diff --git a/c3.js b/c3.js
index dca10f5..21876ab 100644
--- a/c3.js
+++ b/c3.js
@@ -1,5354 +1,5720 @@
+/**
+ * c3.core.js
+ */
(function (window) {
'use strict';
/*global define, module, exports, require */
- var c3 = {
- version: "0.2.4"
- };
+ var c3 = { version: "0.3.0" };
- var CLASS = {
- target: 'c3-target',
- chart : 'c3-chart',
- chartLine: 'c3-chart-line',
- chartLines: 'c3-chart-lines',
- chartBar: 'c3-chart-bar',
- chartBars: 'c3-chart-bars',
- chartText: 'c3-chart-text',
- chartTexts: 'c3-chart-texts',
- chartArc: 'c3-chart-arc',
- chartArcs: 'c3-chart-arcs',
- chartArcsTitle: 'c3-chart-arcs-title',
- chartArcsBackground: 'c3-chart-arcs-background',
- chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit',
- chartArcsGaugeMax: 'c3-chart-arcs-gauge-max',
- chartArcsGaugeMin: 'c3-chart-arcs-gauge-min',
- selectedCircle: 'c3-selected-circle',
- selectedCircles: 'c3-selected-circles',
- eventRect: 'c3-event-rect',
- eventRects: 'c3-event-rects',
- eventRectsSingle: 'c3-event-rects-single',
- eventRectsMultiple: 'c3-event-rects-multiple',
- zoomRect: 'c3-zoom-rect',
- brush: 'c3-brush',
- focused: 'c3-focused',
- region: 'c3-region',
- regions: 'c3-regions',
- tooltip: 'c3-tooltip',
- tooltipName: 'c3-tooltip-name',
- shape: 'c3-shape',
- shapes: 'c3-shapes',
- line: 'c3-line',
- lines: 'c3-lines',
- bar: 'c3-bar',
- bars: 'c3-bars',
- circle: 'c3-circle',
- circles: 'c3-circles',
- arc: 'c3-arc',
- arcs: 'c3-arcs',
- area: 'c3-area',
- areas: 'c3-areas',
- empty: 'c3-empty',
- text: 'c3-text',
- texts: 'c3-texts',
- gaugeValue: 'c3-gauge-value',
- grid: 'c3-grid',
- xgrid: 'c3-xgrid',
- xgrids: 'c3-xgrids',
- xgridLine: 'c3-xgrid-line',
- xgridLines: 'c3-xgrid-lines',
- xgridFocus: 'c3-xgrid-focus',
- ygrid: 'c3-ygrid',
- ygrids: 'c3-ygrids',
- ygridLine: 'c3-ygrid-line',
- ygridLines: 'c3-ygrid-lines',
- axis: 'c3-axis',
- axisX: 'c3-axis-x',
- axisXLabel: 'c3-axis-x-label',
- axisY: 'c3-axis-y',
- axisYLabel: 'c3-axis-y-label',
- axisY2: 'c3-axis-y2',
- axisY2Label: 'c3-axis-y2-label',
- legendBackground: 'c3-legend-background',
- legendItem: 'c3-legend-item',
- legendItemEvent: 'c3-legend-item-event',
- legendItemTile: 'c3-legend-item-tile',
- legendItemHidden: 'c3-legend-item-hidden',
- legendItemFocused: 'c3-legend-item-focused',
- dragarea: 'c3-dragarea',
- EXPANDED: '_expanded_',
- SELECTED: '_selected_',
- INCLUDED: '_included_',
+ // will be called to generate c3 chart object
+ c3.generate = function (config) {
+ return new c3_chart(config);
};
- /*
- * Generate chart according to config
- */
- c3.generate = function (config) {
+ // c3.fn.$$ and c3.fn.chart will be defined as prototype interface
+ c3.fn = {};
+
+ /*-- HIDDEN VARS AND FUNCTIONS --*/
+
+ // Define solid chart for hiding its functions from chart object scope
+ var chart = function () {};
- var d3 = window.d3 ? window.d3 : 'undefined' !== typeof require ? require("d3") : undefined;
+ // Wrap solid chart object and call functions defined through c3.fn.$$ and c3.fn.chart
+ var c3_chart = function (config) {
- var c3 = { data : {}, axis: {}, legend: {} },
- cache = {};
+ var $$ = this.$$ = new chart(),
+ d3 = $$.d3 = window.d3 ? window.d3 : 'undefined' !== typeof require ? require("d3") : undefined;
+
+ $$.this = this;
+ $$.config = config;
+ $$.data = {};
+ $$.cache = {};
/*-- Handle Config --*/
- function checkConfig(key, message) {
- if (! (key in config)) { throw Error(message); }
+ $$.updateConfig();
+
+ // TODO: this should be an API
+ this.config = config;
+
+ /*-- Set Variables --*/
+
+ // TODO: some of these should be a function and defined in prototype
+
+ // MEMO: clipId needs to be unique because it conflicts when multiple charts exist
+ $$.clipId = "c3-" + (+new Date()) + '-clip',
+ $$.clipIdForXAxis = $$.clipId + '-xaxis',
+ $$.clipIdForYAxis = $$.clipId + '-yaxis',
+ $$.clipPath = $$.getClipPath($$.clipId),
+ $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis),
+ $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis);
+
+ $$.isTimeSeries = ($$.__axis_x_type === 'timeseries');
+ $$.isCategorized = ($$.__axis_x_type.indexOf('categor') >= 0);
+ $$.isCustomX = function () { return !$$.isTimeSeries && ($$.__data_x || $$.notEmpty($$.__data_xs)); };
+
+ $$.dragStart = null;
+ $$.dragging = false;
+ $$.cancelClick = false;
+ $$.mouseover = false;
+ $$.transiting = false;
+
+ $$.defaultColorPattern = d3.scale.category10().range();
+ $$.color = $$.generateColor($$.__data_colors, $$.notEmpty($$.__color_pattern) ? $$.__color_pattern : $$.defaultColorPattern, $$.__data_color);
+ $$.levelColor = $$.notEmpty($$.__color_threshold) ? $$.generateLevelColor($$.__color_pattern, $$.__color_threshold) : null;
+
+ $$.dataTimeFormat = $$.__data_x_localtime ? d3.time.format : d3.time.format.utc;
+ $$.axisTimeFormat = $$.__axis_x_localtime ? d3.time.format : d3.time.format.utc;
+ $$.defaultAxisTimeFormat = $$.axisTimeFormat.multi([
+ [".%L", function (d) { return d.getMilliseconds(); }],
+ [":%S", function (d) { return d.getSeconds(); }],
+ ["%I:%M", function (d) { return d.getMinutes(); }],
+ ["%I %p", function (d) { return d.getHours(); }],
+ ["%-m/%-d", function (d) { return d.getDay() && d.getDate() !== 1; }],
+ ["%-m/%-d", function (d) { return d.getDate() !== 1; }],
+ ["%-m/%-d", function (d) { return d.getMonth(); }],
+ ["%Y/%-m/%-d", function () { return true; }]
+ ]);
+
+ $$.hiddenTargetIds = [];
+ $$.hiddenLegendIds = [];
+
+ $$.axes = {};
+
+ $$.xOrient = $$.__axis_rotated ? "left" : "bottom";
+ $$.yOrient = $$.__axis_rotated ? ($$.__axis_y_inner ? "top" : "bottom") : ($$.__axis_y_inner ? "right" : "left");
+ $$.y2Orient = $$.__axis_rotated ? ($$.__axis_y2_inner ? "bottom" : "top") : ($$.__axis_y2_inner ? "left" : "right");
+ $$.subXOrient = $$.__axis_rotated ? "left" : "bottom";
+
+ $$.translate = {
+ main : function () { return "translate(" + $$.asHalfPixel($$.margin.left) + "," + $$.asHalfPixel($$.margin.top) + ")"; },
+ context : function () { return "translate(" + $$.asHalfPixel($$.margin2.left) + "," + $$.asHalfPixel($$.margin2.top) + ")"; },
+ legend : function () { return "translate(" + $$.margin3.left + "," + $$.margin3.top + ")"; },
+ x : function () { return "translate(0," + ($$.__axis_rotated ? 0 : $$.height) + ")"; },
+ y : function () { return "translate(0," + ($$.__axis_rotated ? $$.height : 0) + ")"; },
+ y2 : function () { return "translate(" + ($$.__axis_rotated ? 0 : $$.width) + "," + ($$.__axis_rotated ? 1 : 0) + ")"; },
+ subx : function () { return "translate(0," + ($$.__axis_rotated ? 0 : $$.height2) + ")"; },
+ arc: function () { return "translate(" + ($$.arcWidth / 2) + "," + ($$.arcHeight / 2) + ")"; }
+ };
+
+ $$.isLegendRight = $$.__legend_position === 'right';
+ $$.isLegendInset = $$.__legend_position === 'inset';
+ $$.isLegendTop = $$.__legend_inset_anchor === 'top-left' || $$.__legend_inset_anchor === 'top-right';
+ $$.isLegendLeft = $$.__legend_inset_anchor === 'top-left' || $$.__legend_inset_anchor === 'bottom-left';
+ $$.legendStep = 0;
+ $$.legendItemWidth = 0;
+ $$.legendItemHeight = 0;
+ $$.legendOpacityForHidden = 0.15;
+
+ $$.currentMaxTickWidth = 0;
+
+ $$.rotated_padding_left = 30;
+ $$.rotated_padding_right = $$.__axis_rotated && !$$.__axis_x_show ? 0 : 30;
+ $$.rotated_padding_top = 5;
+
+ $$.withoutFadeIn = {};
+
+ // TODO: this should be pluggable
+ $$.pie = d3.layout.pie().value(function (d) {
+ return d.values.reduce(function (a, b) { return a + b.value; }, 0);
+ });
+ if (!$$.__pie_sort || !$$.__donut_sort) { // TODO: this needs to be called by each type
+ $$.pie.sort(null);
}
- function getConfig(keys, defaultValue) {
- var target = config, i, isLast, nextTarget;
- for (i = 0; i < keys.length; i++) {
- // return default if key not found
- if (typeof target === 'object' && !(keys[i] in target)) { return defaultValue; }
- // Check next key's value
- isLast = (i === keys.length - 1);
- nextTarget = target[keys[i]];
- if (!isLast && typeof nextTarget !== 'object') {
- return defaultValue;
- }
- target = nextTarget;
- }
- return target;
- }
-
- // bindto - id to bind the chart
- var __bindto = getConfig(['bindto'], '#chart');
-
- var __size_width = getConfig(['size', 'width']),
- __size_height = getConfig(['size', 'height']);
-
- var __padding_left = getConfig(['padding', 'left']),
- __padding_right = getConfig(['padding', 'right']),
- __padding_top = getConfig(['padding', 'top']),
- __padding_bottom = getConfig(['padding', 'bottom']);
-
- var __zoom_enabled = getConfig(['zoom', 'enabled'], false),
- __zoom_extent = getConfig(['zoom', 'extent']),
- __zoom_privileged = getConfig(['zoom', 'privileged'], false),
- __zoom_onzoom = getConfig(['zoom', 'onzoom'], function () {});
-
- var __interaction_enabled = getConfig(['interaction', 'enabled'], true);
-
- var __onmouseover = getConfig(['onmouseover'], function () {}),
- __onmouseout = getConfig(['onmouseout'], function () {}),
- __onresize = getConfig(['onresize'], function () {}),
- __onresized = getConfig(['onresized'], function () {});
-
- var __transition_duration = getConfig(['transition', 'duration'], 350);
-
- // data - data configuration
- checkConfig('data', 'data is required in config');
-
- var __data_x = getConfig(['data', 'x']),
- __data_xs = getConfig(['data', 'xs'], {}),
- __data_x_format = getConfig(['data', 'x_format'], '%Y-%m-%d'),
- __data_x_localtime = getConfig(['data', 'x_localtime'], true),
- __data_id_converter = getConfig(['data', 'id_converter'], function (id) { return id; }),
- __data_names = getConfig(['data', 'names'], {}),
- __data_classes = getConfig(['data', 'classes'], {}),
- __data_groups = getConfig(['data', 'groups'], []),
- __data_axes = getConfig(['data', 'axes'], {}),
- __data_type = getConfig(['data', 'type']),
- __data_types = getConfig(['data', 'types'], {}),
- __data_labels = getConfig(['data', 'labels'], {}),
- __data_order = getConfig(['data', 'order']),
- __data_regions = getConfig(['data', 'regions'], {}),
- __data_color = getConfig(['data', 'color']),
- __data_colors = getConfig(['data', 'colors'], {}),
- __data_hide = getConfig(['data', 'hide'], false),
- __data_filter = getConfig(['data', 'filter']),
- __data_selection_enabled = getConfig(['data', 'selection', 'enabled'], false),
- __data_selection_grouped = getConfig(['data', 'selection', 'grouped'], false),
- __data_selection_isselectable = getConfig(['data', 'selection', 'isselectable'], function () { return true; }),
- __data_selection_multiple = getConfig(['data', 'selection', 'multiple'], true),
- __data_onclick = getConfig(['data', 'onclick'], function () {}),
- __data_onmouseover = getConfig(['data', 'onmouseover'], function () {}),
- __data_onmouseout = getConfig(['data', 'onmouseout'], function () {}),
- __data_onselected = getConfig(['data', 'onselected'], function () {}),
- __data_onunselected = getConfig(['data', 'onunselected'], function () {}),
- __data_ondragstart = getConfig(['data', 'ondragstart'], function () {}),
- __data_ondragend = getConfig(['data', 'ondragend'], function () {});
+ // TODO: this should be pluggable
+ $$.brush = d3.svg.brush().on("brush", $$.redrawForBrush);
+ $$.brush.update = function () {
+ if ($$.context) { $$.context.select('.' + this.CLASS.brush).call(this); }
+ return this;
+ };
+ $$.brush.scale = function (scale) {
+ return $$.__axis_rotated ? this.y(scale) : this.x(scale);
+ };
+
+ // TODO: this should be pluggable
+ $$.zoom = d3.behavior.zoom()
+ .on("zoomstart", function () {
+ $$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null;
+ })
+ .on("zoom", $$.redrawForZoom);
+ $$.zoom.scale = function (scale) {
+ return $$.__axis_rotated ? this.y(scale) : this.x(scale);
+ };
+ $$.zoom.orgScaleExtent = function () {
+ var extent = $$.__zoom_extent ? $$.__zoom_extent : [1, 10];
+ return [extent[0], Math.max(this.getMaxDataCount() / extent[1], extent[1])];
+ };
+ $$.zoom.updateScaleExtent = function () {
+ var ratio = this.diffDomain($$.x.orgDomain()) / this.diffDomain(this.orgXDomain), extent = this.orgScaleExtent();
+ this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
+ return this;
+ };
+
+ /*-- Load data and init chart with defined functions --*/
+
+ if (config.data.url) {
+ $$.convertUrlToData(config.data.url, config.data.mimeType, config.data.keys, $$.init);
+ }
+ else if (config.data.json) {
+ $$.init($$.convertJsonToData(config.data.json, config.data.keys));
+ }
+ else if (config.data.rows) {
+ $$.init($$.convertRowsToData(config.data.rows));
+ }
+ else if (config.data.columns) {
+ $$.init($$.convertColumnsToData(config.data.columns));
+ }
+ else {
+ throw Error('url or json or rows or columns is required.');
+ }
+ };
+
+ // Open interface for each prototype
+ c3.fn.chart = c3_chart.prototype = {};
+ c3.fn.$$ = chart.prototype = {};
+
+ if (typeof define === "function" && define.amd) {
+ define("c3", ["d3"], c3);
+ } else if ('undefined' !== typeof exports && 'undefined' !== typeof module) {
+ module.exports = c3;
+ } else {
+ window.c3 = c3;
+ }
+
+})(window);
+
+
+
+// TODO: these should be separated into each file
+(function (c3) {
+ 'use strict';
+
+ /**
+ * c3.config.js
+ */
+ c3.fn.$$.getConfig = function (keys, defaultValue) {
+ var target = this.config, i, isLast, nextTarget;
+ for (i = 0; i < keys.length; i++) {
+ // return default if key not found
+ if (typeof target === 'object' && !(keys[i] in target)) { return defaultValue; }
+ // Check next key's value
+ isLast = (i === keys.length - 1);
+ nextTarget = target[keys[i]];
+ if (!isLast && typeof nextTarget !== 'object') {
+ return defaultValue;
+ }
+ target = nextTarget;
+ }
+ return target;
+ };
+ c3.fn.$$.updateConfig = function () {
+ var $$ = this;
+
+ $$.__bindto = $$.getConfig(['bindto'], '#chart');
+
+ $$.__size_width = $$.getConfig(['size', 'width']);
+ $$.__size_height = $$.getConfig(['size', 'height']);
+
+ $$.__padding_left = $$.getConfig(['padding', 'left']);
+ $$.__padding_right = $$.getConfig(['padding', 'right']);
+ $$.__padding_top = $$.getConfig(['padding', 'top']);
+ $$.__padding_bottom = $$.getConfig(['padding', 'bottom']);
+
+ $$.__zoom_enabled = $$.getConfig(['zoom', 'enabled'], false);
+ $$.__zoom_extent = $$.getConfig(['zoom', 'extent']);
+ $$.__zoom_privileged = $$.getConfig(['zoom', 'privileged'], false);
+ $$.__zoom_onzoom = $$.getConfig(['zoom', 'onzoom'], function () {});
+
+ $$.__interaction_enabled = $$.getConfig(['interaction', 'enabled'], true);
+
+ $$.__onmouseover = $$.getConfig(['onmouseover'], function () {});
+ $$.__onmouseout = $$.getConfig(['onmouseout'], function () {});
+ $$.__onresize = $$.getConfig(['onresize'], function () {});
+ $$.__onresized = $$.getConfig(['onresized'], function () {});
+
+ $$.__transition_duration = $$.getConfig(['transition', 'duration'], 350);
+
+ $$.__data_x = $$.getConfig(['data', 'x']);
+ $$.__data_xs = $$.getConfig(['data', 'xs'], {});
+ $$.__data_x_format = $$.getConfig(['data', 'x_format'], '%Y-%m-%d');
+ $$.__data_x_localtime = $$.getConfig(['data', 'x_localtime'], true);
+ $$.__data_id_converter = $$.getConfig(['data', 'id_converter'], function (id) { return id; });
+ $$.__data_names = $$.getConfig(['data', 'names'], {});
+ $$.__data_classes = $$.getConfig(['data', 'classes'], {});
+ $$.__data_groups = $$.getConfig(['data', 'groups'], []);
+ $$.__data_axes = $$.getConfig(['data', 'axes'], {});
+ $$.__data_type = $$.getConfig(['data', 'type']);
+ $$.__data_types = $$.getConfig(['data', 'types'], {});
+ $$.__data_labels = $$.getConfig(['data', 'labels'], {});
+ $$.__data_order = $$.getConfig(['data', 'order']);
+ $$.__data_regions = $$.getConfig(['data', 'regions'], {});
+ $$.__data_color = $$.getConfig(['data', 'color']);
+ $$.__data_colors = $$.getConfig(['data', 'colors'], {});
+ $$.__data_hide = $$.getConfig(['data', 'hide'], false);
+ $$.__data_filter = $$.getConfig(['data', 'filter']);
+ $$.__data_selection_enabled = $$.getConfig(['data', 'selection', 'enabled'], false);
+ $$.__data_selection_grouped = $$.getConfig(['data', 'selection', 'grouped'], false);
+ $$.__data_selection_isselectable = $$.getConfig(['data', 'selection', 'isselectable'], function () { return true; });
+ $$.__data_selection_multiple = $$.getConfig(['data', 'selection', 'multiple'], true);
+ $$.__data_onclick = $$.getConfig(['data', 'onclick'], function () {});
+ $$.__data_onmouseover = $$.getConfig(['data', 'onmouseover'], function () {});
+ $$.__data_onmouseout = $$.getConfig(['data', 'onmouseout'], function () {});
+ $$.__data_onselected = $$.getConfig(['data', 'onselected'], function () {});
+ $$.__data_onunselected = $$.getConfig(['data', 'onunselected'], function () {});
+ $$.__data_ondragstart = $$.getConfig(['data', 'ondragstart'], function () {});
+ $$.__data_ondragend = $$.getConfig(['data', 'ondragend'], function () {});
// configuration for no plot-able data supplied.
- var __data_empty_label_text = getConfig(['data', 'empty', 'label', 'text'], "");
+ $$.__data_empty_label_text = $$.getConfig(['data', 'empty', 'label', 'text'], "");
// subchart
- var __subchart_show = getConfig(['subchart', 'show'], false),
- __subchart_size_height = getConfig(['subchart', 'size', 'height'], 60),
- __subchart_onbrush = getConfig(['subchart', 'onbrush'], function () {});
+ $$.__subchart_show = $$.getConfig(['subchart', 'show'], false);
+ $$.__subchart_size_height = $$.getConfig(['subchart', 'size', 'height'], 60);
+ $$.__subchart_onbrush = $$.getConfig(['subchart', 'onbrush'], function () {});
// color
- var __color_pattern = getConfig(['color', 'pattern'], []),
- __color_threshold = getConfig(['color', 'threshold'], {});
+ $$.__color_pattern = $$.getConfig(['color', 'pattern'], []);
+ $$.__color_threshold = $$.getConfig(['color', 'threshold'], {});
// legend
- var __legend_show = getConfig(['legend', 'show'], true),
- __legend_position = getConfig(['legend', 'position'], 'bottom'),
- __legend_inset_anchor = getConfig(['legend', 'inset', 'anchor'], 'top-left'),
- __legend_inset_x = getConfig(['legend', 'inset', 'x'], 10),
- __legend_inset_y = getConfig(['legend', 'inset', 'y'], 0),
- __legend_inset_step = getConfig(['legend', 'inset', 'step']),
- __legend_item_onclick = getConfig(['legend', 'item', 'onclick']),
- __legend_item_onmouseover = getConfig(['legend', 'item', 'onmouseover']),
- __legend_item_onmouseout = getConfig(['legend', 'item', 'onmouseout']),
- __legend_equally = getConfig(['legend', 'equally'], false);
+ $$.__legend_show = $$.getConfig(['legend', 'show'], true);
+ $$.__legend_position = $$.getConfig(['legend', 'position'], 'bottom');
+ $$.__legend_inset_anchor = $$.getConfig(['legend', 'inset', 'anchor'], 'top-left');
+ $$.__legend_inset_x = $$.getConfig(['legend', 'inset', 'x'], 10);
+ $$.__legend_inset_y = $$.getConfig(['legend', 'inset', 'y'], 0);
+ $$.__legend_inset_step = $$.getConfig(['legend', 'inset', 'step']);
+ $$.__legend_item_onclick = $$.getConfig(['legend', 'item', 'onclick']);
+ $$.__legend_item_onmouseover = $$.getConfig(['legend', 'item', 'onmouseover']);
+ $$.__legend_item_onmouseout = $$.getConfig(['legend', 'item', 'onmouseout']);
+ $$.__legend_equally = $$.getConfig(['legend', 'equally'], false);
// axis
- var __axis_rotated = getConfig(['axis', 'rotated'], false),
- __axis_x_show = getConfig(['axis', 'x', 'show'], true),
- __axis_x_type = getConfig(['axis', 'x', 'type'], 'indexed'),
- __axis_x_localtime = getConfig(['axis', 'x', 'localtime'], true),
- __axis_x_categories = getConfig(['axis', 'x', 'categories'], []),
- __axis_x_tick_centered = getConfig(['axis', 'x', 'tick', 'centered'], false),
- __axis_x_tick_format = getConfig(['axis', 'x', 'tick', 'format']),
- __axis_x_tick_culling = getConfig(['axis', 'x', 'tick', 'culling'], {}),
- __axis_x_tick_culling_max = getConfig(['axis', 'x', 'tick', 'culling', 'max'], 10),
- __axis_x_tick_count = getConfig(['axis', 'x', 'tick', 'count']),
- __axis_x_tick_fit = getConfig(['axis', 'x', 'tick', 'fit'], true),
- __axis_x_tick_values = getConfig(['axis', 'x', 'tick', 'values'], null),
- __axis_x_tick_rotate = getConfig(['axis', 'x', 'tick', 'rotate']),
- __axis_x_max = getConfig(['axis', 'x', 'max'], null),
- __axis_x_min = getConfig(['axis', 'x', 'min'], null),
- __axis_x_padding = getConfig(['axis', 'x', 'padding'], {}),
- __axis_x_height = getConfig(['axis', 'x', 'height']),
- __axis_x_default = getConfig(['axis', 'x', 'default']),
- __axis_x_label = getConfig(['axis', 'x', 'label'], {}),
- __axis_y_show = getConfig(['axis', 'y', 'show'], true),
- __axis_y_max = getConfig(['axis', 'y', 'max']),
- __axis_y_min = getConfig(['axis', 'y', 'min']),
- __axis_y_center = getConfig(['axis', 'y', 'center']),
- __axis_y_label = getConfig(['axis', 'y', 'label'], {}),
- __axis_y_inner = getConfig(['axis', 'y', 'inner'], false),
- __axis_y_tick_format = getConfig(['axis', 'y', 'tick', 'format']),
- __axis_y_padding = getConfig(['axis', 'y', 'padding']),
- __axis_y_ticks = getConfig(['axis', 'y', 'ticks'], 10),
- __axis_y2_show = getConfig(['axis', 'y2', 'show'], false),
- __axis_y2_max = getConfig(['axis', 'y2', 'max']),
- __axis_y2_min = getConfig(['axis', 'y2', 'min']),
- __axis_y2_center = getConfig(['axis', 'y2', 'center']),
- __axis_y2_label = getConfig(['axis', 'y2', 'label'], {}),
- __axis_y2_inner = getConfig(['axis', 'y2', 'inner'], false),
- __axis_y2_tick_format = getConfig(['axis', 'y2', 'tick', 'format']),
- __axis_y2_padding = getConfig(['axis', 'y2', 'padding']),
- __axis_y2_ticks = getConfig(['axis', 'y2', 'ticks'], 10);
+ $$.__axis_rotated = $$.getConfig(['axis', 'rotated'], false);
+ $$.__axis_x_show = $$.getConfig(['axis', 'x', 'show'], true);
+ $$.__axis_x_type = $$.getConfig(['axis', 'x', 'type'], 'indexed');
+ $$.__axis_x_localtime = $$.getConfig(['axis', 'x', 'localtime'], true);
+ $$.__axis_x_categories = $$.getConfig(['axis', 'x', 'categories'], []);
+ $$.__axis_x_tick_centered = $$.getConfig(['axis', 'x', 'tick', 'centered'], false);
+ $$.__axis_x_tick_format = $$.getConfig(['axis', 'x', 'tick', 'format']);
+ $$.__axis_x_tick_culling = $$.getConfig(['axis', 'x', 'tick', 'culling'], {});
+ $$.__axis_x_tick_culling_max = $$.getConfig(['axis', 'x', 'tick', 'culling', 'max'], 10);
+ $$.__axis_x_tick_count = $$.getConfig(['axis', 'x', 'tick', 'count']);
+ $$.__axis_x_tick_fit = $$.getConfig(['axis', 'x', 'tick', 'fit'], true);
+ $$.__axis_x_tick_values = $$.getConfig(['axis', 'x', 'tick', 'values'], null);
+ $$.__axis_x_tick_rotate = $$.getConfig(['axis', 'x', 'tick', 'rotate']);
+ $$.__axis_x_max = $$.getConfig(['axis', 'x', 'max'], null);
+ $$.__axis_x_min = $$.getConfig(['axis', 'x', 'min'], null);
+ $$.__axis_x_padding = $$.getConfig(['axis', 'x', 'padding'], {});
+ $$.__axis_x_height = $$.getConfig(['axis', 'x', 'height']);
+ $$.__axis_x_default = $$.getConfig(['axis', 'x', 'default']);
+ $$.__axis_x_label = $$.getConfig(['axis', 'x', 'label'], {});
+ $$.__axis_y_show = $$.getConfig(['axis', 'y', 'show'], true);
+ $$.__axis_y_max = $$.getConfig(['axis', 'y', 'max']);
+ $$.__axis_y_min = $$.getConfig(['axis', 'y', 'min']);
+ $$.__axis_y_center = $$.getConfig(['axis', 'y', 'center']);
+ $$.__axis_y_label = $$.getConfig(['axis', 'y', 'label'], {});
+ $$.__axis_y_inner = $$.getConfig(['axis', 'y', 'inner'], false);
+ $$.__axis_y_tick_format = $$.getConfig(['axis', 'y', 'tick', 'format']);
+ $$.__axis_y_padding = $$.getConfig(['axis', 'y', 'padding']);
+ $$.__axis_y_ticks = $$.getConfig(['axis', 'y', 'ticks'], 10);
+ $$.__axis_y2_show = $$.getConfig(['axis', 'y2', 'show'], false);
+ $$.__axis_y2_max = $$.getConfig(['axis', 'y2', 'max']);
+ $$.__axis_y2_min = $$.getConfig(['axis', 'y2', 'min']);
+ $$.__axis_y2_center = $$.getConfig(['axis', 'y2', 'center']);
+ $$.__axis_y2_label = $$.getConfig(['axis', 'y2', 'label'], {});
+ $$.__axis_y2_inner = $$.getConfig(['axis', 'y2', 'inner'], false);
+ $$.__axis_y2_tick_format = $$.getConfig(['axis', 'y2', 'tick', 'format']);
+ $$.__axis_y2_padding = $$.getConfig(['axis', 'y2', 'padding']);
+ $$.__axis_y2_ticks = $$.getConfig(['axis', 'y2', 'ticks'], 10);
// grid
- var __grid_x_show = getConfig(['grid', 'x', 'show'], false),
- __grid_x_type = getConfig(['grid', 'x', 'type'], 'tick'),
- __grid_x_lines = getConfig(['grid', 'x', 'lines'], []),
- __grid_y_show = getConfig(['grid', 'y', 'show'], false),
- // not used
- // __grid_y_type = getConfig(['grid', 'y', 'type'], 'tick'),
- __grid_y_lines = getConfig(['grid', 'y', 'lines'], []),
- __grid_y_ticks = getConfig(['grid', 'y', 'ticks'], 10),
- __grid_focus_show = getConfig(['grid', 'focus', 'show'], true);
+ $$.__grid_x_show = $$.getConfig(['grid', 'x', 'show'], false);
+ $$.__grid_x_type = $$.getConfig(['grid', 'x', 'type'], 'tick');
+ $$.__grid_x_lines = $$.getConfig(['grid', 'x', 'lines'], []);
+ $$.__grid_y_show = $$.getConfig(['grid', 'y', 'show'], false);
+ // not used
+ // __grid_y_type = $$.getConfig(['grid', 'y', 'type'], 'tick'),
+ $$.__grid_y_lines = $$.getConfig(['grid', 'y', 'lines'], []);
+ $$.__grid_y_ticks = $$.getConfig(['grid', 'y', 'ticks'], 10);
+ $$.__grid_focus_show = $$.getConfig(['grid', 'focus', 'show'], true);
// point - point of each data
- var __point_show = getConfig(['point', 'show'], true),
- __point_r = getConfig(['point', 'r'], 2.5),
- __point_focus_expand_enabled = getConfig(['point', 'focus', 'expand', 'enabled'], true),
- __point_focus_expand_r = getConfig(['point', 'focus', 'expand', 'r']),
- __point_select_r = getConfig(['point', 'focus', 'select', 'r']);
+ $$.__point_show = $$.getConfig(['point', 'show'], true);
+ $$.__point_r = $$.getConfig(['point', 'r'], 2.5);
+ $$.__point_focus_expand_enabled = $$.getConfig(['point', 'focus', 'expand', 'enabled'], true);
+ $$.__point_focus_expand_r = $$.getConfig(['point', 'focus', 'expand', 'r']);
+ $$.__point_select_r = $$.getConfig(['point', 'focus', 'select', 'r']);
- var __line_connect_null = getConfig(['line', 'connect_null'], false);
+ $$.__line_connect_null = $$.getConfig(['line', 'connect_null'], false);
// bar
- var __bar_width = getConfig(['bar', 'width']),
- __bar_width_ratio = getConfig(['bar', 'width', 'ratio'], 0.6),
- __bar_zerobased = getConfig(['bar', 'zerobased'], true);
+ $$.__bar_width = $$.getConfig(['bar', 'width']);
+ $$.__bar_width_ratio = $$.getConfig(['bar', 'width', 'ratio'], 0.6);
+ $$.__bar_zerobased = $$.getConfig(['bar', 'zerobased'], true);
// area
- var __area_zerobased = getConfig(['area', 'zerobased'], true);
+ $$.__area_zerobased = $$.getConfig(['area', 'zerobased'], true);
// pie
- var __pie_label_show = getConfig(['pie', 'label', 'show'], true),
- __pie_label_format = getConfig(['pie', 'label', 'format']),
- __pie_label_threshold = getConfig(['pie', 'label', 'threshold'], 0.05),
- __pie_sort = getConfig(['pie', 'sort'], true),
- __pie_expand = getConfig(['pie', 'expand'], true);
+ $$.__pie_label_show = $$.getConfig(['pie', 'label', 'show'], true);
+ $$.__pie_label_format = $$.getConfig(['pie', 'label', 'format']);
+ $$.__pie_label_threshold = $$.getConfig(['pie', 'label', 'threshold'], 0.05);
+ $$.__pie_sort = $$.getConfig(['pie', 'sort'], true);
+ $$.__pie_expand = $$.getConfig(['pie', 'expand'], true);
// gauge
- var __gauge_label_show = getConfig(['gauge', 'label', 'show'], true),
- __gauge_label_format = getConfig(['gauge', 'label', 'format']),
- __gauge_expand = getConfig(['gauge', 'expand'], true),
- __gauge_min = getConfig(['gauge', 'min'], 0),
- __gauge_max = getConfig(['gauge', 'max'], 100),
- __gauge_units = getConfig(['gauge', 'units']),
- __gauge_width = getConfig(['gauge', 'width']);
+ $$.__gauge_label_show = $$.getConfig(['gauge', 'label', 'show'], true);
+ $$.__gauge_label_format = $$.getConfig(['gauge', 'label', 'format']);
+ $$.__gauge_expand = $$.getConfig(['gauge', 'expand'], true);
+ $$.__gauge_min = $$.getConfig(['gauge', 'min'], 0);
+ $$.__gauge_max = $$.getConfig(['gauge', 'max'], 100);
+ $$.__gauge_units = $$.getConfig(['gauge', 'units']);
+ $$.__gauge_width = $$.getConfig(['gauge', 'width']);
// donut
- var __donut_label_show = getConfig(['donut', 'label', 'show'], true),
- __donut_label_format = getConfig(['donut', 'label', 'format']),
- __donut_label_threshold = getConfig(['donut', 'label', 'threshold'], 0.05),
- __donut_sort = getConfig(['donut', 'sort'], true),
- __donut_expand = getConfig(['donut', 'expand'], true),
- __donut_title = getConfig(['donut', 'title'], "");
+ $$.__donut_label_show = $$.getConfig(['donut', 'label', 'show'], true);
+ $$.__donut_label_format = $$.getConfig(['donut', 'label', 'format']);
+ $$.__donut_label_threshold = $$.getConfig(['donut', 'label', 'threshold'], 0.05);
+ $$.__donut_sort = $$.getConfig(['donut', 'sort'], true);
+ $$.__donut_expand = $$.getConfig(['donut', 'expand'], true);
+ $$.__donut_title = $$.getConfig(['donut', 'title'], "");
// region - region to change style
- var __regions = getConfig(['regions'], []);
+ $$.__regions = $$.getConfig(['regions'], []);
// tooltip - show when mouseover on each data
- var __tooltip_show = getConfig(['tooltip', 'show'], true),
- __tooltip_grouped = getConfig(['tooltip', 'grouped'], true),
- __tooltip_format_title = getConfig(['tooltip', 'format', 'title']),
- __tooltip_format_name = getConfig(['tooltip', 'format', 'name']),
- __tooltip_format_value = getConfig(['tooltip', 'format', 'value']),
- __tooltip_contents = getConfig(['tooltip', 'contents'], function (d, defaultTitleFormat, defaultValueFormat, color) {
- var titleFormat = __tooltip_format_title ? __tooltip_format_title : defaultTitleFormat,
- nameFormat = __tooltip_format_name ? __tooltip_format_name : function (name) { return name; },
- valueFormat = __tooltip_format_value ? __tooltip_format_value : defaultValueFormat,
+ $$.__tooltip_show = $$.getConfig(['tooltip', 'show'], true);
+ $$.__tooltip_grouped = $$.getConfig(['tooltip', 'grouped'], true);
+ $$.__tooltip_format_title = $$.getConfig(['tooltip', 'format', 'title']);
+ $$.__tooltip_format_name = $$.getConfig(['tooltip', 'format', 'name']);
+ $$.__tooltip_format_value = $$.getConfig(['tooltip', 'format', 'value']);
+ $$.__tooltip_contents = $$.getConfig(['tooltip', 'contents'], function (d, defaultTitleFormat, defaultValueFormat, color) {
+ var titleFormat = $$.__tooltip_format_title ? $$.__tooltip_format_title : defaultTitleFormat,
+ nameFormat = $$.__tooltip_format_name ? $$.__tooltip_format_name : function (name) { return name; },
+ valueFormat = $$.__tooltip_format_value ? $$.__tooltip_format_value : defaultValueFormat,
text, i, title, value, name, bgcolor;
for (i = 0; i < d.length; i++) {
if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; }
if (! text) {
title = titleFormat ? titleFormat(d[i].x) : d[i].x;
- text = "