diff --git a/c3.js b/c3.js
index 21876ab..9ecb5d9 100644
--- a/c3.js
+++ b/c3.js
@@ -8,38 +8,20 @@
var c3 = { version: "0.3.0" };
- // will be called to generate c3 chart object
- c3.generate = function (config) {
- return new c3_chart(config);
- };
-
- // c3.fn.$$ and c3.fn.chart will be defined as prototype interface
- c3.fn = {};
-
- /*-- HIDDEN VARS AND FUNCTIONS --*/
+ function Chart(config) {
- // Define solid chart for hiding its functions from chart object scope
- var chart = function () {};
-
- // Wrap solid chart object and call functions defined through c3.fn.$$ and c3.fn.chart
- var c3_chart = function (config) {
-
- var $$ = this.$$ = new chart(),
+ var $$ = this.internal = new Chart.Internal(),
d3 = $$.d3 = window.d3 ? window.d3 : 'undefined' !== typeof require ? require("d3") : undefined;
- $$.this = this;
- $$.config = config;
+ $$.chart = this;
$$.data = {};
$$.cache = {};
/*-- Handle Config --*/
- $$.updateConfig();
-
- // TODO: this should be an API
- this.config = config;
+ $$.readConfig(config);
- /*-- Set Variables --*/
+ /*-- Init Variables --*/
// TODO: some of these should be a function and defined in prototype
@@ -51,9 +33,9 @@
$$.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)); };
+ $$.isTimeSeries = ($$.config.axis_x_type === 'timeseries');
+ $$.isCategorized = ($$.config.axis_x_type.indexOf('categor') >= 0);
+ $$.isCustomX = function () { return !$$.isTimeSeries && ($$.config.data_x || $$.notEmpty($$.config.data_xs)); };
$$.dragStart = null;
$$.dragging = false;
@@ -62,11 +44,11 @@
$$.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;
+ $$.color = $$.generateColor($$.config.data_colors, $$.notEmpty($$.config.color_pattern) ? $$.config.color_pattern : $$.defaultColorPattern, $$.config.data_color);
+ $$.levelColor = $$.notEmpty($$.config.color_threshold) ? $$.generateLevelColor($$.config.color_pattern, $$.config.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;
+ $$.dataTimeFormat = $$.config.data_x_localtime ? d3.time.format : d3.time.format.utc;
+ $$.axisTimeFormat = $$.config.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(); }],
@@ -83,26 +65,26 @@
$$.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";
+ $$.xOrient = $$.config.axis_rotated ? "left" : "bottom";
+ $$.yOrient = $$.config.axis_rotated ? ($$.config.axis_y_inner ? "top" : "bottom") : ($$.config.axis_y_inner ? "right" : "left");
+ $$.y2Orient = $$.config.axis_rotated ? ($$.config.axis_y2_inner ? "bottom" : "top") : ($$.config.axis_y2_inner ? "left" : "right");
+ $$.subXOrient = $$.config.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) + ")"; },
+ x : function () { return "translate(0," + ($$.config.axis_rotated ? 0 : $$.height) + ")"; },
+ y : function () { return "translate(0," + ($$.config.axis_rotated ? $$.height : 0) + ")"; },
+ y2 : function () { return "translate(" + ($$.config.axis_rotated ? 0 : $$.width) + "," + ($$.config.axis_rotated ? 1 : 0) + ")"; },
+ subx : function () { return "translate(0," + ($$.config.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';
+ $$.isLegendRight = $$.config.legend_position === 'right';
+ $$.isLegendInset = $$.config.legend_position === 'inset';
+ $$.isLegendTop = $$.config.legend_inset_anchor === 'top-left' || $$.config.legend_inset_anchor === 'top-right';
+ $$.isLegendLeft = $$.config.legend_inset_anchor === 'top-left' || $$.config.legend_inset_anchor === 'bottom-left';
$$.legendStep = 0;
$$.legendItemWidth = 0;
$$.legendItemHeight = 0;
@@ -111,7 +93,7 @@
$$.currentMaxTickWidth = 0;
$$.rotated_padding_left = 30;
- $$.rotated_padding_right = $$.__axis_rotated && !$$.__axis_x_show ? 0 : 30;
+ $$.rotated_padding_right = $$.config.axis_rotated && !$$.config.axis_x_show ? 0 : 30;
$$.rotated_padding_top = 5;
$$.withoutFadeIn = {};
@@ -120,7 +102,7 @@
$$.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
+ if (!$$.config.pie_sort || !$$.config.donut_sort) { // TODO: this needs to be called by each type
$$.pie.sort(null);
}
@@ -131,7 +113,7 @@
return this;
};
$$.brush.scale = function (scale) {
- return $$.__axis_rotated ? this.y(scale) : this.x(scale);
+ return $$.config.axis_rotated ? this.y(scale) : this.x(scale);
};
// TODO: this should be pluggable
@@ -141,10 +123,10 @@
})
.on("zoom", $$.redrawForZoom);
$$.zoom.scale = function (scale) {
- return $$.__axis_rotated ? this.y(scale) : this.x(scale);
+ return $$.config.axis_rotated ? this.y(scale) : this.x(scale);
};
$$.zoom.orgScaleExtent = function () {
- var extent = $$.__zoom_extent ? $$.__zoom_extent : [1, 10];
+ var extent = $$.config.zoom_extent ? $$.config.zoom_extent : [1, 10];
return [extent[0], Math.max(this.getMaxDataCount() / extent[1], extent[1])];
};
$$.zoom.updateScaleExtent = function () {
@@ -170,11 +152,20 @@
else {
throw Error('url or json or rows or columns is required.');
}
+ }
+
+ Chart.Internal = function () {};
+
+ c3.generate = function (config) {
+ return new Chart(config);
};
- // Open interface for each prototype
- c3.fn.chart = c3_chart.prototype = {};
- c3.fn.$$ = chart.prototype = {};
+ c3.chart = {
+ fn: Chart.prototype,
+ internal: {
+ fn: Chart.Internal.prototype
+ }
+ };
if (typeof define === "function" && define.amd) {
define("c3", ["d3"], c3);
@@ -195,340 +186,254 @@
/**
* 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 () {});
+ c3.chart.internal.fn.config = {
+ bindto: '#chart',
+ size_width: undefined,
+ size_height: undefined,
+
+ padding_left: undefined,
+ padding_right: undefined,
+ padding_top: undefined,
+ padding_bottom: undefined,
+
+ zoom_enabled: false,
+ zoom_extent: undefined,
+ zoom_privileged: false,
+ zoom_onzoom: function () {},
+
+ interaction_enabled: true,
+
+ onmouseover: function () {},
+ onmouseout: function () {},
+ onresize: function () {},
+ onresized: function () {},
+
+ transition_duration: 350,
+
+ data_x: undefined,
+ data_xs: {},
+ data_x_format: '%Y-%m-%d',
+ data_x_localtime: true,
+ data_id_converter: function (id) { return id; },
+ data_names: {},
+ data_classes: {},
+ data_groups: [],
+ data_axes: {},
+ data_type: undefined,
+ data_types: {},
+ data_labels: {},
+ data_order: 'desc',
+ data_regions: {},
+ data_color: undefined,
+ data_colors: {},
+ data_hide: false,
+ data_filter: undefined,
+ data_selection_enabled: false,
+ data_selection_grouped: false,
+ data_selection_isselectable: function () { return true; },
+ data_selection_multiple: true,
+ data_onclick: function () {},
+ data_onmouseover: function () {},
+ data_onmouseout: function () {},
+ data_onselected: function () {},
+ data_onunselected: function () {},
+ data_ondragstart: function () {},
+ data_ondragend: function () {},
+ data_url: {},
+ data_json: {},
+ data_rows: {},
+ data_columns: {},
// configuration for no plot-able data supplied.
- $$.__data_empty_label_text = $$.getConfig(['data', 'empty', 'label', 'text'], "");
-
+ data_empty_label_text: "",
+
// subchart
- $$.__subchart_show = $$.getConfig(['subchart', 'show'], false);
- $$.__subchart_size_height = $$.getConfig(['subchart', 'size', 'height'], 60);
- $$.__subchart_onbrush = $$.getConfig(['subchart', 'onbrush'], function () {});
+ subchart_show: false,
+ subchart_size_height: 60,
+ subchart_onbrush: function () {},
// color
- $$.__color_pattern = $$.getConfig(['color', 'pattern'], []);
- $$.__color_threshold = $$.getConfig(['color', 'threshold'], {});
+ color_pattern: [],
+ color_threshold : {},
// legend
- $$.__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: true,
+ legend_position: 'bottom',
+ legend_inset_anchor: 'top-left',
+ legend_inset_x: 10,
+ legend_inset_y: 0,
+ legend_inset_step: undefined,
+ legend_item_onclick: undefined,
+ legend_item_onmouseover: undefined,
+ legend_item_onmouseout: undefined,
+ legend_equally: false,
// axis
- $$.__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: false,
+ axis_x_show: true,
+ axis_x_type: 'indexed',
+ axis_x_localtime: true,
+ axis_x_categories: [],
+ axis_x_tick_centered: false,
+ axis_x_tick_format: undefined,
+ axis_x_tick_culling: {},
+ axis_x_tick_culling_max: 10,
+ axis_x_tick_count: undefined,
+ axis_x_tick_fit: true,
+ axis_x_tick_values: null,
+ axis_x_tick_rotate: undefined,
+ axis_x_tick_outer: true,
+ axis_x_max: null,
+ axis_x_min: null,
+ axis_x_padding: {},
+ axis_x_height: undefined,
+ axis_x_default: undefined,
+ axis_x_label: {},
+ axis_y_show: true,
+ axis_y_max: undefined,
+ axis_y_min: undefined,
+ axis_y_center: undefined,
+ axis_y_label: {},
+ axis_y_inner: false,
+ axis_y_tick_format: undefined,
+ axis_y_tick_outer: true,
+ axis_y_padding: undefined,
+ axis_y_ticks: 10,
+ axis_y2_show: false,
+ axis_y2_max: undefined,
+ axis_y2_min: undefined,
+ axis_y2_center: undefined,
+ axis_y2_label: {},
+ axis_y2_inner: false,
+ axis_y2_tick_format: undefined,
+ axis_y2_tick_outer: true,
+ axis_y2_padding: undefined,
+ axis_y2_ticks: 10,
// grid
- $$.__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);
+ grid_x_show: false,
+ grid_x_type: 'tick',
+ grid_x_lines: [],
+ 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_y_type: {}, 'tick'),
+ grid_y_lines: [],
+ grid_y_ticks: 10,
+ grid_focus_show: true,
// point - point of each data
- $$.__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: true,
+ point_r: 2.5,
+ point_focus_expand_enabled: true,
+ point_focus_expand_r: undefined,
+ point_select_r: undefined,
- $$.__line_connect_null = $$.getConfig(['line', 'connect_null'], false);
+ line_connect_null: false,
// bar
- $$.__bar_width = $$.getConfig(['bar', 'width']);
- $$.__bar_width_ratio = $$.getConfig(['bar', 'width', 'ratio'], 0.6);
- $$.__bar_zerobased = $$.getConfig(['bar', 'zerobased'], true);
+ bar_width: undefined,
+ bar_width_ratio: 0.6,
+ bar_width_max: undefined,
+ bar_zerobased: true,
// area
- $$.__area_zerobased = $$.getConfig(['area', 'zerobased'], true);
+ area_zerobased: true,
// pie
- $$.__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: true,
+ pie_label_format: undefined,
+ pie_label_threshold: 0.05,
+ pie_sort: true,
+ pie_expand: true,
// gauge
- $$.__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: true,
+ gauge_label_format: undefined,
+ gauge_expand: true,
+ gauge_min: 0,
+ gauge_max: 100,
+ gauge_units: undefined,
+ gauge_width: undefined,
// donut
- $$.__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: true,
+ donut_label_format: undefined,
+ donut_label_threshold: 0.05,
+ donut_width: undefined,
+ donut_sort: true,
+ donut_expand: true,
+ donut_title: "",
// region - region to change style
- $$.__regions = $$.getConfig(['regions'], []);
+ regions: [],
// tooltip - show when mouseover on each data
- $$.__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: true,
+ tooltip_grouped: true,
+ tooltip_format_title: undefined,
+ tooltip_format_name: undefined,
+ tooltip_format_value: undefined,
+ tooltip_contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
+ var titleFormat = this.config.tooltip_format_title || defaultTitleFormat,
+ nameFormat = this.config.tooltip_format_name || function (name) { return name; },
+ valueFormat = this.config.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 = "