-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimpledimple.js
536 lines (507 loc) · 25.7 KB
/
simpledimple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
// Copyright: 2016 Nagarajan Chinnsamy, Mindtree and Other Contributors
// License: https://github.com/nagarajanchinnasamy/simpledimple/blob/master/LICENSE
// Wrap all application code in a self-executing function which handles optional AMD/CommonJS publishing
(function (context, simpledimple) {
"use strict";
if (typeof exports === "object") {
// CommonJS
module.exports = simpledimple(require('d3'), require('dimple'));
} else {
if (typeof define === "function" && define.amd) {
// RequireJS | AMD
define(["d3", "dimple"], function (d3, dimple) {
// publish simpledimple to the global namespace for backwards compatibility
// and define it as an AMD module
context.simpledimple = simpledimple(d3, dimple);
return context.simpledimple;
});
} else {
// No AMD, expect d3 to exist in the current context and publish
// simpledimple to the global namespace
if (!context.d3) {
if (console && console.warn) {
console.warn("simpledimple requires d3 to run. Are you missing a reference to the d3 library?");
} else {
throw "simpledimple requires d3 to run. Are you missing a reference to the d3 library?";
}
} else if (!context.dimple) {
if (console && console.warn) {
console.warn("simpledimple requires dimple to run. Are you missing a reference to the dimple library?");
} else {
throw "simpledimple requires dimple to run. Are you missing a reference to the dimple library?";
}
} else {
context.simpledimple = simpledimple(context.d3, context.dimple);
}
}
}
}(this, function (d3, dimple) {
"use strict";
/*jslint unparam: true*/
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart
function SimpleDimpleChart(svg, chartConfig, data) {
var bounds, noFormats, i, n, axis, series, legend, aClass, colors, color, margins, makeEventHandler, makeAfterDrawHandler;
makeEventHandler = function (handler, chart, data, userData) {
return function (e) {
handler(e, chart, data, userData);
};
};
makeAfterDrawHandler = function (handler, chart, data, userData) {
return function (shape, shapeData) {
handler(shape, shapeData, chart, data, userData);
};
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-addAxis
this.addAxis = function (config) {
var j, m, isInt, dimpleAxis, rule,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-position
position = config.position || null,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-categoryFields
categoryFields = config.categoryFields || null,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-measure
measure = config.measure || null,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-timeField
timeField = config.timeField || null,
// Help: https://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#addTimeAxis
inputFormat = config.inputFormat || null,
// Help: https://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#addTimeAxis
outputFormat = config.outputFormat || null,
timePeriods = {
seconds: d3.time.seconds,
minutes: d3.time.minutes,
hours: d3.time.hours,
days: d3.time.days,
weeks: d3.time.weeks,
sundays: d3.time.sundays,
mondays: d3.time.mondays,
tuesdays: d3.time.tuesdays,
wednesdays: d3.time.wednesdays,
thursdays: d3.time.thursdays,
fridays: d3.time.fridays,
saturdays: d3.time.saturdays,
months: d3.time.months,
years: d3.time.years
};
isInt = function (value) {
var x;
if (isNaN(value)) {
return false;
}
x = parseFloat(value);
/*jslint bitwise: true */
return (x | 0) === x;
};
if (isInt(position)) {
position = this._chart.axes[position];
}
if (timeField) {
dimpleAxis = this._chart.addTimeAxis(position, timeField, inputFormat, outputFormat);
} else if (config.position === "c" && config.colors) {
dimpleAxis = this._chart.addColorAxis(measure, config.colors);
} else {
dimpleAxis = this._chart.addAxis(position, categoryFields, measure, null);
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-floatingBarWidth
if (config.floatingBarWidth !== undefined) {
dimpleAxis.floatingBarWidth = config.floatingBarWidth;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-hidden
if (config.hidden !== undefined) {
dimpleAxis.hidden = config.hidden;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-showPercent
if (config.showPercent !== undefined) {
dimpleAxis.showPercent = config.showPercent;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-colors
if (config.colors !== undefined) {
dimpleAxis.colors = config.colors;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-overrideMin
if (config.overrideMin !== undefined) {
if (config.timeField !== undefined) {
dimpleAxis.overrideMin = new Date(config.overrideMin);
} else {
dimpleAxis.overrideMin = config.overrideMin;
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-overrideMax
if (config.overrideMax !== undefined) {
if (config.timeField !== undefined) {
dimpleAxis.overrideMax = new Date(config.overrideMax);
} else {
dimpleAxis.overrideMax = config.overrideMax;
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-showGridlines
if (config.showGridlines !== undefined) {
dimpleAxis.showGridlines = config.showGridlines;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-dateParseFormat
if (config.dateParseFormat !== undefined) {
dimpleAxis.dateParseFormat = config.dateParseFormat;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-tickFormat
if (config.tickFormat !== undefined) {
dimpleAxis.tickFormat = config.tickFormat;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-timePeriod
if (config.timePeriod !== undefined) {
dimpleAxis.timePeriod = timePeriods[config.timePeriod];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-timeInterval
if (config.timeInterval !== undefined) {
dimpleAxis.timeInterval = config.timeInterval;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-useLog
if (config.useLog !== undefined) {
dimpleAxis.useLog = config.useLog;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-logBase
if (config.logBase !== undefined) {
dimpleAxis.logBase = config.logBase;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-title
if (config.title !== undefined) {
dimpleAxis.title = config.title;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-clamp
if (config.clamp !== undefined) {
dimpleAxis.clamp = config.clamp;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-ticks
if (config.ticks !== undefined) {
dimpleAxis.ticks = config.ticks;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-fontSize
if (config.fontSize !== undefined) {
dimpleAxis.fontSize = config.fontSize;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-fontFamily
if (config.fontFamily !== undefined) {
dimpleAxis.fontFamily = config.fontFamily;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-autoRotateLabel
if (config.autoRotateLabel !== undefined) {
dimpleAxis.autoRotateLabel = config.autoRotateLabel;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-addGroupOrderRule
if (config.groupOrderRules !== undefined) {
m = config.groupOrderRules.length;
for (j = 0; j < m; j++) {
rule = config.groupOrderRules[j];
dimpleAxis.addGroupOrderRule(rule.ordering, rule.desc);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleAxis#wiki-addOrderRule
if (config.orderRules !== undefined) {
m = config.orderRules.length;
for (j = 0; j < m; j++) {
rule = config.orderRules[j];
dimpleAxis.addOrderRule(rule.ordering, rule.desc);
}
}
// return the dimpleAxis
return dimpleAxis;
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-addLegend
this.addLegend = function (config) {
var j, m, cSeries, lSeries, dimpleLegend;
cSeries = config.series;
m = cSeries ? cSeries.length : 0;
lSeries = m ? [] : null;
for (j = 0; j < m; j++) {
lSeries.push(series[cSeries[j]]);
}
dimpleLegend = this._chart.addLegend(config.x, config.y, config.width, config.height, config.horizontalAlign, lSeries);
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleLegend#wiki-fontSize
if (config.fontSize !== undefined) {
dimpleLegend.fontSize = config.fontSize;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleLegend#wiki-fontFamily
if (config.fontFamily !== undefined) {
dimpleLegend.fontFamily = config.fontFamily;
}
return dimpleLegend;
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-addSeries
this.addSeries = function (config) {
var j, m, dimpleSeries, seriesAxes, rule, handler,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-categoryFields
categoryFields = config.categoryFields || null,
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-plot
plotFunctions = {
"area": dimple.plot.area,
"bar": dimple.plot.bar,
"bubble": dimple.plot.bubble,
"line": dimple.plot.line,
"pie": dimple.plot.pie
},
aggregateFunctions = {
"avg": dimple.aggregateMethod.avg,
"count": dimple.aggregateMethod.count,
"max": dimple.aggregateMethod.max,
"min": dimple.aggregateMethod.min,
"sum": dimple.aggregateMethod.sum
}, afterDraw;
if (config.axes && config.axes.length) {
seriesAxes = [];
m = config.axes.length;
for (j = 0; j < m; j++) {
seriesAxes.push(this.axes[config.axes[j]]);
}
} else {
seriesAxes = null;
}
dimpleSeries = this._chart.addSeries(categoryFields, plotFunctions[config.plot], seriesAxes);
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-x
if (config.x !== undefined) {
dimpleSeries.x = this.axes[config.x];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-y
if (config.y !== undefined) {
dimpleSeries.y = this.axes[config.y];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-z
if (config.z !== undefined) {
dimpleSeries.z = this.axes[config.z];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-c
if (config.c !== undefined) {
dimpleSeries.c = this.axes[config.c];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-p
if (config.p !== undefined) {
dimpleSeries.p = this.axes[config.p];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-plot
if (config.plot !== undefined) {
dimpleSeries.plot = plotFunctions[config.plot];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-aggregateFunction
if (config.aggregate !== undefined) {
dimpleSeries.aggregate = aggregateFunctions[config.aggregate];
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-stacked
if (config.stacked !== undefined) {
dimpleSeries.stacked = config.stacked;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-barGap
if (config.barGap !== undefined) {
dimpleSeries.barGap = config.barGap;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-clusterBarGap
if (config.clusterBarGap !== undefined) {
dimpleSeries.clusterBarGap = config.clusterBarGap;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-lineWeight
if (config.lineWeight !== undefined) {
dimpleSeries.lineWeight = config.lineWeight;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-lineMarkers
if (config.lineMarkers !== undefined) {
dimpleSeries.lineMarkers = config.lineMarkers;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-afterDraw
if (config.afterDraw !== undefined) {
/*jslint evil: true */
afterDraw = new Function("shape", "shapeData", "chart", "data", "userData", config.afterDraw);
dimpleSeries.afterDraw = makeAfterDrawHandler(afterDraw, this._chart, this.data, this.userData);
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-interpolation
if (config.interpolation !== undefined) {
dimpleSeries.interpolation = config.interpolation;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-tooltipFontSize
if (config.tooltipFontSize !== undefined) {
dimpleSeries.tooltipFontSize = config.tooltipFontSize;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-tooltipFontFamily
if (config.tooltipFontFamily !== undefined) {
dimpleSeries.tooltipFontFamily = config.tooltipFontFamily;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-radius
if (config.radius !== undefined) {
dimpleSeries.radius = config.radius;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-innerRadius
if (config.innerRadius !== undefined) {
dimpleSeries.innerRadius = config.innerRadius;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-outerRadius
if (config.outerRadius !== undefined) {
dimpleSeries.outerRadius = config.outerRadius;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-addOrderRule
if (config.orderRules !== undefined) {
m = config.orderRules.length;
for (j = 0; j < m; j++) {
rule = config.orderRules[j];
dimpleSeries.addOrderRule(rule.ordering, rule.desc);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-addEventHandler
if (config.eventHandlers !== undefined) {
m = config.eventHandlers.length;
for (j = 0; j < m; j++) {
/*jslint evil: true */
handler = new Function("e", "chart", "data", "userData", config.eventHandlers[j].handler);
dimpleSeries.addEventHandler(config.eventHandlers[j].event, makeEventHandler(handler, this._chart, this.data, this.userData));
}
}
return dimpleSeries;
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-draw
this.draw = function (duration, noDataChange) {
this._chart.draw(duration, noDataChange);
if (this.afterDraw) {
this.afterDraw(this);
}
// Return the chart for chaining
return this;
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-setStoryboard
this.setStoryboard = function (config) {
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-onTick
var tickHandler, storyboard, j, m, rule;
if (config.onTick !== undefined) {
/*jslint evil: true */
tickHandler = new Function("e", config.onTick);
}
storyboard = this._chart.setStoryboard(config.categoryFields, tickHandler);
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-autoplay
if (config.autoplay !== undefined) {
storyboard.autoplay = config.autoplay;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-frameDuration
if (config.frameDuration !== undefined) {
storyboard.frameDuration = config.frameDuration;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-storyLabel
if (config.storyLabel !== undefined) {
storyboard.storyLabel = config.storyLabel;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-fontSize
if (config.fontSize !== undefined) {
storyboard.fontSize = config.fontSize;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-fontFamily
if (config.fontFamily !== undefined) {
storyboard.fontFamily = config.fontFamily;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.storyboard#wiki-addOrderRule
if (config.orderRules !== undefined) {
m = config.orderRules.length;
for (j = 0; j < m; j++) {
rule = config.orderRules[j];
storyboard.addOrderRule(rule.ordering, rule.desc);
}
}
return storyboard;
};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.dimpleSeries#wiki-afterDraw
this.userData = {};
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart
this._chart = new dimple.chart(svg, data);
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-setBounds
bounds = chartConfig.bounds;
if (bounds) {
this._chart.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-data
this.data = data;
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-noFormats
noFormats = chartConfig.noFormats;
if (noFormats !== null && noFormats !== undefined) {
this._chart.noFormats = noFormats;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-axes
this.axes = [];
if (chartConfig.axes && chartConfig.axes.length) {
n = chartConfig.axes.length;
for (i = 0; i < n; i++) {
axis = this.addAxis(chartConfig.axes[i]);
this.axes.push(axis);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-series
this.series = [];
if (chartConfig.series && chartConfig.series.length) {
n = chartConfig.series.length;
for (i = 0; i < n; i++) {
series = this.addSeries(chartConfig.series[i]);
this.series.push(series);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-legends
this.legends = [];
if (chartConfig.legends && chartConfig.legends.length) {
n = chartConfig.legends.length;
for (i = 0; i < n; i++) {
legend = this.addLegend(chartConfig.legends[i]);
this.legends.push(legend);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-setStoryboard
if (chartConfig.storyboard) {
this.storyboard = this.setStoryboard(chartConfig.storyboard);
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-ease
if (chartConfig.ease !== undefined) {
this._chart.ease = chartConfig.ease;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-staggerDraw
if (chartConfig.staggerDraw !== undefined) {
this._chart.staggerDraw = chartConfig.staggerDraw;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-assignClass
if (chartConfig.classes !== undefined) {
n = chartConfig.classes.length;
for (i = 0; i < n; i++) {
aClass = chartConfig.classes[i];
this._chart.assignClass(aClass.tag, aClass.css);
}
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-defaultColors
if (chartConfig.defaultColors !== undefined) {
n = chartConfig.defaultColors.length;
colors = [];
for (i = 0; i < n; i++) {
color = chartConfig.defaultColors[i];
colors.push(new dimple.color(color.fill, color.stroke, color.opacity));
}
this._chart.defaultColors = colors;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-customClassList
if (chartConfig.customClassList !== undefined) {
this._chart.customClassList = chartConfig.customClassList;
}
// Help: http://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#wiki-setMargins
margins = chartConfig.margins;
if (margins !== undefined) {
this._chart.setMargins(margins.x, margins.y, margins.width, margins.height);
}
// Help: https://github.com/PMSI-AlignAlytics/dimple/wiki/dimple.chart#assignColor
if (chartConfig.assignedColors !== undefined) {
n = chartConfig.assignedColors.length;
colors = {};
for (i = 0; i < n; i++) {
color = chartConfig.assignedColors[i];
colors[color.tag] = this._chart.assignColor(color.tag, color.fill, color.stroke, color.opacity);
}
this._chart.assignedColors = colors;
}
if (chartConfig.afterDraw !== undefined) {
/*jslint evil: true */
this.afterDraw = new Function("simpledimple", chartConfig.afterDraw);
}
return this;
}
// Create the stub object
var simpledimple = {
version: "1.1.0",
chart: SimpleDimpleChart
};
return simpledimple;
}));
// End simpledimple