From a3a16800fbfa737f1dc003e05c510dfe1e6d8803 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Tue, 19 Aug 2014 17:40:05 +0900 Subject: [PATCH] Fix literal for config --- c3.js | 1431 +++++++++++++++++++----------------------- c3.min.js | 8 +- src/api.axis.js | 16 +- src/api.category.js | 10 +- src/api.chart.js | 4 +- src/api.data.js | 12 +- src/api.flow.js | 8 +- src/api.grid.js | 16 +- src/api.group.js | 6 +- src/api.load.js | 4 +- src/api.region.js | 18 +- src/api.selection.js | 12 +- src/api.zoom.js | 2 +- src/arc.js | 36 +- src/axis.js | 80 +-- src/category.js | 2 +- src/class.js | 2 +- src/clip.js | 18 +- src/color.js | 12 +- src/config.js | 499 +++++---------- src/core.js | 132 ++-- src/data.convert.js | 16 +- src/data.js | 28 +- src/domain.js | 58 +- src/drag.js | 20 +- src/format.js | 6 +- src/grid.js | 78 +-- src/interaction.js | 44 +- src/legend.js | 38 +- src/region.js | 18 +- src/scale.js | 20 +- src/selection.js | 22 +- src/shape.bar.js | 12 +- src/shape.js | 10 +- src/shape.line.js | 44 +- src/size.js | 38 +- src/subchart.js | 18 +- src/text.js | 6 +- src/tooltip.js | 30 +- src/type.js | 26 +- src/zoom.js | 10 +- 41 files changed, 1282 insertions(+), 1588 deletions(-) diff --git a/c3.js b/c3.js index 7b5a1a3..87c29d5 100644 --- a/c3.js +++ b/c3.js @@ -52,17 +52,17 @@ $$.initParams(); - if (config[__data_url]) { - $$.convertUrlToData(config[__data_url], config[__data_mimeType], config[__data_keys], $$.initWithData); + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_keys, $$.initWithData); } - else if (config[__data_json]) { - $$.initWithData($$.convertJsonToData(config[__data_json], config[__data_keys])); + else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); } - else if (config[__data_rows]) { - $$.initWithData($$.convertRowsToData(config[__data_rows])); + else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); } - else if (config[__data_columns]) { - $$.initWithData($$.convertColumnsToData(config[__data_columns])); + else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); } else { throw Error('url or json or rows or columns is required.'); @@ -89,8 +89,8 @@ $$.color = $$.generateColor(); $$.levelColor = $$.generateLevelColor(); - $$.dataTimeFormat = config[__data_xLocaltime] ? d3.time.format : d3.time.format.utc; - $$.axisTimeFormat = config[__axis_x_localtime] ? d3.time.format : d3.time.format.utc; + $$.dataTimeFormat = config.data_xLocaltime ? 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(); }], @@ -105,15 +105,15 @@ $$.hiddenTargetIds = []; $$.hiddenLegendIds = []; - $$.xOrient = config[__axis_rotated] ? "left" : "bottom"; - $$.yOrient = config[__axis_rotated] ? "bottom" : "left"; - $$.y2Orient = config[__axis_rotated] ? "top" : "right"; - $$.subXOrient = config[__axis_rotated] ? "left" : "bottom"; + $$.xOrient = config.axis_rotated ? "left" : "bottom"; + $$.yOrient = config.axis_rotated ? "bottom" : "left"; + $$.y2Orient = config.axis_rotated ? "top" : "right"; + $$.subXOrient = config.axis_rotated ? "left" : "bottom"; - $$.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'; + $$.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; @@ -122,7 +122,7 @@ $$.currentMaxTickWidth = 0; $$.rotated_padding_left = 30; - $$.rotated_padding_right = config[__axis_rotated] && !config[__axis_x_show] ? 0 : 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; $$.rotated_padding_top = 5; $$.withoutFadeIn = {}; @@ -138,7 +138,7 @@ if ($$.initBrush) { $$.initBrush(); } if ($$.initZoom) { $$.initZoom(); } - $$.selectChart = d3.select(config[__bindto]); + $$.selectChart = d3.select(config.bindto); if ($$.selectChart.empty()) { $$.selectChart = d3.select(document.createElement('div')).style('opacity', 0); $$.observeInserted($$.selectChart); @@ -150,18 +150,18 @@ $$.data.xs = {}; $$.data.targets = $$.convertDataToTargets(data); - if (config[__data_filter]) { - $$.data.targets = $$.data.targets.filter(config[__data_filter]); + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); } // Set targets to hide if needed - if (config[__data_hide]) { - $$.addHiddenTargetIds(config[__data_hide] === true ? $$.mapToIds($$.data.targets) : config[__data_hide]); + if (config.data_hide) { + $$.addHiddenTargetIds(config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide); } // when gauge, hide legend // TODO: fix if ($$.hasType('gauge')) { - config[__legend_show] = false; + config.legend_show = false; } // Init sizes and scales @@ -181,15 +181,15 @@ // Set initialized scales to brush and zoom if ($$.brush) { $$.brush.scale($$.subX); } - if (config[__zoom_enabled]) { $$.zoom.scale($$.x); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } /*-- Basic Elements --*/ // Define svgs $$.svg = $$.selectChart.append("svg") .style("overflow", "hidden") - .on('mouseenter', function () { return config[__onmouseover].call($$); }) - .on('mouseleave', function () { return config[__onmouseout].call($$); }); + .on('mouseenter', function () { return config.onmouseover.call($$); }) + .on('mouseleave', function () { return config.onmouseout.call($$); }); // Define defs $$.defs = $$.svg.append("defs"); @@ -242,7 +242,7 @@ // if zoom privileged, insert rect to forefront // TODO: is this needed? - main.insert('rect', config[__zoom_privileged] ? null : 'g.' + CLASS[_regions]) + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS[_regions]) .attr('class', CLASS[_zoomRect]) .attr('width', $$.width) .attr('height', $$.height) @@ -250,8 +250,8 @@ .on("dblclick.zoom", null); // Set default extent if defined - if (config[__axis_x_default]) { - $$.brush.extent(isFunction(config[__axis_x_default]) ? config[__axis_x_default]($$.getXDomain()) : config[__axis_x_default]); + if (config.axis_x_default) { + $$.brush.extent(isFunction(config.axis_x_default) ? config.axis_x_default($$.getXDomain()) : config.axis_x_default); } // Add Axis @@ -277,13 +277,13 @@ } if (window.onresize.add) { window.onresize.add(function () { - config[__onresize].call($$); + config.onresize.call($$); }); window.onresize.add(function () { $$.api.flush(); }); window.onresize.add(function () { - config[__onresized].call($$); + config.onresized.call($$); }); } @@ -317,14 +317,14 @@ legendWidth = $$.legend ? $$.getLegendWidth() : 0, legendHeightForBottom = $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, hasArc = $$.hasArcType(), - xAxisHeight = config[__axis_rotated] || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), - subchartHeight = config[__subchart_show] && !hasArc ? (config[__subchart_size_height] + xAxisHeight) : 0; + xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), + subchartHeight = config.subchart_show && !hasArc ? (config.subchart_size_height + xAxisHeight) : 0; $$.currentWidth = $$.getCurrentWidth(); $$.currentHeight = $$.getCurrentHeight(); // for main - $$.margin = config[__axis_rotated] ? { + $$.margin = config.axis_rotated ? { top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), right: hasArc ? 0 : $$.getCurrentPaddingRight(), bottom: $$.getHorizontalAxisHeight('y') + legendHeightForBottom + $$.getCurrentPaddingBottom(), @@ -337,7 +337,7 @@ }; // for subchart - $$.margin2 = config[__axis_rotated] ? { + $$.margin2 = config.axis_rotated ? { top: $$.margin.top, right: NaN, bottom: 20 + legendHeightForBottom, @@ -363,8 +363,8 @@ if ($$.width < 0) { $$.width = 0; } if ($$.height < 0) { $$.height = 0; } - $$.width2 = config[__axis_rotated] ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; - $$.height2 = config[__axis_rotated] ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + $$.width2 = config.axis_rotated ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; + $$.height2 = config.axis_rotated ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; if ($$.width2 < 0) { $$.width2 = 0; } if ($$.height2 < 0) { $$.height2 = 0; } @@ -400,7 +400,7 @@ // Fade-in each chart $$.svg.selectAll('.' + CLASS[_target]).filter(function (d) { return $$.isTargetToShow(d.id); }) - .transition().duration(config[__transition_duration]) + .transition().duration(config.transition_duration) .style("opacity", 1); }; @@ -414,8 +414,8 @@ var waitForDraw, flow; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling; var xv = $$.xv.bind($$), - cx = ($$.config[__axis_rotated] ? $$.circleY : $$.circleX).bind($$), - cy = ($$.config[__axis_rotated] ? $$.circleX : $$.circleY).bind($$); + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); options = options || {}; withY = getOption(options, "withY", true); @@ -428,14 +428,14 @@ withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); - duration = withTransition ? config[__transition_duration] : 0; + duration = withTransition ? config.transition_duration : 0; durationForExit = withTransitionForExit ? duration : 0; durationForAxis = withTransitionForAxis ? duration : 0; transitions = transitions || $$.generateAxisTransitions(durationForAxis); // update legend and transform each g - if (withLegend && config[__legend_show]) { + if (withLegend && config.legend_show) { $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); } @@ -447,8 +447,8 @@ if (targetsToShow.length) { $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain); // update axis tick values according to options - if (!config[__axis_x_tick_values] && (config[__axis_x_tick_fit] || config[__axis_x_tick_count])) { - tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config[__axis_x_tick_count]); + if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) { + tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count); $$.xAxis.tickValues(tickValues); $$.subXAxis.tickValues(tickValues); } @@ -468,9 +468,9 @@ // show/hide if manual culling needed if (withUpdateXDomain && targetsToShow.length) { - if (config[__axis_x_tick_culling] && tickValues) { + if (config.axis_x_tick_culling && tickValues) { for (i = 1; i < tickValues.length; i++) { - if (tickValues.length / i < config[__axis_x_tick_culling_max]) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { intervalForCulling = i; break; } @@ -487,8 +487,8 @@ } // rotate tick text if needed - if (!config[__axis_rotated] && config[__axis_x_tick_rotate]) { - $$.rotateTickText($$.axes.x, transitions.axisX, config[__axis_x_tick_rotate]); + if (!config.axis_rotated && config.axis_x_tick_rotate) { + $$.rotateTickText($$.axes.x, transitions.axisX, config.axis_x_tick_rotate); } // setup drawer - MEMO: these must be called after axis updated @@ -512,7 +512,7 @@ main.select("text." + CLASS[_text] + '.' + CLASS[_empty]) .attr("x", $$.width / 2) .attr("y", $$.height / 2) - .text(config[__data_empty_label_text]) + .text(config.data_empty_label_text) .transition() .style('opacity', targetsToShow.length ? 0 : 1); @@ -528,7 +528,7 @@ // lines, areas and cricles $$.redrawLine(durationForExit); $$.redrawArea(durationForExit); - if (config[__point_show]) { $$.redrawCircle(); } + if (config.point_show) { $$.redrawCircle(); } // text if ($$.hasDataLabel()) { @@ -550,7 +550,7 @@ .remove(); // event rect - if (config[__interaction_enabled]) { + if (config.interaction_enabled) { $$.redrawEventRect(); } @@ -612,8 +612,8 @@ // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) $$.updateSizes(); // MEMO: called in updateLegend in redraw if withLegend - if (!(options.withLegend && config[__legend_show])) { - transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config[__transition_duration] : 0); + if (!(options.withLegend && config.legend_show)) { + transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config.transition_duration : 0); // Update scales $$.updateScales(); $$.updateSvgSize(); @@ -625,14 +625,14 @@ }; c3_chart_internal_fn.isTimeSeries = function () { - return this.config[__axis_x_type] === 'timeseries'; + return this.config.axis_x_type === 'timeseries'; }; c3_chart_internal_fn.isCategorized = function () { - return this.config[__axis_x_type].indexOf('categor') >= 0; + return this.config.axis_x_type.indexOf('categor') >= 0; }; c3_chart_internal_fn.isCustomX = function () { var $$ = this, config = $$.config; - return !$$.isTimeSeries() && (config[__data_x] || notEmpty(config[__data_xs])); + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); }; c3_chart_internal_fn.getTranslate = function (target) { @@ -648,16 +648,16 @@ y = $$.margin3.top; } else if (target === 'x') { x = 0; - y = config[__axis_rotated] ? 0 : $$.height; + y = config.axis_rotated ? 0 : $$.height; } else if (target === 'y') { x = 0; - y = config[__axis_rotated] ? $$.height : 0; + y = config.axis_rotated ? $$.height : 0; } else if (target === 'y2') { - x = config[__axis_rotated] ? 0 : $$.width; - y = config[__axis_rotated] ? 1 : 0; + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; } else if (target === 'subx') { x = 0; - y = config[__axis_rotated] ? 0 : $$.height2; + y = config.axis_rotated ? 0 : $$.height2; } else if (target === 'arc') { x = $$.arcWidth / 2; y = $$.arcHeight / 2; @@ -720,7 +720,7 @@ c3_chart_internal_fn.transformAll = function (withTransition, transitions) { var $$ = this; $$.transformMain(withTransition, transitions); - if ($$.config[__subchart_show]) { $$.transformContext(withTransition, transitions); } + if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } if ($$.legend) { $$.transformLegend(withTransition); } }; @@ -750,7 +750,7 @@ c3_chart_internal_fn.updateDimension = function () { var $$ = this; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { $$.axes.x.call($$.xAxis); $$.axes.subx.call($$.subXAxis); } else { @@ -848,7 +848,7 @@ } else if (typeof date === 'number') { parsedDate = new Date(date); } else { - parsedDate = $$.dataTimeFormat($$.config[__data_xFormat]).parse(date); + parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date); } if (!parsedDate || isNaN(+parsedDate)) { window.console.error("Failed to parse x '" + date + "' to Date object"); @@ -856,333 +856,180 @@ return parsedDate; }; - var __bindto = 'bindto', - __size_width = 'size_width', - __size_height = 'size_height', - __padding_left = 'padding_left', - __padding_right = 'padding_right', - __padding_top = 'padding_top', - __padding_bottom = 'padding_bottom', - __zoom_enabled = 'zoom_enabled', - __zoom_extent = 'zoom_extent', - __zoom_privileged = 'zoom_privileged', - __zoom_onzoom = 'zoom_onzoom', - __interaction_enabled = 'interaction_enabled', - __onmouseover = 'onmouseover', - __onmouseout = 'onmouseout', - __onresize = 'onresize', - __onresized = 'onresized', - __transition_duration = 'transition_duration', - __data_x = 'data_x', - __data_xs = 'data_xs', - __data_xFormat = 'data_xFormat', - __data_xLocaltime = 'data_xLocaltime', - __data_idConverter = 'data_idConverter', - __data_names = 'data_names', - __data_classes = 'data_classes', - __data_groups = 'data_groups', - __data_axes = 'data_axes', - __data_type = 'data_type', - __data_types = 'data_types', - __data_labels = 'data_labels', - __data_order = 'data_order', - __data_regions = 'data_regions', - __data_color = 'data_color', - __data_colors = 'data_colors', - __data_hide = 'data_hide', - __data_filter = 'data_filter', - __data_selection_enabled = 'data_selection_enabled', - __data_selection_grouped = 'data_selection_grouped', - __data_selection_isselectable = 'data_selection_isselectable', - __data_selection_multiple = 'data_selection_multiple', - __data_onclick = 'data_onclick', - __data_onmouseover = 'data_onmouseover', - __data_onmouseout = 'data_onmouseout', - __data_onselected = 'data_onselected', - __data_onunselected = 'data_onunselected', - __data_ondragstart = 'data_ondragstart', - __data_ondragend = 'data_ondragend', - __data_url = 'data_url', - __data_json = 'data_json', - __data_rows = 'data_rows', - __data_columns = 'data_columns', - __data_mimeType = 'data_mimeType', - __data_keys = 'data_keys', - __data_empty_label_text = 'data_empty_label_text', - __subchart_show = 'subchart_show', - __subchart_size_height = 'subchart_size_height', - __subchart_onbrush = 'subchart_onbrush', - __color_pattern = 'color_pattern', - __color_threshold = 'color_threshold', - __legend_show = 'legend_show', - __legend_position = 'legend_position', - __legend_inset_anchor = 'legend_inset_anchor', - __legend_inset_x = 'legend_inset_x', - __legend_inset_y = 'legend_inset_y', - __legend_inset_step = 'legend_inset_step', - __legend_item_onclick = 'legend_item_onclick', - __legend_item_onmouseover = 'legend_item_onmouseover', - __legend_item_onmouseout = 'legend_item_onmouseout', - __legend_equally = 'legend_equally', - __axis_rotated = 'axis_rotated', - __axis_x_show = 'axis_x_show', - __axis_x_type = 'axis_x_type', - __axis_x_localtime = 'axis_x_localtime', - __axis_x_categories = 'axis_x_categories', - __axis_x_tick_centered = 'axis_x_tick_centered', - __axis_x_tick_format = 'axis_x_tick_format', - __axis_x_tick_culling = 'axis_x_tick_culling', - __axis_x_tick_culling_max = 'axis_x_tick_culling_max', - __axis_x_tick_count = 'axis_x_tick_count', - __axis_x_tick_fit = 'axis_x_tick_fit', - __axis_x_tick_values = 'axis_x_tick_values', - __axis_x_tick_rotate = 'axis_x_tick_rotate', - __axis_x_tick_outer = 'axis_x_tick_outer', - __axis_x_max = 'axis_x_max', - __axis_x_min = 'axis_x_min', - __axis_x_padding = 'axis_x_padding', - __axis_x_height = 'axis_x_height', - __axis_x_default = 'axis_x_default', - __axis_x_label = 'axis_x_label', - __axis_y_show = 'axis_y_show', - __axis_y_max = 'axis_y_max', - __axis_y_min = 'axis_y_min', - __axis_y_center = 'axis_y_center', - __axis_y_label = 'axis_y_label', - __axis_y_tick_format = 'axis_y_tick_format', - __axis_y_tick_outer = 'axis_y_tick_outer', - __axis_y_padding = 'axis_y_padding', - __axis_y_ticks = 'axis_y_ticks', - __axis_y2_show = 'axis_y2_show', - __axis_y2_max = 'axis_y2_max', - __axis_y2_min = 'axis_y2_min', - __axis_y2_center = 'axis_y2_center', - __axis_y2_label = 'axis_y2_label', - __axis_y2_tick_format = 'axis_y2_tick_format', - __axis_y2_tick_outer = 'axis_y2_tick_outer', - __axis_y2_padding = 'axis_y2_padding', - __axis_y2_ticks = 'axis_y2_ticks', - __grid_x_show = 'grid_x_show', - __grid_x_type = 'grid_x_type', - __grid_x_lines = 'grid_x_lines', - __grid_y_show = 'grid_y_show', - __grid_y_lines = 'grid_y_lines', - __grid_y_ticks = 'grid_y_ticks', - __grid_focus_show = 'grid_focus_show', - __point_show = 'point_show', - __point_r = 'point_r', - __point_focus_expand_enabled = 'point_focus_expand_enabled', - __point_focus_expand_r = 'point_focus_expand_r', - __point_select_r = 'point_select_r', - __line_connect_null = 'line_connect_null', - __bar_width = 'bar_width', - __bar_width_ratio = 'bar_width_ratio', - __bar_width_max = 'bar_width_max', - __bar_zerobased = 'bar_zerobased', - __area_zerobased = 'area_zerobased', - __pie_label_show = 'pie_label_show', - __pie_label_format = 'pie_label_format', - __pie_label_threshold = 'pie_label_threshold', - __pie_sort = 'pie_sort', - __pie_expand = 'pie_expand', - __gauge_label_show = 'gauge_label_show', - __gauge_label_format = 'gauge_label_format', - __gauge_expand = 'gauge_expand', - __gauge_min = 'gauge_min', - __gauge_max = 'gauge_max', - __gauge_units = 'gauge_units', - __gauge_width = 'gauge_width', - __donut_label_show = 'donut_label_show', - __donut_label_format = 'donut_label_format', - __donut_label_threshold = 'donut_label_threshold', - __donut_width = 'donut_width', - __donut_sort = 'donut_sort', - __donut_expand = 'donut_expand', - __donut_title = 'donut_title', - __regions = 'regions', - __tooltip_show = 'tooltip_show', - __tooltip_grouped = 'tooltip_grouped', - __tooltip_format_title = 'tooltip_format_title', - __tooltip_format_name = 'tooltip_format_name', - __tooltip_format_value = 'tooltip_format_value', - __tooltip_contents = 'tooltip_contents', - __tooltip_init_show = 'tooltip_init_show', - __tooltip_init_x = 'tooltip_init_x', - __tooltip_init_position = 'tooltip_init_position'; - c3_chart_internal_fn.getDefaultConfig = function () { - var config = {}; - config[__bindto] = '#chart'; - config[__size_width] = undefined; - config[__size_height] = undefined; - config[__padding_left] = undefined; - config[__padding_right] = undefined; - config[__padding_top] = undefined; - config[__padding_bottom] = undefined; - config[__zoom_enabled] = false; - config[__zoom_extent] = undefined; - config[__zoom_privileged] = false; - config[__zoom_onzoom] = function () {}; - config[__interaction_enabled] = true; - config[__onmouseover] = function () {}; - config[__onmouseout] = function () {}; - config[__onresize] = function () {}; - config[__onresized] = function () {}; - config[__transition_duration] = 350; - config[__data_x] = undefined; - config[__data_xs] = {}; - config[__data_xFormat] = '%Y-%m-%d'; - config[__data_xLocaltime] = true; - config[__data_idConverter] = function (id) { return id; }; - config[__data_names] = {}; - config[__data_classes] = {}; - config[__data_groups] = []; - config[__data_axes] = {}; - config[__data_type] = undefined; - config[__data_types] = {}; - config[__data_labels] = {}; - config[__data_order] = 'desc'; - config[__data_regions] = {}; - config[__data_color] = undefined; - config[__data_colors] = {}; - config[__data_hide] = false; - config[__data_filter] = undefined; - config[__data_selection_enabled] = false; - config[__data_selection_grouped] = false; - config[__data_selection_isselectable] = function () { return true; }; - config[__data_selection_multiple] = true; - config[__data_onclick] = function () {}; - config[__data_onmouseover] = function () {}; - config[__data_onmouseout] = function () {}; - config[__data_onselected] = function () {}; - config[__data_onunselected] = function () {}; - config[__data_ondragstart] = function () {}; - config[__data_ondragend] = function () {}; - config[__data_url] = undefined; - config[__data_json] = undefined; - config[__data_rows] = undefined; - config[__data_columns] = undefined; - config[__data_mimeType] = undefined; - config[__data_keys] = undefined; - // configuration for no plot-able data supplied. - config[__data_empty_label_text] = ""; - // subchart - config[__subchart_show] = false; - config[__subchart_size_height] = 60; - config[__subchart_onbrush] = function () {}; - // color - config[__color_pattern] = []; - config[__color_threshold] = {}; - // legend - config[__legend_show] = true; - config[__legend_position] = 'bottom'; - config[__legend_inset_anchor] = 'top-left'; - config[__legend_inset_x] = 10; - config[__legend_inset_y] = 0; - config[__legend_inset_step] = undefined; - config[__legend_item_onclick] = undefined; - config[__legend_item_onmouseover] = undefined; - config[__legend_item_onmouseout] = undefined; - config[__legend_equally] = false; - // axis - config[__axis_rotated] = false; - config[__axis_x_show] = true; - config[__axis_x_type] = 'indexed'; - config[__axis_x_localtime] = true; - config[__axis_x_categories] = []; - config[__axis_x_tick_centered] = false; - config[__axis_x_tick_format] = undefined; - config[__axis_x_tick_culling] = {}; - config[__axis_x_tick_culling_max] = 10; - config[__axis_x_tick_count] = undefined; - config[__axis_x_tick_fit] = true; - config[__axis_x_tick_values] = null; - config[__axis_x_tick_rotate] = undefined; - config[__axis_x_tick_outer] = true; - config[__axis_x_max] = null; - config[__axis_x_min] = null; - config[__axis_x_padding] = {}; - config[__axis_x_height] = undefined; - config[__axis_x_default] = undefined; - config[__axis_x_label] = {}; - config[__axis_y_show] = true; - config[__axis_y_max] = undefined; - config[__axis_y_min] = undefined; - config[__axis_y_center] = undefined; - config[__axis_y_label] = {}; - config[__axis_y_tick_format] = undefined; - config[__axis_y_tick_outer] = true; - config[__axis_y_padding] = undefined; - config[__axis_y_ticks] = 10; - config[__axis_y2_show] = false; - config[__axis_y2_max] = undefined; - config[__axis_y2_min] = undefined; - config[__axis_y2_center] = undefined; - config[__axis_y2_label] = {}; - config[__axis_y2_tick_format] = undefined; - config[__axis_y2_tick_outer] = true; - config[__axis_y2_padding] = undefined; - config[__axis_y2_ticks] = 10; - // grid - config[__grid_x_show] = false; - config[__grid_x_type] = 'tick'; - config[__grid_x_lines] = []; - config[__grid_y_show] = false; - // not used - // grid_y_type: {}, 'tick'), - config[__grid_y_lines] = []; - config[__grid_y_ticks] = 10; - config[__grid_focus_show] = true; - // point - point of each data - config[__point_show] = true; - config[__point_r] = 2.5; - config[__point_focus_expand_enabled] = true; - config[__point_focus_expand_r] = undefined; - config[__point_select_r] = undefined; - config[__line_connect_null] = false; - // bar - config[__bar_width] = undefined; - config[__bar_width_ratio] = 0.6; - config[__bar_width_max] = undefined; - config[__bar_zerobased] = true; - // area - config[__area_zerobased] = true; - // pie - config[__pie_label_show] = true; - config[__pie_label_format] = undefined; - config[__pie_label_threshold] = 0.05; - config[__pie_sort] = true; - config[__pie_expand] = true; - // gauge - config[__gauge_label_show] = true; - config[__gauge_label_format] = undefined; - config[__gauge_expand] = true; - config[__gauge_min] = 0; - config[__gauge_max] = 100; - config[__gauge_units] = undefined; - config[__gauge_width] = undefined; - // donut - config[__donut_label_show] = true; - config[__donut_label_format] = undefined; - config[__donut_label_threshold] = 0.05; - config[__donut_width] = undefined; - config[__donut_sort] = true; - config[__donut_expand] = true; - config[__donut_title] = ""; - // region - region to change style - config[__regions] = []; - // tooltip - show when mouseover on each data - config[__tooltip_show] = true; - config[__tooltip_grouped] = true; - config[__tooltip_format_title] = undefined; - config[__tooltip_format_name] = undefined; - config[__tooltip_format_value] = undefined; - config[__tooltip_contents] = function (d, defaultTitleFormat, defaultValueFormat, color) { - return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : ''; - }, - config[__tooltip_init_show] = false; - config[__tooltip_init_x] = 0; - config[__tooltip_init_position] = {top: '0px', left: '50px'}; + var 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_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_idConverter: 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: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: "", + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_onbrush: function () {}, + // color + color_pattern: [], + color_threshold: {}, + // legend + 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: 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_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_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_padding: undefined, + axis_y2_ticks: 10, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + line_connect_null: false, + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + // area + area_zerobased: true, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_sort: true, + pie_expand: true, + // gauge + 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: 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: [], + // tooltip - show when mouseover on each data + 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) { + return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : ''; + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: {top: '0px', left: '50px'} + }; Object.keys(this.additionalConfig).forEach(function (key) { config[key] = this.additionalConfig[key]; @@ -1274,14 +1121,14 @@ var $$ = this, config = $$.config, forInit = !$$.x; // update edges - $$.xMin = config[__axis_rotated] ? 1 : 0; - $$.xMax = config[__axis_rotated] ? $$.height : $$.width; - $$.yMin = config[__axis_rotated] ? 0 : $$.height; - $$.yMax = config[__axis_rotated] ? $$.width : 1; + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; $$.subXMin = $$.xMin; $$.subXMax = $$.xMax; - $$.subYMin = config[__axis_rotated] ? 0 : $$.height2; - $$.subYMax = config[__axis_rotated] ? $$.width2 : 1; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; // update scales $$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { return $$.xAxis.tickOffset(); }); $$.y = $$.getY($$.yMin, $$.yMax, forInit ? undefined : $$.y.domain()); @@ -1291,15 +1138,15 @@ $$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? undefined : $$.subY2.domain()); // update axes $$.xAxisTickFormat = $$.getXAxisTickFormat(); - $$.xAxisTickValues = config[__axis_x_tick_values] ? config[__axis_x_tick_values] : (forInit ? undefined : $$.xAxis.tickValues()); + $$.xAxisTickValues = config.axis_x_tick_values ? config.axis_x_tick_values : (forInit ? undefined : $$.xAxis.tickValues()); $$.xAxis = $$.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); $$.subXAxis = $$.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues); - $$.yAxis = $$.getYAxis($$.y, $$.yOrient, config[__axis_y_tick_format], config[__axis_y_ticks]); - $$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config[__axis_y2_tick_format], config[__axis_y2_ticks]); + $$.yAxis = $$.getYAxis($$.y, $$.yOrient, config.axis_y_tick_format, config.axis_y_ticks); + $$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, config.axis_y2_ticks); // Set initialized scales to brush and zoom if (!forInit) { if ($$.brush) { $$.brush.scale($$.subX); } - if (config[__zoom_enabled]) { $$.zoom.scale($$.x); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } } // update for arc if ($$.updateArc) { $$.updateArc(); } @@ -1309,11 +1156,11 @@ var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasNegativeValue; - if (config[__data_groups].length > 0) { + if (config.data_groups.length > 0) { hasNegativeValue = $$.hasNegativeValueInTargets(targets); - for (j = 0; j < config[__data_groups].length; j++) { + for (j = 0; j < config.data_groups.length; j++) { // Determine baseId - idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; }); + idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider negative values @@ -1340,11 +1187,11 @@ var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasPositiveValue; - if (config[__data_groups].length > 0) { + if (config.data_groups.length > 0) { hasPositiveValue = $$.hasPositiveValueInTargets(targets); - for (j = 0; j < config[__data_groups].length; j++) { + for (j = 0; j < config.data_groups.length; j++) { // Determine baseId - idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; }); + idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider positive values @@ -1370,16 +1217,16 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) { var $$ = this, config = $$.config, yTargets = targets.filter(function (d) { return $$.getAxisId(d.id) === axisId; }), - yMin = axisId === 'y2' ? config[__axis_y2_min] : config[__axis_y_min], - yMax = axisId === 'y2' ? config[__axis_y2_max] : config[__axis_y_max], + yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, + yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, yDomainMin = isValue(yMin) ? yMin : $$.getYDomainMin(yTargets), yDomainMax = isValue(yMax) ? yMax : $$.getYDomainMax(yTargets), domainLength, padding, padding_top, padding_bottom, - center = axisId === 'y2' ? config[__axis_y2_center] : config[__axis_y_center], + center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, - isZeroBased = ($$.hasType('bar', yTargets) && config[__bar_zerobased]) || ($$.hasType('area', yTargets) && config[__area_zerobased]), - showHorizontalDataLabel = $$.hasDataLabel() && config[__axis_rotated], - showVerticalDataLabel = $$.hasDataLabel() && !config[__axis_rotated]; + isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || ($$.hasType('area', yTargets) && config.area_zerobased), + showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, + showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; if (yTargets.length === 0) { // use current domain if target of axisId is none return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); } @@ -1415,13 +1262,13 @@ padding_top += lengths[1]; padding_bottom += lengths[0]; } - if (axisId === 'y' && config[__axis_y_padding]) { - padding_top = $$.getAxisPadding(config[__axis_y_padding], 'top', padding, domainLength); - padding_bottom = $$.getAxisPadding(config[__axis_y_padding], 'bottom', padding, domainLength); + if (axisId === 'y' && config.axis_y_padding) { + padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength); + padding_bottom = $$.getAxisPadding(config.axis_y_padding, 'bottom', padding, domainLength); } - if (axisId === 'y2' && config[__axis_y2_padding]) { - padding_top = $$.getAxisPadding(config[__axis_y2_padding], 'top', padding, domainLength); - padding_bottom = $$.getAxisPadding(config[__axis_y2_padding], 'bottom', padding, domainLength); + if (axisId === 'y2' && config.axis_y2_padding) { + padding_top = $$.getAxisPadding(config.axis_y2_padding, 'top', padding, domainLength); + padding_bottom = $$.getAxisPadding(config.axis_y2_padding, 'bottom', padding, domainLength); } // Bar/Area chart should be 0-based if all positive|negative if (isZeroBased) { @@ -1432,14 +1279,14 @@ }; c3_chart_internal_fn.getXDomainMin = function (targets) { var $$ = this, config = $$.config; - return config[__axis_x_min] ? - ($$.isTimeSeries() ? this.parseDate(config[__axis_x_min]) : config[__axis_x_min]) : + return config.axis_x_min ? + ($$.isTimeSeries() ? this.parseDate(config.axis_x_min) : config.axis_x_min) : $$.d3.min(targets, function (t) { return $$.d3.min(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainMax = function (targets) { var $$ = this, config = $$.config; - return config[__axis_x_max] ? - ($$.isTimeSeries() ? this.parseDate(config[__axis_x_max]) : config[__axis_x_max]) : + return config.axis_x_max ? + ($$.isTimeSeries() ? this.parseDate(config.axis_x_max) : config.axis_x_max) : $$.d3.max(targets, function (t) { return $$.d3.max(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainPadding = function (targets) { @@ -1454,11 +1301,11 @@ } else { padding = diff * 0.01; } - if (typeof config[__axis_x_padding] === 'object' && notEmpty(config[__axis_x_padding])) { - paddingLeft = isValue(config[__axis_x_padding].left) ? config[__axis_x_padding].left : padding; - paddingRight = isValue(config[__axis_x_padding].right) ? config[__axis_x_padding].right : padding; - } else if (typeof config[__axis_x_padding] === 'number') { - paddingLeft = paddingRight = config[__axis_x_padding]; + if (typeof config.axis_x_padding === 'object' && notEmpty(config.axis_x_padding)) { + paddingLeft = isValue(config.axis_x_padding.left) ? config.axis_x_padding.left : padding; + paddingRight = isValue(config.axis_x_padding.right) ? config.axis_x_padding.right : padding; + } else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; } else { paddingLeft = paddingRight = padding; } @@ -1488,27 +1335,27 @@ if (withUpdateOrgXDomain) { $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); $$.orgXDomain = $$.x.domain(); - if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); } + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } $$.subX.domain($$.x.domain()); if ($$.brush) { $$.brush.scale($$.subX); } } if (withUpdateXDomain) { $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); - if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); } + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } } return $$.x.domain(); }; c3_chart_internal_fn.isX = function (key) { var $$ = this, config = $$.config; - return (config[__data_x] && key === config[__data_x]) || (notEmpty(config[__data_xs]) && hasValue(config[__data_xs], key)); + return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key)); }; c3_chart_internal_fn.isNotX = function (key) { return !this.isX(key); }; c3_chart_internal_fn.getXKey = function (id) { var $$ = this, config = $$.config; - return config[__data_x] ? config[__data_x] : notEmpty(config[__data_xs]) ? config[__data_xs][id] : null; + return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null; }; c3_chart_internal_fn.getXValuesOfXKey = function (key, targets) { var $$ = this, @@ -1536,7 +1383,7 @@ c3_chart_internal_fn.addXs = function (xs) { var $$ = this; Object.keys(xs).forEach(function (id) { - $$.config[__data_xs][id] = xs[id]; + $$.config.data_xs[id] = xs[id]; }); }; c3_chart_internal_fn.hasMultipleX = function (xs) { @@ -1544,12 +1391,12 @@ }; c3_chart_internal_fn.isMultipleX = function () { var $$ = this, config = $$.config; - return notEmpty(config[__data_xs]) && $$.hasMultipleX(config[__data_xs]); + return notEmpty(config.data_xs) && $$.hasMultipleX(config.data_xs); }; c3_chart_internal_fn.addName = function (data) { var $$ = this, name; if (data) { - name = $$.config[__data_names][data.id]; + name = $$.config.data_names[data.id]; data.name = name ? name : data.id; } return data; @@ -1704,11 +1551,11 @@ }; c3_chart_internal_fn.isOrderDesc = function () { var config = this.config; - return config[__data_order] && config[__data_order].toLowerCase() === 'desc'; + return config.data_order && config.data_order.toLowerCase() === 'desc'; }; c3_chart_internal_fn.isOrderAsc = function () { var config = this.config; - return config[__data_order] && config[__data_order].toLowerCase() === 'asc'; + return config.data_order && config.data_order.toLowerCase() === 'asc'; }; c3_chart_internal_fn.orderTargets = function (targets) { var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); @@ -1719,8 +1566,8 @@ t2Sum = t2.values.reduce(reducer, 0); return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum; }); - } else if (isFunction(config[__data_order])) { - targets.sort(config[__data_order]); + } else if (isFunction(config.data_order)) { + targets.sort(config.data_order); } // TODO: accept name array for order return targets; }; @@ -1732,9 +1579,9 @@ }; c3_chart_internal_fn.hasDataLabel = function () { var config = this.config; - if (typeof config[__data_labels] === 'boolean' && config[__data_labels]) { + if (typeof config.data_labels === 'boolean' && config.data_labels) { return true; - } else if (typeof config[__data_labels] === 'object' && notEmpty(config[__data_labels])) { + } else if (typeof config.data_labels === 'object' && notEmpty(config.data_labels)) { return true; } return false; @@ -1777,7 +1624,7 @@ max = _max ? _max : values.length - 1, med = Math.floor((max - min) / 2) + min, value = values[med], - diff = $$.x(value.x) - pos[$$.config[__axis_rotated] ? 1 : 0], + diff = $$.x(value.x) - pos[$$.config.axis_rotated ? 1 : 0], candidates; // Update range for search @@ -1826,8 +1673,8 @@ c3_chart_internal_fn.dist = function (data, pos) { var $$ = this, config = $$.config, yScale = $$.getAxisId(data.id) === 'y' ? $$.y : $$.y2, - xIndex = config[__axis_rotated] ? 1 : 0, - yIndex = config[__axis_rotated] ? 0 : 1; + xIndex = config.axis_rotated ? 1 : 0, + yIndex = config.axis_rotated ? 0 : 1; return Math.pow($$.x(data.x) - pos[xIndex], 2) + Math.pow(yScale(data.value) - pos[yIndex], 2); }; @@ -1862,7 +1709,7 @@ targetKeys = keys.value; if (keys.x) { targetKeys.push(keys.x); - $$.config[__data_x] = keys.x; + $$.config.data_x = keys.x; } new_rows.push(targetKeys); json.forEach(function (o) { @@ -1933,11 +1780,11 @@ ); } // if not included in input data, find from preloaded data of other id's x - else if (config[__data_x]) { + else if (config.data_x) { $$.data.xs[id] = $$.getOtherTargetXs(); } // if not included in input data, find from preloaded data - else if (notEmpty(config[__data_xs])) { + else if (notEmpty(config.data_xs)) { $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); } // MEMO: if no x included, use same x of current will be used @@ -1956,7 +1803,7 @@ // convert to target targets = ids.map(function (id, index) { - var convertedId = config[__data_idConverter](id); + var convertedId = config.data_idConverter(id); return { id: convertedId, id_org: id, @@ -1964,8 +1811,8 @@ var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i); // use x as categories if custom x and categorized if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { - if (i === 0) { config[__axis_x_categories] = []; } - config[__axis_x_categories].push(rawX); + if (i === 0) { config.axis_x_categories = []; } + config.axis_x_categories.push(rawX); } // mark as x = undefined if value is undefined and filter to remove after mapped if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { @@ -1997,8 +1844,8 @@ }); // set target types - if (config[__data_type]) { - $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config[__data_types]); }), config[__data_type]); + if (config.data_type) { + $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type); } // cache as original id keyed @@ -2099,7 +1946,7 @@ c3_chart_internal_fn.categoryName = function (i) { var config = this.config; - return i < config[__axis_x_categories].length ? config[__axis_x_categories][i] : i; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; }; c3_chart_internal_fn.initEventRect = function () { @@ -2115,7 +1962,7 @@ // rects for mouseover var eventRects = $$.main.select('.' + CLASS[_eventRects]) - .style('cursor', config[__zoom_enabled] ? config[__axis_rotated] ? 'ns-resize' : 'ew-resize' : null) + .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) .classed(CLASS[_eventRectsMultiple], isMultipleX) .classed(CLASS[_eventRectsSingle], !isMultipleX); @@ -2178,10 +2025,10 @@ return $$.x(d.x) - (rectW / 2); }; } - x = config[__axis_rotated] ? 0 : rectX; - y = config[__axis_rotated] ? rectX : 0; - w = config[__axis_rotated] ? $$.width : rectW; - h = config[__axis_rotated] ? rectW : $$.height; + x = config.axis_rotated ? 0 : rectX; + y = config.axis_rotated ? rectX : 0; + w = config.axis_rotated ? $$.width : rectW; + h = config.axis_rotated ? rectW : $$.height; } eventRectUpdate @@ -2195,7 +2042,7 @@ var $$ = this, d3 = $$.d3, config = $$.config; eventRectEnter.append("rect") .attr("class", $$.classEvent.bind($$)) - .style("cursor", config[__data_selection_enabled] && config[__data_selection_grouped] ? "pointer" : null) + .style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null) .on('mouseover', function (d) { var index = d.index, selectedData, newData; @@ -2208,7 +2055,7 @@ // Sort selectedData as names order newData = []; - Object.keys(config[__data_names]).forEach(function (id) { + Object.keys(config.data_names).forEach(function (id) { for (var j = 0; j < selectedData.length; j++) { if (selectedData[j] && selectedData[j].id === id) { newData.push(selectedData[j]); @@ -2220,12 +2067,12 @@ selectedData = newData.concat(selectedData); // Add remained // Expand shapes for selection - if (config[__point_focus_expand_enabled]) { $$.expandCircles(index); } + if (config.point_focus_expand_enabled) { $$.expandCircles(index); } $$.expandBars(index); // Call event handler $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { - config[__data_onmouseover].call(c3, d); + config.data_onmouseover.call($$, d); }); }) .on('mouseout', function (d) { @@ -2238,7 +2085,7 @@ $$.unexpandBars(); // Call event handler $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { - config[__data_onmouseout].call($$, d); + config.data_onmouseout.call($$, d); }); }) .on('mousemove', function (d) { @@ -2253,25 +2100,25 @@ return $$.addName($$.getValueOnIndex(t.values, index)); }); - if (config[__tooltip_grouped]) { + if (config.tooltip_grouped) { $$.showTooltip(selectedData, d3.mouse(this)); $$.showXGridFocus(selectedData); } - if (config[__tooltip_grouped] && (!config[__data_selection_enabled] || config[__data_selection_grouped])) { + if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { return; } $$.main.selectAll('.' + CLASS[_shape] + '-' + index) .each(function () { d3.select(this).classed(CLASS[_EXPANDED], true); - if (config[__data_selection_enabled]) { - eventRect.style('cursor', config[__data_selection_grouped] ? 'pointer' : null); + if (config.data_selection_enabled) { + eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); } - if (!config[__tooltip_grouped]) { + if (!config.tooltip_grouped) { $$.hideXGridFocus(); $$.hideTooltip(); - if (!config[__data_selection_grouped]) { + if (!config.data_selection_grouped) { $$.unexpandCircles(index); $$.unexpandBars(); } @@ -2286,13 +2133,13 @@ } }) .each(function (d) { - if (config[__data_selection_enabled] && (config[__data_selection_grouped] || config[__data_selection_isselectable](d))) { + if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { eventRect.style('cursor', 'pointer'); } - if (!config[__tooltip_grouped]) { + if (!config.tooltip_grouped) { $$.showTooltip([d], d3.mouse(this)); $$.showXGridFocus([d]); - if (config[__point_focus_expand_enabled]) { $$.expandCircles(index, d.id); } + if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id); } $$.expandBars(index, d.id); } }); @@ -2356,7 +2203,7 @@ $$.showTooltip(selectedData, mouse); // expand points - if (config[__point_focus_expand_enabled]) { + if (config.point_focus_expand_enabled) { $$.unexpandCircles(); $$.expandCircles(closest.index, closest.id); } @@ -2368,12 +2215,12 @@ if ($$.dist(closest, mouse) < 100) { $$.svg.select('.' + CLASS[_eventRect]).style('cursor', 'pointer'); if (!$$.mouseover) { - config[__data_onmouseover].call($$, closest); + config.data_onmouseover.call($$, closest); $$.mouseover = true; } } else if ($$.mouseover) { $$.svg.select('.' + CLASS[_eventRect]).style('cursor', null); - config[__data_onmouseout].call($$, closest); + config.data_onmouseout.call($$, closest); $$.mouseover = false; } }) @@ -2406,40 +2253,40 @@ c3_chart_internal_fn.getCurrentWidth = function () { var $$ = this, config = $$.config; - return config[__size_width] ? config[__size_width] : $$.getParentWidth(); + return config.size_width ? config.size_width : $$.getParentWidth(); }; c3_chart_internal_fn.getCurrentHeight = function () { var $$ = this, config = $$.config, - h = config[__size_height] ? config[__size_height] : $$.getParentHeight(); + h = config.size_height ? config.size_height : $$.getParentHeight(); return h > 0 ? h : 320; }; c3_chart_internal_fn.getCurrentPaddingTop = function () { var config = this.config; - return isValue(config[__padding_top]) ? config[__padding_top] : 0; + return isValue(config.padding_top) ? config.padding_top : 0; }; c3_chart_internal_fn.getCurrentPaddingBottom = function () { var config = this.config; - return isValue(config[__padding_bottom]) ? config[__padding_bottom] : 0; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; }; c3_chart_internal_fn.getCurrentPaddingLeft = function () { var $$ = this, config = $$.config; - if (isValue(config[__padding_left])) { - return config[__padding_left]; - } else if (config[__axis_rotated]) { - return !config[__axis_x_show] ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40); + if (isValue(config.padding_left)) { + return config.padding_left; + } else if (config.axis_rotated) { + return !config.axis_x_show ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40); } else { - return !config[__axis_y_show] ? 1 : ceil10($$.getAxisWidthByAxisId('y')); + return !config.axis_y_show ? 1 : ceil10($$.getAxisWidthByAxisId('y')); } }; c3_chart_internal_fn.getCurrentPaddingRight = function () { var $$ = this, config = $$.config, defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; - if (isValue(config[__padding_right])) { - return config[__padding_right] + 1; // 1 is needed not to hide tick line - } else if (config[__axis_rotated]) { + if (isValue(config.padding_right)) { + return config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { return defaultPadding + legendWidthOnRight; } else { - return (!config[__axis_y2_show] ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight; + return (!config.axis_y2_show ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight; } }; @@ -2465,7 +2312,7 @@ c3_chart_internal_fn.getSvgLeft = function () { var $$ = this, config = $$.config, - leftAxisClass = config[__axis_rotated] ? CLASS[_axisX] : CLASS[_axisY], + leftAxisClass = config.axis_rotated ? CLASS[_axisX] : CLASS[_axisY], leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, chartRect = $$.selectChart.node().getBoundingClientRect(), @@ -2481,10 +2328,10 @@ }; c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) { var $$ = this, config = $$.config; - if (axisId === 'x' && !config[__axis_x_show]) { return 0; } - if (axisId === 'x' && config[__axis_x_height]) { return config[__axis_x_height]; } - if (axisId === 'y' && !config[__axis_y_show]) { return config[__legend_show] && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } - if (axisId === 'y2' && !config[__axis_y2_show]) { return $$.rotated_padding_top; } + if (axisId === 'x' && !config.axis_x_show) { return 0; } + if (axisId === 'x' && config.axis_x_height) { return config.axis_x_height; } + if (axisId === 'y' && !config.axis_y_show) { return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } + if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } return ($$.getAxisLabelPositionById(axisId).isInner ? 30 : 40) + (axisId === 'y2' ? -10 : 0); }; @@ -2498,7 +2345,7 @@ firstData = target.values[0], lastData = target.values[target.values.length - 1]; base = $$.x(lastData.x) - $$.x(firstData.x); if (base === 0) { - return $$.config[__axis_rotated] ? $$.height : $$.width; + return $$.config.axis_rotated ? $$.height : $$.width; } maxDataCount = $$.getMaxDataCount(); ratio = ($$.hasType('bar') ? (maxDataCount - ($$.isCategorized() ? 0.25 : 1)) / maxDataCount : 1); @@ -2510,11 +2357,11 @@ var $$ = this, config = $$.config, indices = {}, i = 0, j, k; $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) { - for (j = 0; j < config[__data_groups].length; j++) { - if (config[__data_groups][j].indexOf(d.id) < 0) { continue; } - for (k = 0; k < config[__data_groups][j].length; k++) { - if (config[__data_groups][j][k] in indices) { - indices[d.id] = indices[config[__data_groups][j][k]]; + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { continue; } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; break; } } @@ -2590,7 +2437,7 @@ .attr("class", function (d) { return $$.generateClass(CLASS[_selectedCircles], d.id); }); mainLineEnter.append('g') .attr("class", classCircles) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }); + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); // Update date for selected circles targets.forEach(function (t) { $$.main.selectAll('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[_selectedCircle]).each(function (d) { @@ -2628,17 +2475,17 @@ yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, yValue = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); + return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); }; - line = config[__axis_rotated] ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); - if (!config[__line_connect_null]) { line = line.defined(function (d) { return d.value != null; }); } + line = config.axis_rotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); + if (!config.line_connect_null) { line = line.defined(function (d) { return d.value != null; }); } return function (d) { - var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values, + var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values, x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; if ($$.isLineType(d)) { - if (config[__data_regions][d.id]) { - path = $$.lineWithRegions(data, x, y, config[__data_regions][d.id]); + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(data, x, y, config.data_regions[d.id]); } else { path = line.interpolate($$.getInterpolate(d))(data); } @@ -2647,7 +2494,7 @@ x0 = x(data[0].x); y0 = y(data[0].value); } - path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; + path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; @@ -2664,7 +2511,7 @@ offset = lineOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant - if (config[__axis_rotated]) { + if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the line position @@ -2709,8 +2556,8 @@ } // Set scales - xValue = config[__axis_rotated] ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; - yValue = config[__axis_rotated] ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; + xValue = config.axis_rotated ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; + yValue = config.axis_rotated ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; // Define svg generator function for region if ($$.isTimeSeries()) { @@ -2782,19 +2629,19 @@ yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, value0 = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0); + return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0); }, value1 = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); + return config.data_groups.length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); }; - area = config[__axis_rotated] ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1); - if (!config[__line_connect_null]) { + area = config.axis_rotated ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1); + if (!config.line_connect_null) { area = area.defined(function (d) { return d.value !== null; }); } return function (d) { - var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; + var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; if ($$.isAreaType(d)) { path = area.interpolate($$.getInterpolate(d))(data); } else { @@ -2802,7 +2649,7 @@ x0 = $$.x(data[0].x); y0 = $$.getYScale(d.id)(data[0].value); } - path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; + path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; @@ -2820,7 +2667,7 @@ offset = areaOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant - if (config[__axis_rotated]) { + if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the area position @@ -2861,7 +2708,7 @@ c3_chart_internal_fn.circleY = function (d, i) { var $$ = this, lineIndices = $$.getShapeIndices($$.isLineType), getPoint = $$.generateGetLinePoint(lineIndices); - return $$.config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value); + return $$.config.data_groups.length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value); }; c3_chart_internal_fn.getCircles = function (i, id) { var $$ = this; @@ -2884,15 +2731,15 @@ }; c3_chart_internal_fn.pointR = function (d) { var $$ = this, config = $$.config; - return config[__point_show] && !$$.isStepType(d) ? (isFunction(config[__point_r]) ? config[__point_r](d) : config[__point_r]) : 0; + return config.point_show && !$$.isStepType(d) ? (isFunction(config.point_r) ? config.point_r(d) : config.point_r) : 0; }; c3_chart_internal_fn.pointExpandedR = function (d) { var $$ = this, config = $$.config; - return config[__point_focus_expand_enabled] ? (config[__point_focus_expand_r] ? config[__point_focus_expand_r] : $$.pointR(d) * 1.75) : $$.pointR(d); + return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d); }; c3_chart_internal_fn.pointSelectR = function (d) { var $$ = this, config = $$.config; - return config[__point_select_r] ? config[__point_select_r] : $$.pointR(d) * 4; + return config.point_select_r ? config.point_select_r : $$.pointR(d) * 4; }; c3_chart_internal_fn.isWithinCircle = function (_this, _r) { var d3 = this.d3, @@ -2921,7 +2768,7 @@ // Bars for each data mainBarEnter.append('g') .attr("class", classBars) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }); + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); }; c3_chart_internal_fn.redrawBar = function (durationForExit) { @@ -2951,8 +2798,8 @@ }; c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) { var $$ = this, config = $$.config, - w = typeof config[__bar_width] === 'number' ? config[__bar_width] : barTargetsNum ? (axis.tickOffset() * 2 * config[__bar_width_ratio]) / barTargetsNum : 0; - return config[__bar_width_max] && w > config[__bar_width_max] ? config[__bar_width_max] : w; + w = typeof config.bar_width === 'number' ? config.bar_width : barTargetsNum ? (axis.tickOffset() * 2 * config.bar_width_ratio) / barTargetsNum : 0; + return config.bar_width_max && w > config.bar_width_max ? config.bar_width_max : w; }; c3_chart_internal_fn.getBars = function (i) { var $$ = this; @@ -2974,8 +2821,8 @@ var points = getPoints(d, i); // switch points if axis is rotated, not applicable for sub chart - var indexX = config[__axis_rotated] ? 1 : 0; - var indexY = config[__axis_rotated] ? 0 : 1; + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' + 'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' + @@ -2999,7 +2846,7 @@ offset = barOffset(d, i) || y0, // offset is for stacked bar chart posX = barX(d), posY = barY(d); // fix posY not to overflow opposite quadrant - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 4 points that make a bar @@ -3048,7 +2895,7 @@ .data(barOrLineData); $$.mainText.enter().append('text') .attr("class", classText) - .attr('text-anchor', function (d) { return config[__axis_rotated] ? (d.value < 0 ? 'end' : 'start') : 'middle'; }) + .attr('text-anchor', function (d) { return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; }) .style("stroke", 'none') .style("fill", function (d) { return $$.color(d); }) .style("fill-opacity", 0); @@ -3090,7 +2937,7 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), xPos, padding; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { padding = $$.isBarType(d) ? 4 : 6; xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); } else { @@ -3101,7 +2948,7 @@ c3_chart_internal_fn.getYForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), yPos; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; } else { yPos = points[2][1] + (d.value < 0 ? box.height : $$.isBarType(d) ? -3 : -6); @@ -3112,15 +2959,15 @@ c3_chart_internal_fn.setTargetType = function (targetIds, type) { var $$ = this, config = $$.config; $$.mapToTargetIds(targetIds).forEach(function (id) { - $$.withoutFadeIn[id] = (type === config[__data_types][id]); - config[__data_types][id] = type; + $$.withoutFadeIn[id] = (type === config.data_types[id]); + config.data_types[id] = type; }); if (!targetIds) { - config[__data_type] = type; + config.data_type = type; } }; c3_chart_internal_fn.hasType = function (type, targets) { - var $$ = this, types = $$.config[__data_types], has = false; + var $$ = this, types = $$.config.data_types, has = false; (targets || $$.data.targets).forEach(function (t) { if ((types[t.id] && types[t.id].indexOf(type) >= 0) || (!(t.id in types) && type === 'line')) { has = true; @@ -3133,39 +2980,39 @@ }; c3_chart_internal_fn.isLineType = function (d) { var config = this.config, id = isString(d) ? d : d.id; - return !config[__data_types][id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config[__data_types][id]) >= 0; + return !config.data_types[id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0; }; c3_chart_internal_fn.isStepType = function (d) { var id = isString(d) ? d : d.id; - return ['step', 'area-step'].indexOf(this.config[__data_types][id]) >= 0; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isSplineType = function (d) { var id = isString(d) ? d : d.id; - return ['spline', 'area-spline'].indexOf(this.config[__data_types][id]) >= 0; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isAreaType = function (d) { var id = isString(d) ? d : d.id; - return ['area', 'area-spline', 'area-step'].indexOf(this.config[__data_types][id]) >= 0; + return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isBarType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'bar'; + return this.config.data_types[id] === 'bar'; }; c3_chart_internal_fn.isScatterType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'scatter'; + return this.config.data_types[id] === 'scatter'; }; c3_chart_internal_fn.isPieType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'pie'; + return this.config.data_types[id] === 'pie'; }; c3_chart_internal_fn.isGaugeType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'gauge'; + return this.config.data_types[id] === 'gauge'; }; c3_chart_internal_fn.isDonutType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'donut'; + return this.config.data_types[id] === 'donut'; }; c3_chart_internal_fn.isArcType = function (d) { return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); @@ -3196,15 +3043,15 @@ $$.grid = $$.main.append('g') .attr("clip-path", $$.clipPath) .attr('class', CLASS[_grid]); - if (config[__grid_x_show]) { + if (config.grid_x_show) { $$.grid.append("g").attr("class", CLASS[_xgrids]); } - if (config[__grid_y_show]) { + if (config.grid_y_show) { $$.grid.append('g').attr('class', CLASS[_ygrids]); } $$.grid.append('g').attr("class", CLASS[_xgridLines]); $$.grid.append('g').attr('class', CLASS[_ygridLines]); - if (config[__grid_focus_show]) { + if (config.grid_focus_show) { $$.grid.append('g') .attr("class", CLASS[_xgridFocus]) .append('line') @@ -3216,10 +3063,10 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3, - xgridData = $$.generateGridData(config[__grid_x_type], $$.x), + xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; - $$.xgridAttr = config[__axis_rotated] ? { + $$.xgridAttr = config.axis_rotated ? { 'x1': 0, 'x2': $$.width, 'y1': function (d) { return $$.x(d) - tickOffset; }, @@ -3236,7 +3083,7 @@ $$.xgrid.enter().append('line').attr("class", CLASS[_xgrid]); if (!withoutUpdate) { $$.xgrid.attr($$.xgridAttr) - .style("opacity", function () { return +d3.select(this).attr(config[__axis_rotated] ? 'y1' : 'x1') === (config[__axis_rotated] ? $$.height : 0) ? 0 : 1; }); + .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); } $$.xgrid.exit().remove(); }; @@ -3244,13 +3091,13 @@ c3_chart_internal_fn.updateYGrid = function () { var $$ = this, config = $$.config, CLASS = $$.CLASS; $$.ygrid = $$.main.select('.' + CLASS[_ygrids]).selectAll('.' + CLASS[_ygrid]) - .data($$.y.ticks(config[__grid_y_ticks])); + .data($$.y.ticks(config.grid_y_ticks)); $$.ygrid.enter().append('line') .attr('class', CLASS[_ygrid]); - $$.ygrid.attr("x1", config[__axis_rotated] ? $$.y : 0) - .attr("x2", config[__axis_rotated] ? $$.y : $$.width) - .attr("y1", config[__axis_rotated] ? 0 : $$.y) - .attr("y2", config[__axis_rotated] ? $$.height : $$.y); + $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0) + .attr("x2", config.axis_rotated ? $$.y : $$.width) + .attr("y1", config.axis_rotated ? 0 : $$.y) + .attr("y2", config.axis_rotated ? $$.height : $$.y); $$.ygrid.exit().remove(); $$.smoothLines($$.ygrid, 'grid'); }; @@ -3260,11 +3107,11 @@ var $$ = this, main = $$.main, config = $$.config, CLASS = $$.CLASS, xgridLine, ygridLine, yv; main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); - if (config[__grid_x_show]) { + if (config.grid_x_show) { $$.updateXGrid(); } $$.xgridLines = main.select('.' + CLASS[_xgridLines]).selectAll('.' + CLASS[_xgridLine]) - .data(config[__grid_x_lines]); + .data(config.grid_x_lines); // enter xgridLine = $$.xgridLines.enter().append('g') .attr("class", function (d) { return CLASS[_xgridLine] + (d.class ? ' ' + d.class : ''); }); @@ -3272,8 +3119,8 @@ .style("opacity", 0); xgridLine.append('text') .attr("text-anchor", "end") - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") - .attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top) + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") + .attr('dx', config.axis_rotated ? 0 : -$$.margin.top) .attr('dy', -5) .style("opacity", 0); // udpate @@ -3284,12 +3131,12 @@ .remove(); // Y-Grid - if (withY && config[__grid_y_show]) { + if (withY && config.grid_y_show) { $$.updateYGrid(); } if (withY) { $$.ygridLines = main.select('.' + CLASS[_ygridLines]).selectAll('.' + CLASS[_ygridLine]) - .data(config[__grid_y_lines]); + .data(config.grid_y_lines); // enter ygridLine = $$.ygridLines.enter().append('g') .attr("class", function (d) { return CLASS[_ygridLine] + (d.class ? ' ' + d.class : ''); }); @@ -3297,22 +3144,22 @@ .style("opacity", 0); ygridLine.append('text') .attr("text-anchor", "end") - .attr("transform", config[__axis_rotated] ? "rotate(-90)" : "") - .attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top) + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") + .attr('dx', config.axis_rotated ? 0 : -$$.margin.top) .attr('dy', -5) .style("opacity", 0); // update yv = $$.yv.bind($$); $$.ygridLines.select('line') .transition().duration(duration) - .attr("x1", config[__axis_rotated] ? yv : 0) - .attr("x2", config[__axis_rotated] ? yv : $$.width) - .attr("y1", config[__axis_rotated] ? 0 : yv) - .attr("y2", config[__axis_rotated] ? $$.height : yv) + .attr("x1", config.axis_rotated ? yv : 0) + .attr("x2", config.axis_rotated ? yv : $$.width) + .attr("y1", config.axis_rotated ? 0 : yv) + .attr("y2", config.axis_rotated ? $$.height : yv) .style("opacity", 1); $$.ygridLines.select('text') .transition().duration(duration) - .attr("x", config[__axis_rotated] ? 0 : $$.width) + .attr("x", config.axis_rotated ? 0 : $$.width) .attr("y", yv) .text(function (d) { return d.text; }) .style("opacity", 1); @@ -3325,13 +3172,13 @@ c3_chart_internal_fn.addTransitionForGrid = function (transitions) { var $$ = this, config = $$.config, xv = $$.xv.bind($$); transitions.push($$.xgridLines.select('line').transition() - .attr("x1", config[__axis_rotated] ? 0 : xv) - .attr("x2", config[__axis_rotated] ? $$.width : xv) - .attr("y1", config[__axis_rotated] ? xv : $$.margin.top) - .attr("y2", config[__axis_rotated] ? xv : $$.height) + .attr("x1", config.axis_rotated ? 0 : xv) + .attr("x2", config.axis_rotated ? $$.width : xv) + .attr("y1", config.axis_rotated ? xv : $$.margin.top) + .attr("y2", config.axis_rotated ? xv : $$.height) .style("opacity", 1)); transitions.push($$.xgridLines.select('text').transition() - .attr("x", config[__axis_rotated] ? $$.width : 0) + .attr("x", config.axis_rotated ? $$.width : 0) .attr("y", xv) .text(function (d) { return d.text; }) .style("opacity", 1)); @@ -3341,14 +3188,14 @@ dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), focusEl = $$.main.selectAll('line.' + CLASS[_xgridFocus]), xx = $$.xx.bind($$); - if (! config[__tooltip_show]) { return; } + if (! config.tooltip_show) { return; } // Hide when scatter plot exists if ($$.hasType('scatter') || $$.hasArcType()) { return; } focusEl .style("visibility", "visible") .data([dataToShow[0]]) - .attr(config[__axis_rotated] ? 'y1' : 'x1', xx) - .attr(config[__axis_rotated] ? 'y2' : 'x2', xx); + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); $$.smoothLines(focusEl, 'grid'); }; c3_chart_internal_fn.hideXGridFocus = function () { @@ -3357,10 +3204,10 @@ c3_chart_internal_fn.updateXgridFocus = function () { var $$ = this, config = $$.config; $$.main.select('line.' + CLASS[_xgridFocus]) - .attr("x1", config[__axis_rotated] ? 0 : -10) - .attr("x2", config[__axis_rotated] ? $$.width : -10) - .attr("y1", config[__axis_rotated] ? -10 : 0) - .attr("y2", config[__axis_rotated] ? -10 : $$.height); + .attr("x1", config.axis_rotated ? 0 : -10) + .attr("x2", config.axis_rotated ? $$.width : -10) + .attr("y1", config.axis_rotated ? -10 : 0) + .attr("y2", config.axis_rotated ? -10 : $$.height); }; c3_chart_internal_fn.generateGridData = function (type, scale) { var $$ = this, @@ -3399,12 +3246,12 @@ classLines = forX ? CLASS[_xgridLines] : CLASS[_ygridLines], classLine = forX ? CLASS[_xgridLine] : CLASS.ygridLine; $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) - .transition().duration(config[__transition_duration]) + .transition().duration(config.transition_duration) .style('opacity', 0).remove(); if (forX) { - config[__grid_x_lines] = config[__grid_x_lines].filter(toShow); + config.grid_x_lines = config.grid_x_lines.filter(toShow); } else { - config[__grid_y_lines] = config[__grid_y_lines].filter(toShow); + config.grid_y_lines = config.grid_y_lines.filter(toShow); } }; @@ -3418,27 +3265,27 @@ .style("z-index", "10") .style("display", "none"); // Show tooltip if needed - if (config[__tooltip_init_show]) { - if ($$.isTimeSeries() && isString(config[__tooltip_init_x])) { - config[__tooltip_init_x] = $$.parseDate(config[__tooltip_init_x]); + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); for (i = 0; i < $$.data.targets[0].values.length; i++) { - if (($$.data.targets[0].values[i].x - config[__tooltip_init_x]) === 0) { break; } + if (($$.data.targets[0].values[i].x - config.tooltip_init_x) === 0) { break; } } - config[__tooltip_init_x] = i; + config.tooltip_init_x = i; } - $$.tooltip.html(config[__tooltip_contents].call($$, $$.data.targets.map(function (d) { - return $$.addName(d.values[config[__tooltip_init_x]]); + $$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) { + return $$.addName(d.values[config.tooltip_init_x]); }), $$.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color)); - $$.tooltip.style("top", config[__tooltip_init_position].top) - .style("left", config[__tooltip_init_position].left) + $$.tooltip.style("top", config.tooltip_init_position.top) + .style("left", config.tooltip_init_position.left) .style("display", "block"); } }; c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) { var $$ = this, config = $$.config, - titleFormat = config[__tooltip_format_title] || defaultTitleFormat, - nameFormat = config[__tooltip_format_name] || function (name) { return name; }, - valueFormat = config[__tooltip_format_value] || defaultValueFormat, + titleFormat = config.tooltip_format_title || defaultTitleFormat, + nameFormat = config.tooltip_format_name || function (name) { return name; }, + valueFormat = 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; } @@ -3464,10 +3311,10 @@ var tWidth, tHeight, svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; var forArc = $$.hasArcType(), dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }); - if (dataToShow.length === 0 || !config[__tooltip_show]) { + if (dataToShow.length === 0 || !config.tooltip_show) { return; } - $$.tooltip.html(config[__tooltip_contents].call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); + $$.tooltip.html(config.tooltip_contents.call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); // Get tooltip dimensions tWidth = $$.tooltip.property('offsetWidth'); @@ -3477,7 +3324,7 @@ tooltipLeft = ($$.width / 2) + mouse[0]; tooltipTop = ($$.height / 2) + mouse[1] + 20; } else { - if (config[__axis_rotated]) { + if (config.axis_rotated) { svgLeft = $$.getSvgLeft(); tooltipLeft = svgLeft + mouse[0] + 100; tooltipRight = tooltipLeft + tWidth; @@ -3510,7 +3357,7 @@ c3_chart_internal_fn.initLegend = function () { var $$ = this; $$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend')); - if (!$$.config[__legend_show]) { + if (!$$.config.legend_show) { $$.legend.style('visibility', 'hidden'); $$.hiddenLegendIds = $$.mapToIds($$.data.targets); } @@ -3520,8 +3367,8 @@ }; c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) { var $$ = this, config = $$.config, insetLegendPosition = { - top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config[__legend_inset_y] + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config[__legend_inset_y], - left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config[__legend_inset_x] + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config[__legend_inset_x] + 0.5 + top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config.legend_inset_y, + left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config.legend_inset_x + 0.5 }; $$.margin3 = { top: $$.isLegendRight ? 0 : $$.isLegendInset ? insetLegendPosition.top : $$.currentHeight - legendHeight, @@ -3545,15 +3392,15 @@ }; c3_chart_internal_fn.getLegendWidth = function () { var $$ = this; - return $$.config[__legend_show] ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; + return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; }; c3_chart_internal_fn.getLegendHeight = function () { var $$ = this, config = $$.config, h = 0; - if (config[__legend_show]) { + if (config.legend_show) { if ($$.isLegendRight) { h = $$.currentHeight; } else if ($$.isLegendInset) { - h = config[__legend_inset_step] ? Math.max(20, $$.legendItemHeight) * (config[__legend_inset_step] + 1) : $$.height; + h = config.legend_inset_step ? Math.max(20, $$.legendItemHeight) * (config.legend_inset_step + 1) : $$.height; } else { h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); } @@ -3589,8 +3436,8 @@ }; c3_chart_internal_fn.showLegend = function (targetIds) { var $$ = this, config = $$.config; - if (!config[__legend_show]) { - config[__legend_show] = true; + if (!config.legend_show) { + config.legend_show = true; $$.legend.style('visibility', 'visible'); } $$.removeHiddenLegendIds(targetIds); @@ -3601,8 +3448,8 @@ }; c3_chart_internal_fn.hideLegend = function (targetIds) { var $$ = this, config = $$.config; - if (config[__legend_show] && isEmpty(targetIds)) { - config[__legend_show] = false; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; $$.legend.style('visibility', 'hidden'); } $$.addHiddenLegendIds(targetIds); @@ -3654,7 +3501,7 @@ maxHeight = 0; } - if (config[__legend_show] && !$$.isLegendToShow(id)) { + if (config.legend_show && !$$.isLegendToShow(id)) { widths[id] = heights[id] = steps[id] = offsets[id] = 0; return; } @@ -3666,7 +3513,7 @@ if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; } maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; - if (config[__legend_equally]) { + if (config.legend_equally) { Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); margin = (areaLength - maxLength * targetIds.length) / 2; @@ -3706,15 +3553,15 @@ .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('cursor', 'pointer') .on('click', function (id) { - config[__legend_item_onclick] ? config[__legend_item_onclick].call($$, id) : $$.api.toggle(id); + config.legend_item_onclick ? config.legend_item_onclick.call($$, id) : $$.api.toggle(id); }) .on('mouseover', function (id) { $$.d3.select(this).classed(CLASS[_legendItemFocused], true); if (!$$.transiting) { $$.api.focus(id); } - if (config[__legend_item_onmouseover]) { - config[__legend_item_onmouseover].call($$, id); + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); } }) .on('mouseout', function (id) { @@ -3722,12 +3569,12 @@ if (!$$.transiting) { $$.api.revert(); } - if (config[__legend_item_onmouseout]) { - config[__legend_item_onmouseout].call($$, id); + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); } }); l.append('text') - .text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; }) + .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) .each(function (id, i) { updatePositions(this, id, i === 0); }) .style("pointer-events", "none") .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) @@ -3756,7 +3603,7 @@ texts = $$.legend.selectAll('text') .data(targetIds) - .text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; }) // MEMO: needed for update + .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) // MEMO: needed for update .each(function (id, i) { updatePositions(this, id, i === 0); }); (withTransition ? texts.transition() : texts) .attr('x', xForLegendText) @@ -3808,30 +3655,30 @@ .attr("class", CLASS[_axis] + ' ' + CLASS[_axisX]) .attr("clip-path", $$.clipPathForXAxis) .attr("transform", $$.getTranslate('x')) - .style("visibility", config[__axis_x_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_x_show ? 'visible' : 'hidden'); $$.axes.x.append("text") .attr("class", CLASS[_axisXLabel]) - .attr("transform", config[__axis_rotated] ? "rotate(-90)" : "") + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .style("text-anchor", $$.textAnchorForXAxisLabel.bind($$)); $$.axes.y = main.append("g") .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY]) .attr("clip-path", $$.clipPathForYAxis) .attr("transform", $$.getTranslate('y')) - .style("visibility", config[__axis_y_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text") .attr("class", CLASS[_axisYLabel]) - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForYAxisLabel.bind($$)); $$.axes.y2 = main.append("g") .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY2]) // clip-path? .attr("transform", $$.getTranslate('y2')) - .style("visibility", config[__axis_y2_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text") .attr("class", CLASS[_axisY2Label]) - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); }; c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues) { @@ -3841,15 +3688,15 @@ // Set tick axis.tickFormat(tickFormat).tickValues(tickValues); if ($$.isCategorized()) { - axis.tickCentered(config[__axis_x_tick_centered]); - if (isEmpty(config[__axis_x_tick_culling])) { - config[__axis_x_tick_culling] = false; + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; } } else { // TODO: move this to c3_axis axis.tickOffset = function () { var edgeX = $$.getEdgeX($$.data.targets), diff = $$.x(edgeX[1]) - $$.x(edgeX[0]), - base = diff ? diff : (config[__axis_rotated] ? $$.height : $$.width); + base = diff ? diff : (config.axis_rotated ? $$.height : $$.width); return (base / $$.getMaxDataCount()) / 2; }; } @@ -3861,17 +3708,17 @@ }; c3_chart_internal_fn.getAxisId = function (id) { var config = this.config; - return id in config[__data_axes] ? config[__data_axes][id] : 'y'; + return id in config.data_axes ? config.data_axes[id] : 'y'; }; c3_chart_internal_fn.getXAxisTickFormat = function () { var $$ = this, config = $$.config, format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : v; }; - if (config[__axis_x_tick_format]) { - if (isFunction(config[__axis_x_tick_format])) { - format = config[__axis_x_tick_format]; + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; } else if ($$.isTimeSeries()) { format = function (date) { - return date ? $$.axisTimeFormat(config[__axis_x_tick_format])(date) : ""; + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : ""; }; } } @@ -3880,11 +3727,11 @@ c3_chart_internal_fn.getAxisLabelOptionByAxisId = function (axisId) { var $$ = this, config = $$.config, option; if (axisId === 'y') { - option = config[__axis_y_label]; + option = config.axis_y_label; } else if (axisId === 'y2') { - option = config[__axis_y2_label]; + option = config.axis_y2_label; } else if (axisId === 'x') { - option = config[__axis_x_label]; + option = config.axis_x_label; } return option; }; @@ -3897,11 +3744,11 @@ option = $$.getAxisLabelOptionByAxisId(axisId); if (isString(option)) { if (axisId === 'y') { - config[__axis_y_label] = text; + config.axis_y_label = text; } else if (axisId === 'y2') { - config[__axis_y2_label] = text; + config.axis_y2_label = text; } else if (axisId === 'x') { - config[__axis_x_label] = text; + config.axis_x_label = text; } } else if (option) { option.text = text; @@ -3922,13 +3769,13 @@ }; }; c3_chart_internal_fn.getXAxisLabelPosition = function () { - return this.getAxisLabelPosition('x', this.config[__axis_rotated] ? 'inner-top' : 'inner-right'); + return this.getAxisLabelPosition('x', this.config.axis_rotated ? 'inner-top' : 'inner-right'); }; c3_chart_internal_fn.getYAxisLabelPosition = function () { - return this.getAxisLabelPosition('y', this.config[__axis_rotated] ? 'inner-right' : 'inner-top'); + return this.getAxisLabelPosition('y', this.config.axis_rotated ? 'inner-right' : 'inner-top'); }; c3_chart_internal_fn.getY2AxisLabelPosition = function () { - return this.getAxisLabelPosition('y2', this.config[__axis_rotated] ? 'inner-right' : 'inner-top'); + return this.getAxisLabelPosition('y2', this.config.axis_rotated ? 'inner-right' : 'inner-top'); }; c3_chart_internal_fn.getAxisLabelPositionById = function (id) { return id === 'y2' ? this.getY2AxisLabelPosition() : id === 'y' ? this.getYAxisLabelPosition() : this.getXAxisLabelPosition(); @@ -3965,36 +3812,36 @@ } }; c3_chart_internal_fn.xForXAxisLabel = function () { - return this.xForAxisLabel(!this.config[__axis_rotated], this.getXAxisLabelPosition()); + return this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition()); }; c3_chart_internal_fn.xForYAxisLabel = function () { - return this.xForAxisLabel(this.config[__axis_rotated], this.getYAxisLabelPosition()); + return this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition()); }; c3_chart_internal_fn.xForY2AxisLabel = function () { - return this.xForAxisLabel(this.config[__axis_rotated], this.getY2AxisLabelPosition()); + return this.xForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition()); }; c3_chart_internal_fn.dxForXAxisLabel = function () { - return this.dxForAxisLabel(!this.config[__axis_rotated], this.getXAxisLabelPosition()); + return this.dxForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition()); }; c3_chart_internal_fn.dxForYAxisLabel = function () { - return this.dxForAxisLabel(this.config[__axis_rotated], this.getYAxisLabelPosition()); + return this.dxForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition()); }; c3_chart_internal_fn.dxForY2AxisLabel = function () { - return this.dxForAxisLabel(this.config[__axis_rotated], this.getY2AxisLabelPosition()); + return this.dxForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition()); }; c3_chart_internal_fn.dyForXAxisLabel = function () { var $$ = this, config = $$.config, position = $$.getXAxisLabelPosition(); - if (config[__axis_rotated]) { + if (config.axis_rotated) { return position.isInner ? "1.2em" : -25 - $$.getMaxTickWidth('x'); } else { - return position.isInner ? "-0.5em" : config[__axis_x_height] ? config[__axis_x_height] - 10 : "3em"; + return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; } }; c3_chart_internal_fn.dyForYAxisLabel = function () { var $$ = this, position = $$.getYAxisLabelPosition(); - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { return position.isInner ? "-0.5em" : "3em"; } else { return position.isInner ? "1.2em" : -20 - $$.getMaxTickWidth('y'); @@ -4003,7 +3850,7 @@ c3_chart_internal_fn.dyForY2AxisLabel = function () { var $$ = this, position = $$.getY2AxisLabelPosition(); - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { return position.isInner ? "1.2em" : "-2.2em"; } else { return position.isInner ? "-0.5em" : 30 + this.getMaxTickWidth('y2'); @@ -4011,15 +3858,15 @@ }; c3_chart_internal_fn.textAnchorForXAxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel(!$$.config[__axis_rotated], $$.getXAxisLabelPosition()); + return $$.textAnchorForAxisLabel(!$$.config.axis_rotated, $$.getXAxisLabelPosition()); }; c3_chart_internal_fn.textAnchorForYAxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel($$.config[__axis_rotated], $$.getYAxisLabelPosition()); + return $$.textAnchorForAxisLabel($$.config.axis_rotated, $$.getYAxisLabelPosition()); }; c3_chart_internal_fn.textAnchorForY2AxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel($$.config[__axis_rotated], $$.getY2AxisLabelPosition()); + return $$.textAnchorForAxisLabel($$.config.axis_rotated, $$.getY2AxisLabelPosition()); }; c3_chart_internal_fn.xForRotatedTickText = function (r) { @@ -4044,13 +3891,13 @@ targetsToShow = $$.filterTargetsToShow($$.data.targets); if (id === 'y') { scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); - axis = $$.getYAxis(scale, $$.yOrient, config[__axis_y_tick_format], config[__axis_y_ticks]); + axis = $$.getYAxis(scale, $$.yOrient, config.axis_y_tick_format, config.axis_y_ticks); } else if (id === 'y2') { scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); - axis = $$.getYAxis(scale, $$.y2Orient, config[__axis_y2_tick_format], config[__axis_y2_ticks]); + axis = $$.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, config.axis_y2_ticks); } else { scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); - axis = $$.getXAxis(scale, $$.xOrient, $$.getXAxisTickFormat(), config[__axis_x_tick_values] ? config[__axis_x_tick_values] : $$.xAxis.tickValues()); + axis = $$.getXAxis(scale, $$.xOrient, $$.getXAxisTickFormat(), config.axis_x_tick_values ? config.axis_x_tick_values : $$.xAxis.tickValues()); } $$.main.append("g").call(axis).each(function () { $$.d3.select(this).selectAll('text').each(function () { @@ -4151,19 +3998,19 @@ }; c3_chart_internal_fn.getXAxisClipX = function () { var $$ = this; - return $$.getAxisClipX(!$$.config[__axis_rotated]); + return $$.getAxisClipX(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipY = function () { var $$ = this; - return $$.getAxisClipY(!$$.config[__axis_rotated]); + return $$.getAxisClipY(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipX = function () { var $$ = this; - return $$.getAxisClipX($$.config[__axis_rotated]); + return $$.getAxisClipX($$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipY = function () { var $$ = this; - return $$.getAxisClipY($$.config[__axis_rotated]); + return $$.getAxisClipY($$.config.axis_rotated); }; c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) { var $$ = this; @@ -4172,23 +4019,23 @@ }; c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) { var $$ = this, config = $$.config; - return forHorizontal ? (config[__axis_x_height] ? config[__axis_x_height] : 0) + 80 : $$.height + 8; + return forHorizontal ? (config.axis_x_height ? config.axis_x_height : 0) + 80 : $$.height + 8; }; c3_chart_internal_fn.getXAxisClipWidth = function () { var $$ = this; - return $$.getAxisClipWidth(!$$.config[__axis_rotated]); + return $$.getAxisClipWidth(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipHeight = function () { var $$ = this; - return $$.getAxisClipHeight(!$$.config[__axis_rotated]); + return $$.getAxisClipHeight(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipWidth = function () { var $$ = this; - return $$.getAxisClipWidth($$.config[__axis_rotated]); + return $$.getAxisClipWidth($$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipHeight = function () { var $$ = this; - return $$.getAxisClipHeight($$.config[__axis_rotated]); + return $$.getAxisClipHeight($$.config.axis_rotated); }; c3_chart_internal_fn.initPie = function () { @@ -4196,14 +4043,14 @@ $$.pie = d3.layout.pie().value(function (d) { return d.values.reduce(function (a, b) { return a + b.value; }, 0); }); - if (!config[__data_order] || !config[__pie_sort] || !config[__donut_sort]) { + if (!config.data_order || !config.pie_sort || !config.donut_sort) { $$.pie.sort(null); } }; c3_chart_internal_fn.updateRadius = function () { var $$ = this, config = $$.config, - w = config[__gauge_width] || config[__donut_width]; + w = config.gauge_width || config.donut_width; $$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2; $$.radius = $$.radiusExpanded * 0.95; $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; @@ -4232,7 +4079,7 @@ d.endAngle = d.startAngle; } if ($$.isGaugeType(d.data)) { - var gMin = config[__gauge_min], gMax = config[__gauge_max], + var gMin = config.gauge_min, gMax = config.gauge_max, gF = Math.abs(gMin) + gMax, aTic = (Math.PI) / gF; d.startAngle = (-1 * (Math.PI / 2)) + (aTic * Math.abs(gMin)); @@ -4345,15 +4192,15 @@ c3_chart_internal_fn.shouldExpand = function (id) { var $$ = this, config = $$.config; - return ($$.isDonutType(id) && config[__donut_expand]) || ($$.isGaugeType(id) && config[__gauge_expand]) || ($$.isPieType(id) && config[__pie_expand]); + return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand); }; c3_chart_internal_fn.shouldShowArcLabel = function () { var $$ = this, config = $$.config, shouldShow = true; if ($$.hasType('donut')) { - shouldShow = config[__donut_label_show]; + shouldShow = config.donut_label_show; } else if ($$.hasType('pie')) { - shouldShow = config[__pie_label_show]; + shouldShow = config.pie_label_show; } // when gauge, always true return shouldShow; @@ -4361,24 +4208,24 @@ c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) { var $$ = this, config = $$.config, - threshold = $$.hasType('donut') ? config[__donut_label_threshold] : config[__pie_label_threshold]; + threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold; return ratio >= threshold; }; c3_chart_internal_fn.getArcLabelFormat = function () { var $$ = this, config = $$.config, - format = config[__pie_label_format]; + format = config.pie_label_format; if ($$.hasType('gauge')) { - format = config[__gauge_label_format]; + format = config.gauge_label_format; } else if ($$.hasType('donut')) { - format = config[__donut_label_format]; + format = config.donut_label_format; } return format; }; c3_chart_internal_fn.getArcTitle = function () { var $$ = this; - return $$.hasType('donut') ? $$.config[__donut_title] : ""; + return $$.hasType('donut') ? $$.config.donut_title : ""; }; c3_chart_internal_fn.descByStartAngle = function (a, b) { @@ -4425,7 +4272,7 @@ mainArc.enter().append('path') .attr("class", $$.classArc.bind($$)) .style("fill", function (d) { return $$.color(d.data); }) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }) + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }) .style("opacity", 0) .each(function (d) { if ($$.isGaugeType(d.data)) { @@ -4443,7 +4290,7 @@ // transitions $$.expandArc(updated.data.id); $$.toggleFocusLegend(updated.data.id, true); - $$.config[__data_onmouseover](arcData, this); + $$.config.data_onmouseover(arcData, this); }) .on('mousemove', function (d) { var updated = $$.updateAngle(d), @@ -4462,7 +4309,7 @@ $$.unexpandArc(updated.data.id); $$.revertLegend(); $$.hideTooltip(); - $$.config[__data_onmouseout](arcData, this); + $$.config.data_onmouseout(arcData, this); }) .on('click', function (d, i) { var updated, arcData; @@ -4525,7 +4372,7 @@ .attr("class", CLASS[_chartArcsBackground]) .attr("d", function () { var d = { - data: [{value: config[__gauge_max]}], + data: [{value: config.gauge_max}], startAngle: -1 * (Math.PI / 2), endAngle: Math.PI / 2 }; @@ -4536,21 +4383,21 @@ .attr("class", CLASS[_chartArcsGaugeUnit]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_units] : ''); + .text(config.gauge_label_show ? config.gauge_units : ''); arcs.append("text") .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px") .attr("dy", "1.2em") .attr("class", CLASS[_chartArcsGaugeMin]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_min] : ''); + .text(config.gauge_label_show ? config.gauge_min : ''); arcs.append("text") .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") .attr("dy", "1.2em") .attr("class", CLASS[_chartArcsGaugeMax]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_max] : ''); + .text(config.gauge_label_show ? config.gauge_max : ''); } }; @@ -4563,7 +4410,7 @@ c3_chart_internal_fn.redrawRegion = function (duration) { var $$ = this, config = $$.config, CLASS = $$.CLASS; $$.mainRegion = $$.main.select('.' + CLASS[_regions]).selectAll('.' + CLASS[_region]) - .data(config[__regions]); + .data(config.regions); $$.mainRegion.enter().append('g') .attr('class', $$.classRegion.bind($$)) .append('rect') @@ -4589,9 +4436,9 @@ var $$ = this, config = $$.config, xPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - xPos = config[__axis_rotated] ? ('start' in d ? yScale(d.start) : 0) : 0; + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; } else { - xPos = config[__axis_rotated] ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0); + xPos = config.axis_rotated ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0); } return xPos; }; @@ -4599,9 +4446,9 @@ var $$ = this, config = $$.config, yPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - yPos = config[__axis_rotated] ? 0 : ('end' in d ? yScale(d.end) : 0); + yPos = config.axis_rotated ? 0 : ('end' in d ? yScale(d.end) : 0); } else { - yPos = config[__axis_rotated] ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0; + yPos = config.axis_rotated ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0; } return yPos; }; @@ -4609,9 +4456,9 @@ var $$ = this, config = $$.config, start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - end = config[__axis_rotated] ? ('end' in d ? yScale(d.end) : $$.width) : $$.width; + end = config.axis_rotated ? ('end' in d ? yScale(d.end) : $$.width) : $$.width; } else { - end = config[__axis_rotated] ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width); + end = config.axis_rotated ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width); } return end < start ? 0 : end - start; }; @@ -4619,9 +4466,9 @@ var $$ = this, config = $$.config, start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - end = config[__axis_rotated] ? $$.height : ('start' in d ? yScale(d.start) : $$.height); + end = config.axis_rotated ? $$.height : ('start' in d ? yScale(d.start) : $$.height); } else { - end = config[__axis_rotated] ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height; + end = config.axis_rotated ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height; } return end < start ? 0 : end - start; }; @@ -4634,9 +4481,9 @@ var sx, sy, mx, my, minX, maxX, minY, maxY; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable - if (config[__zoom_enabled] && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior - if (!config[__data_selection_multiple]) { return; } // skip when single selection because drag is used for multiple selection + if (! config.data_selection_enabled) { return; } // do nothing if not selectable + if (config.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior + if (!config.data_selection_multiple) { return; } // skip when single selection because drag is used for multiple selection sx = $$.dragStart[0]; sy = $$.dragStart[1]; @@ -4644,8 +4491,8 @@ my = mouse[1]; minX = Math.min(sx, mx); maxX = Math.max(sx, mx); - minY = (config[__data_selection_grouped]) ? $$.margin.top : Math.min(sy, my); - maxY = (config[__data_selection_grouped]) ? $$.height : Math.max(sy, my); + minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); + maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); main.select('.' + CLASS[_dragarea]) .attr('x', minX) @@ -4654,7 +4501,7 @@ .attr('height', maxY - minY); // TODO: binary search when multiple xs main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]) - .filter(function (d) { return config[__data_selection_isselectable](d); }) + .filter(function (d) { return config.data_selection_isselectable(d); }) .each(function (d, i) { var shape = d3.select(this), isSelected = shape.classed(CLASS[_SELECTED]), @@ -4690,19 +4537,19 @@ c3_chart_internal_fn.dragstart = function (mouse) { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable + if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.dragStart = mouse; $$.main.select('.' + CLASS[_chart]).append('rect') .attr('class', CLASS[_dragarea]) .style('opacity', 0.1); $$.dragging = true; - $$.config[__data_ondragstart](); + $$.config.data_ondragstart(); }; c3_chart_internal_fn.dragend = function () { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable + if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.main.select('.' + CLASS[_dragarea]) .transition().duration(100) .style('opacity', 0) @@ -4710,16 +4557,16 @@ $$.main.selectAll('.' + CLASS[_shape]) .classed(CLASS[_INCLUDED], false); $$.dragging = false; - $$.config[__data_ondragend](); + $$.config.data_ondragend(); }; c3_chart_internal_fn.selectPoint = function (target, d, i) { var $$ = this, config = $$.config, - cx = (config[__axis_rotated] ? $$.circleY : $$.circleX).bind($$), - cy = (config[__axis_rotated] ? $$.circleX : $$.circleY).bind($$), + cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), r = $$.pointSelectR.bind($$); - config[__data_onselected].call($$.api, d, target.node()); + config.data_onselected.call($$.api, d, target.node()); // add selected-circle on low layer g $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) .data([d]) @@ -4734,7 +4581,7 @@ }; c3_chart_internal_fn.unselectPoint = function (target, d, i) { var $$ = this; - $$.config[__data_onunselected](d, target.node()); + $$.config.data_onunselected(d, target.node()); // remove selected-circle from low layer g $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) .transition().duration(100).attr('r', 0) @@ -4745,13 +4592,13 @@ }; c3_chart_internal_fn.selectBar = function (target, d) { var $$ = this; - $$.config[__data_onselected].call($$, d, target.node()); + $$.config.data_onselected.call($$, d, target.node()); target.transition().duration(100) .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); }; c3_chart_internal_fn.unselectBar = function (target, d) { var $$ = this; - $$.config[__data_onunselected].call($$, d, target.node()); + $$.config.data_onunselected.call($$, d, target.node()); target.transition().duration(100) .style("fill", function () { return $$.color(d); }); }; @@ -4782,10 +4629,10 @@ toggle = $$.toggleArc; } } - if (config[__data_selection_grouped] || isWithin) { - if (config[__data_selection_enabled] && config[__data_selection_isselectable](d)) { - if (!config[__data_selection_multiple]) { - $$.main.selectAll('.' + CLASS[_shapes] + (config[__data_selection_grouped] ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { + if (config.data_selection_grouped || isWithin) { + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main.selectAll('.' + CLASS[_shapes] + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this); if (shape.classed(CLASS[_SELECTED])) { toggle.call($$, false, shape.classed(CLASS[_SELECTED], false), d, i); } }); @@ -4793,7 +4640,7 @@ shape.classed(CLASS[_SELECTED], !isSelected); toggle.call($$, !isSelected, shape, d, i); } - $$.config[__data_onclick].call($$.api, d, that); + $$.config.data_onclick.call($$.api, d, that); } }; @@ -4805,14 +4652,14 @@ return this; }; $$.brush.scale = function (scale) { - return $$.config[__axis_rotated] ? this.y(scale) : this.x(scale); + return $$.config.axis_rotated ? this.y(scale) : this.x(scale); }; }; c3_chart_internal_fn.initSubchart = function () { var $$ = this, config = $$.config, context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')); - if (!config[__subchart_show]) { + if (!config.subchart_show) { context.style('visibility', 'hidden'); } @@ -4835,14 +4682,14 @@ .attr("class", CLASS[_brush]) .call($$.brush) .selectAll("rect") - .attr(config[__axis_rotated] ? "width" : "height", config[__axis_rotated] ? $$.width2 : $$.height2); + .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") .attr("class", CLASS[_axisX]) .attr("transform", $$.getTranslate('subx')) - .attr("clip-path", config[__axis_rotated] ? "" : $$.clipPathForXAxis); + .attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis); }; c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { var $$ = this, context = $$.context, config = $$.config, @@ -4853,7 +4700,7 @@ classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); - if (config[__subchart_show]) { + if (config.subchart_show) { contextBarUpdate = context.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) .data(targets) .attr('class', classChartBar); @@ -4890,7 +4737,7 @@ initialOpacity = $$.initialOpacity.bind($$); // subchart - if (config[__subchart_show]) { + if (config.subchart_show) { // reflect main chart to extent on subchart if zoomed if (d3.event && d3.event.type === 'zoom') { $$.brush.extent($$.x.orgDomain()).update(); @@ -4899,8 +4746,8 @@ if (withSubchart) { // rotate tick text if needed - if (!config[__axis_rotated] && config[__axis_x_tick_rotate]) { - $$.rotateTickText($$.axes.subx, transitions.axisSubX, config[__axis_x_tick_rotate]); + if (!config.axis_rotated && config.axis_x_tick_rotate) { + $$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate); } // extent rect @@ -4967,7 +4814,7 @@ withSubchart: false, withUpdateXDomain: true }); - $$.config[__subchart_onbrush].call($$.api, x.orgDomain()); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.transformContext = function (withTransition, transitions) { var $$ = this, subXAxis; @@ -4989,10 +4836,10 @@ }) .on("zoom", function () { $$.redrawForZoom.call($$); }); $$.zoom.scale = function (scale) { - return config[__axis_rotated] ? this.y(scale) : this.x(scale); + return config.axis_rotated ? this.y(scale) : this.x(scale); }; $$.zoom.orgScaleExtent = function () { - var extent = config[__zoom_extent] ? config[__zoom_extent] : [1, 10]; + var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; }; $$.zoom.updateScaleExtent = function () { @@ -5003,13 +4850,13 @@ }; }; c3_chart_internal_fn.updateZoom = function () { - var $$ = this, z = $$.config[__zoom_enabled] ? $$.zoom : function () {}; + var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; $$.main.select('.' + $$.CLASS[_zoomRect]).call(z); $$.main.selectAll('.' + $$.CLASS[_eventRect]).call(z); }; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x, orgXDomain = $$.orgXDomain; - if (!config[__zoom_enabled]) { + if (!config.zoom_enabled) { return; } if ($$.filterTargetsToShow($$.data.targets).length === 0) { @@ -5031,14 +4878,14 @@ if (d3.event.sourceEvent.type === 'mousemove') { $$.cancelClick = true; } - config[__zoom_onzoom].call($$.api, x.orgDomain()); + config.zoom_onzoom.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.generateColor = function () { var $$ = this, config = $$.config, d3 = $$.d3, - colors = config[__data_colors], - pattern = notEmpty(config[__color_pattern]) ? config[__color_pattern] : d3.scale.category10().range(), - callback = config[__data_color], + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), + callback = config.data_color, ids = []; return function (d) { @@ -5063,12 +4910,12 @@ }; c3_chart_internal_fn.generateLevelColor = function () { var $$ = this, config = $$.config, - colors = config[__color_pattern], - threshold = config[__color_threshold], + colors = config.color_pattern, + threshold = config.color_threshold, asValue = threshold.unit === 'value', values = threshold.values && threshold.values.length ? threshold.values : [], max = threshold.max || 100; - return notEmpty(config[__color_threshold]) ? function (value) { + return notEmpty(config.color_threshold) ? function (value) { var i, v, color = colors[colors.length - 1]; for (i = 0; i < values.length; i++) { v = asValue ? value : (value * 100 / max); @@ -5092,12 +4939,12 @@ }; c3_chart_internal_fn.yFormat = function (v) { var $$ = this, config = $$.config, - format = config[__axis_y_tick_format] ? config[__axis_y_tick_format] : $$.defaultValueFormat; + format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.y2Format = function (v) { var $$ = this, config = $$.config, - format = config[__axis_y2_tick_format] ? config[__axis_y2_tick_format] : $$.defaultValueFormat; + format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.defaultValueFormat = function (v) { @@ -5107,7 +4954,7 @@ return (ratio * 100).toFixed(1) + '%'; }; c3_chart_internal_fn.formatByAxisId = function (axisId) { - var $$ = this, data_labels = $$.config[__data_labels], + var $$ = this, data_labels = $$.config.data_labels, format = function (v) { return isValue(v) ? +v : ""; }; // find format according to axis id if (data_labels.format) { @@ -5335,7 +5182,7 @@ }; c3_chart_internal_fn.classTarget = function (id) { var $$ = this; - var additionalClassSuffix = $$.config[__data_classes][id], additionalClass = ''; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; if (additionalClassSuffix) { additionalClass = ' ' + CLASS[_target] + '-' + additionalClassSuffix; } @@ -5514,7 +5361,7 @@ }; c3_chart_fn.zoom.enable = function (enabled) { var $$ = this.internal; - $$.config[__zoom_enabled] = enabled; + $$.config.zoom_enabled = enabled; $$.updateAndRedraw(); }; c3_chart_fn.unzoom = function () { @@ -5532,12 +5379,12 @@ // update classes if exists if ('classes' in args) { Object.keys(args.classes).forEach(function (id) { - config[__data_classes][id] = args.classes[id]; + config.data_classes[id] = args.classes[id]; }); } // update categories if exists if ('categories' in args && $$.isCategorized()) { - config[__axis_x_categories] = args.categories; + config.axis_x_categories = args.categories; } // use cache if exists if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { @@ -5696,7 +5543,7 @@ flow: { index: baseValue.index, length: length, - duration: isValue(args.duration) ? args.duration : $$.config[__transition_duration], + duration: isValue(args.duration) ? args.duration : $$.config.transition_duration, done: args.done, orgDataCount: orgDataCount, }, @@ -5809,10 +5656,10 @@ xgridLines .attr('transform', null); xgridLines.select('line') - .attr("x1", config[__axis_rotated] ? 0 : xv) - .attr("x2", config[__axis_rotated] ? $$.width : xv); + .attr("x1", config.axis_rotated ? 0 : xv) + .attr("x2", config.axis_rotated ? $$.width : xv); xgridLines.select('text') - .attr("x", config[__axis_rotated] ? $$.width : 0) + .attr("x", config.axis_rotated ? $$.width : 0) .attr("y", xv); mainBar .attr('transform', null) @@ -5855,10 +5702,10 @@ }; c3_chart_fn.select = function (ids, indices, resetOther) { var $$ = this.internal, d3 = $$.d3, config = $$.config; - if (! config[__data_selection_enabled]) { return; } + if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), - isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0, + isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS[_SELECTED]); // line/area selection not supported yet @@ -5866,7 +5713,7 @@ return; } if (isTargetId && isTargetIndex) { - if (config[__data_selection_isselectable](d) && !isSelected) { + if (config.data_selection_isselectable(d) && !isSelected) { toggle(true, shape.classed(CLASS[_SELECTED], true), d, i); } } else if (isDefined(resetOther) && resetOther) { @@ -5878,10 +5725,10 @@ }; c3_chart_fn.unselect = function (ids, indices) { var $$ = this.internal, d3 = $$.d3, config = $$.config; - if (! config[__data_selection_enabled]) { return; } + if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), - isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0, + isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS[_SELECTED]); // line/area selection not supported yet @@ -5889,7 +5736,7 @@ return; } if (isTargetId && isTargetIndex) { - if (config[__data_selection_isselectable](d)) { + if (config.data_selection_isselectable(d)) { if (isSelected) { toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); } @@ -5916,22 +5763,22 @@ c3_chart_fn.groups = function (groups) { var $$ = this.internal, config = $$.config; - if (isUndefined(groups)) { return config[__data_groups]; } - config[__data_groups] = groups; + if (isUndefined(groups)) { return config.data_groups; } + config.data_groups = groups; $$.redraw(); - return config[__data_groups]; + return config.data_groups; }; c3_chart_fn.xgrids = function (grids) { var $$ = this.internal, config = $$.config; - if (! grids) { return config[__grid_x_lines]; } - config[__grid_x_lines] = grids; + if (! grids) { return config.grid_x_lines; } + config.grid_x_lines = grids; $$.redraw(); - return config[__grid_x_lines]; + return config.grid_x_lines; }; c3_chart_fn.xgrids.add = function (grids) { var $$ = this.internal; - return this.xgrids($$.config[__grid_x_lines].concat(grids ? grids : [])); + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); }; c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple var $$ = this.internal; @@ -5940,14 +5787,14 @@ c3_chart_fn.ygrids = function (grids) { var $$ = this.internal, config = $$.config; - if (! grids) { return config[__grid_y_lines]; } - config[__grid_y_lines] = grids; + if (! grids) { return config.grid_y_lines; } + config.grid_y_lines = grids; $$.redraw(); - return config[__grid_y_lines]; + return config.grid_y_lines; }; c3_chart_fn.ygrids.add = function (grids) { var $$ = this.internal; - return this.ygrids($$.config[__grid_y_lines].concat(grids ? grids : [])); + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); }; c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple var $$ = this.internal; @@ -5956,24 +5803,24 @@ c3_chart_fn.regions = function (regions) { var $$ = this.internal, config = $$.config; - if (!regions) { return config[__regions]; } - config[__regions] = regions; + if (!regions) { return config.regions; } + config.regions = regions; $$.redraw(); - return config[__regions]; + return config.regions; }; c3_chart_fn.regions.add = function (regions) { var $$ = this.internal, config = $$.config; - if (!regions) { return config[__regions]; } - config[__regions] = config[__regions].concat(regions); + if (!regions) { return config.regions; } + config.regions = config.regions.concat(regions); $$.redraw(); - return config[__regions]; + return config.regions; }; c3_chart_fn.regions.remove = function (options) { var $$ = this.internal, config = $$.config, duration, classes, regions; options = options || {}; - duration = $$.getOption(options, "duration", config[__transition_duration]); + duration = $$.getOption(options, "duration", config.transition_duration); classes = $$.getOption(options, "classes", [CLASS[_region]]); regions = $$.main.select('.' + CLASS[_regions]).selectAll(classes.map(function (c) { return '.' + c; })); @@ -5981,7 +5828,7 @@ .style('opacity', 0) .remove(); - config[__regions] = config[__regions].filter(function (region) { + config.regions = config.regions.filter(function (region) { var found = false; if (!region.class) { return true; @@ -5992,7 +5839,7 @@ return !found; }); - return config[__regions]; + return config.regions; }; c3_chart_fn.data = function () {}; @@ -6006,37 +5853,37 @@ }; c3_chart_fn.data.names = function (names) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__data_names]; } + if (!arguments.length) { return config.data_names; } Object.keys(names).forEach(function (id) { - config[__data_names][id] = names[id]; + config.data_names[id] = names[id]; }); $$.redraw({withLegend: true}); - return config[__data_names]; + return config.data_names; }; c3_chart_fn.data.colors = function (colors) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__data_colors]; } + if (!arguments.length) { return config.data_colors; } Object.keys(colors).forEach(function (id) { - config[__data_colors][id] = colors[id]; + config.data_colors[id] = colors[id]; }); $$.redraw({withLegend: true}); - return config[__data_colors]; + return config.data_colors; }; c3_chart_fn.category = function (i, category) { var $$ = this.internal, config = $$.config; if (arguments.length > 1) { - config[__axis_x_categories][i] = category; + config.axis_x_categories[i] = category; $$.redraw(); } - return config[__axis_x_categories][i]; + return config.axis_x_categories[i]; }; c3_chart_fn.categories = function (categories) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__axis_x_categories]; } - config[__axis_x_categories] = categories; + if (!arguments.length) { return config.axis_x_categories; } + config.axis_x_categories = categories; $$.redraw(); - return config[__axis_x_categories]; + return config.axis_x_categories; }; // TODO: fix @@ -6077,11 +5924,11 @@ var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof max === 'object') { - if (isValue(max.x)) { config[__axis_x_max] = max.x; } - if (isValue(max.y)) { config[__axis_y_max] = max.y; } - if (isValue(max.y2)) { config[__axis_y2_max] = max.y2; } + if (isValue(max.x)) { config.axis_x_max = max.x; } + if (isValue(max.y)) { config.axis_y_max = max.y; } + if (isValue(max.y2)) { config.axis_y2_max = max.y2; } } else { - config[__axis_y_max] = config[__axis_y2_max] = max; + config.axis_y_max = config.axis_y2_max = max; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } @@ -6090,11 +5937,11 @@ var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof min === 'object') { - if (isValue(min.x)) { config[__axis_x_min] = min.x; } - if (isValue(min.y)) { config[__axis_y_min] = min.y; } - if (isValue(min.y2)) { config[__axis_y2_min] = min.y2; } + if (isValue(min.x)) { config.axis_x_min = min.x; } + if (isValue(min.y)) { config.axis_y_min = min.y; } + if (isValue(min.y2)) { config.axis_y2_min = min.y2; } } else { - config[__axis_y_min] = config[__axis_y2_min] = min; + config.axis_y_min = config.axis_y2_min = min; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } @@ -6120,8 +5967,8 @@ c3_chart_fn.resize = function (size) { var $$ = this.internal, config = $$.config; - config[__size_width] = size ? size.width : null; - config[__size_height] = size ? size.height : null; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; this.flush(); }; diff --git a/c3.min.js b/c3.min.js index b9df0ff..95a879e 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,4 +1,4 @@ -!function(a){"use strict";function b(a){var b=this.internal=new c(this);b.loadConfig(a),b.init(),function d(a,b,c){for(var e in a)b[e]=a[e].bind(c),Object.keys(a[e]).length>0&&d(a[e],b[e],c)}(e,this,this)}function c(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function d(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0&&C.select(this).style("display",b%z?"none":"block")})}else A.svg.selectAll("."+pe[_d]+" .tick text").style("display","block");!D[vb]&&D[Hb]&&A.rotateTickText(A.axes.x,b.axisX,D[Hb]),l=A.generateDrawArea?A.generateDrawArea(E,!1):void 0,m=A.generateDrawBar?A.generateDrawBar(F):void 0,n=A.generateDrawLine?A.generateDrawLine(G,!1):void 0,o=A.generateXYForText(F,!0),p=A.generateXYForText(F,!1),A.subY.domain(A.y.domain()),A.subY2.domain(A.y2.domain()),A.tooltip.style("display","none"),A.updateXgridFocus(),B.select("text."+pe[Nd]+"."+pe[Md]).attr("x",A.width/2).attr("y",A.height/2).text(D[fb]).transition().style("opacity",I.length?0:1),A.redrawGrid(q,c),A.redrawRegion(q),A.redrawBar(r),A.redrawLine(r),A.redrawArea(r),D[mc]&&A.redrawCircle(),A.hasDataLabel()&&A.redrawText(r),A.redrawArc&&A.redrawArc(q,r,h),A.redrawSubchart&&A.redrawSubchart(d,b,q,r,E,F,G),B.selectAll("."+pe[od]).filter(A.isBarType.bind(A)).selectAll("circle").remove(),D[s]&&A.redrawEventRect(),C.transition().duration(q).each(function(){var b=[];A.addTransitionForBar(b,m),A.addTransitionForLine(b,n),A.addTransitionForArea(b,l),A.addTransitionForCircle(b,K,L),A.addTransitionForText(b,o,p,a.flow),A.addTransitionForRegion(b),A.addTransitionForGrid(b),a.flow&&(u=A.generateWait(),b.forEach(function(a){u.add(a)}),v=A.generateFlow({targets:I,flow:a.flow,duration:q,drawBar:m,drawLine:n,drawArea:l,cx:K,cy:L,xv:J,xForText:o,yForText:p}))}).call(u||function(){},v||function(){}),A.mapToIds(A.data.targets).forEach(function(a){A.withoutFadeIn[a]=!0}),A.updateZoom&&A.updateZoom()},f.updateAndRedraw=function(a){var b,c=this,d=c.config;a=a||{},a.withTransition=Ae(a,"withTransition",!0),a.withTransform=Ae(a,"withTransform",!1),a.withLegend=Ae(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=Ae(a,"withTransitionForTransform",a.withTransition),c.updateSizes(),a.withLegend&&d[lb]||(b=c.generateAxisTransitions(a.withTransitionForAxis?d[x]:0),c.updateScales(),c.updateSvgSize(),c.transformAll(a.withTransitionForTransform,b)),c.redraw(a,b)},f.isTimeSeries=function(){return"timeseries"===this.config[xb]},f.isCategorized=function(){return this.config[xb].indexOf("categor")>=0},f.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b[y]||ze(b[z]))},f.getTranslate=function(a){var b,c,d=this,e=d.config;return"main"===a?(b=we(d.margin.left),c=we(d.margin.top)):"context"===a?(b=we(d.margin2.left),c=we(d.margin2.top)):"legend"===a?(b=d.margin3.left,c=d.margin3.top):"x"===a?(b=0,c=e[vb]?0:d.height):"y"===a?(b=0,c=e[vb]?d.height:0):"y2"===a?(b=e[vb]?0:d.width,c=e[vb]?1:0):"subx"===a?(b=0,c=e[vb]?0:d.height2):"arc"===a&&(b=d.arcWidth/2,c=d.arcHeight/2),"translate("+b+","+c+")"},f.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},f.opacityForCircle=function(a){var b=this;return qe(a.value)?b.isScatterType(a)?.5:1:0},f.opacityForText=function(){return this.hasDataLabel()?1:0},f.xx=function(a){return a?this.x(a.x):null},f.xv=function(a){var b=this;return Math.ceil(b.x(b.isTimeSeries()?b.parseDate(a.value):a.value))},f.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},f.subxx=function(a){return a?this.subX(a.x):null},f.transformMain=function(a,b){var c,d,e,f=this;b&&b.axisX?c=b.axisX:(c=f.main.select("."+pe[_d]),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=f.main.select("."+pe[be]),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=f.main.select("."+pe[de]),a&&(e=e.transition())),(a?f.main.transition():f.main).attr("transform",f.getTranslate("main")),c.attr("transform",f.getTranslate("x")),d.attr("transform",f.getTranslate("y")),e.attr("transform",f.getTranslate("y2")),f.main.select("."+pe[hd]).attr("transform",f.getTranslate("arc"))},f.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config[gb]&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},f.updateSvgSize=function(){var a=this;a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.select("#"+a.clipId).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("."+pe[td]).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},f.updateDimension=function(){var a=this;a.config[vb]?(a.axes.x.call(a.xAxis),a.axes.subx.call(a.subXAxis)):(a.axes.y.call(a.yAxis),a.axes.y2.call(a.y2Axis)),a.updateSizes(),a.updateScales(),a.updateSvgSize(),a.transformAll(!1)},f.observeInserted=function(b){var c=this,d=new MutationObserver(function(e){e.forEach(function(e){if("childList"===e.type&&e.previousSibling){d.disconnect();var f=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(f),c.updateDimension(),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});d.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})},f.generateResize=function(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a},f.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},f.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},f.parseDate=function(b){var c,d=this;return c=b instanceof Date?b:"number"==typeof b?new Date(b):d.dataTimeFormat(d.config[A]).parse(b),(!c||isNaN(+c))&&a.console.error("Failed to parse x '"+b+"' to Date object"),c};var h="bindto",i="size_width",j="size_height",k="padding_left",l="padding_right",m="padding_top",n="padding_bottom",o="zoom_enabled",p="zoom_extent",q="zoom_privileged",r="zoom_onzoom",s="interaction_enabled",t="onmouseover",u="onmouseout",v="onresize",w="onresized",x="transition_duration",y="data_x",z="data_xs",A="data_xFormat",B="data_xLocaltime",C="data_idConverter",D="data_names",E="data_classes",F="data_groups",G="data_axes",H="data_type",I="data_types",J="data_labels",K="data_order",L="data_regions",M="data_color",N="data_colors",O="data_hide",P="data_filter",Q="data_selection_enabled",R="data_selection_grouped",S="data_selection_isselectable",T="data_selection_multiple",U="data_onclick",V="data_onmouseover",W="data_onmouseout",X="data_onselected",Y="data_onunselected",Z="data_ondragstart",$="data_ondragend",_="data_url",ab="data_json",bb="data_rows",cb="data_columns",db="data_mimeType",eb="data_keys",fb="data_empty_label_text",gb="subchart_show",hb="subchart_size_height",ib="subchart_onbrush",jb="color_pattern",kb="color_threshold",lb="legend_show",mb="legend_position",nb="legend_inset_anchor",ob="legend_inset_x",pb="legend_inset_y",qb="legend_inset_step",rb="legend_item_onclick",sb="legend_item_onmouseover",tb="legend_item_onmouseout",ub="legend_equally",vb="axis_rotated",wb="axis_x_show",xb="axis_x_type",yb="axis_x_localtime",zb="axis_x_categories",Ab="axis_x_tick_centered",Bb="axis_x_tick_format",Cb="axis_x_tick_culling",Db="axis_x_tick_culling_max",Eb="axis_x_tick_count",Fb="axis_x_tick_fit",Gb="axis_x_tick_values",Hb="axis_x_tick_rotate",Ib="axis_x_tick_outer",Jb="axis_x_max",Kb="axis_x_min",Lb="axis_x_padding",Mb="axis_x_height",Nb="axis_x_default",Ob="axis_x_label",Pb="axis_y_show",Qb="axis_y_max",Rb="axis_y_min",Sb="axis_y_center",Tb="axis_y_label",Ub="axis_y_tick_format",Vb="axis_y_tick_outer",Wb="axis_y_padding",Xb="axis_y_ticks",Yb="axis_y2_show",Zb="axis_y2_max",$b="axis_y2_min",_b="axis_y2_center",ac="axis_y2_label",bc="axis_y2_tick_format",cc="axis_y2_tick_outer",dc="axis_y2_padding",ec="axis_y2_ticks",fc="grid_x_show",gc="grid_x_type",hc="grid_x_lines",ic="grid_y_show",jc="grid_y_lines",kc="grid_y_ticks",lc="grid_focus_show",mc="point_show",nc="point_r",oc="point_focus_expand_enabled",pc="point_focus_expand_r",qc="point_select_r",rc="line_connect_null",sc="bar_width",tc="bar_width_ratio",uc="bar_width_max",vc="bar_zerobased",wc="area_zerobased",xc="pie_label_show",yc="pie_label_format",zc="pie_label_threshold",Ac="pie_sort",Bc="pie_expand",Cc="gauge_label_show",Dc="gauge_label_format",Ec="gauge_expand",Fc="gauge_min",Gc="gauge_max",Hc="gauge_units",Ic="gauge_width",Jc="donut_label_show",Kc="donut_label_format",Lc="donut_label_threshold",Mc="donut_width",Nc="donut_sort",Oc="donut_expand",Pc="donut_title",Qc="regions",Rc="tooltip_show",Sc="tooltip_grouped",Tc="tooltip_format_title",Uc="tooltip_format_name",Vc="tooltip_format_value",Wc="tooltip_contents",Xc="tooltip_init_show",Yc="tooltip_init_x",Zc="tooltip_init_position";f.getDefaultConfig=function(){var a={};return a[h]="#chart",a[i]=void 0,a[j]=void 0,a[k]=void 0,a[l]=void 0,a[m]=void 0,a[n]=void 0,a[o]=!1,a[p]=void 0,a[q]=!1,a[r]=function(){},a[s]=!0,a[t]=function(){},a[u]=function(){},a[v]=function(){},a[w]=function(){},a[x]=350,a[y]=void 0,a[z]={},a[A]="%Y-%m-%d",a[B]=!0,a[C]=function(a){return a},a[D]={},a[E]={},a[F]=[],a[G]={},a[H]=void 0,a[I]={},a[J]={},a[K]="desc",a[L]={},a[M]=void 0,a[N]={},a[O]=!1,a[P]=void 0,a[Q]=!1,a[R]=!1,a[S]=function(){return!0},a[T]=!0,a[U]=function(){},a[V]=function(){},a[W]=function(){},a[X]=function(){},a[Y]=function(){},a[Z]=function(){},a[$]=function(){},a[_]=void 0,a[ab]=void 0,a[bb]=void 0,a[cb]=void 0,a[db]=void 0,a[eb]=void 0,a[fb]="",a[gb]=!1,a[hb]=60,a[ib]=function(){},a[jb]=[],a[kb]={},a[lb]=!0,a[mb]="bottom",a[nb]="top-left",a[ob]=10,a[pb]=0,a[qb]=void 0,a[rb]=void 0,a[sb]=void 0,a[tb]=void 0,a[ub]=!1,a[vb]=!1,a[wb]=!0,a[xb]="indexed",a[yb]=!0,a[zb]=[],a[Ab]=!1,a[Bb]=void 0,a[Cb]={},a[Db]=10,a[Eb]=void 0,a[Fb]=!0,a[Gb]=null,a[Hb]=void 0,a[Ib]=!0,a[Jb]=null,a[Kb]=null,a[Lb]={},a[Mb]=void 0,a[Nb]=void 0,a[Ob]={},a[Pb]=!0,a[Qb]=void 0,a[Rb]=void 0,a[Sb]=void 0,a[Tb]={},a[Ub]=void 0,a[Vb]=!0,a[Wb]=void 0,a[Xb]=10,a[Yb]=!1,a[Zb]=void 0,a[$b]=void 0,a[_b]=void 0,a[ac]={},a[bc]=void 0,a[cc]=!0,a[dc]=void 0,a[ec]=10,a[fc]=!1,a[gc]="tick",a[hc]=[],a[ic]=!1,a[jc]=[],a[kc]=10,a[lc]=!0,a[mc]=!0,a[nc]=2.5,a[oc]=!0,a[pc]=void 0,a[qc]=void 0,a[rc]=!1,a[sc]=void 0,a[tc]=.6,a[uc]=void 0,a[vc]=!0,a[wc]=!0,a[xc]=!0,a[yc]=void 0,a[zc]=.05,a[Ac]=!0,a[Bc]=!0,a[Cc]=!0,a[Dc]=void 0,a[Ec]=!0,a[Fc]=0,a[Gc]=100,a[Hc]=void 0,a[Ic]=void 0,a[Jc]=!0,a[Kc]=void 0,a[Lc]=.05,a[Mc]=void 0,a[Nc]=!0,a[Oc]=!0,a[Pc]="",a[Qc]=[],a[Rc]=!0,a[Sc]=!0,a[Tc]=void 0,a[Uc]=void 0,a[Vc]=void 0,a[Wc]=function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},a[Xc]=!1,a[Yc]=0,a[Zc]={top:"0px",left:"50px"},Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},f.additionalConfig={},f.loadConfig=function(a){function b(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],b()):a?void 0:c}var c,d,e,f=this.config;Object.keys(f).forEach(function(g){c=a,d=g.split("_"),e=b(),ue(e)&&(f[g]=e)})},f.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},f.getX=function(a,b,c,d){var e,f=this,g=f.getScale(a,b,f.isTimeSeries()),h=c?g.domain(c):g;f.isCategorized()?(d=d||function(){return 0},g=function(a,b){var c=h(a)+d(a);return b?c:Math.ceil(c)}):g=function(a,b){var c=h(a);return b?c:Math.ceil(c)};for(e in h)g[e]=h[e];return g.orgDomain=function(){return h.domain()},f.isCategorized()&&(g.domain=function(a){return arguments.length?(h.domain(a),g):(a=this.orgDomain(),[a[0],a[1]+1])}),g},f.getY=function(a,b,c){var d=this.getScale(a,b);return c&&d.domain(c),d},f.getYScale=function(a){return"y2"===this.getAxisId(a)?this.y2:this.y},f.getSubYScale=function(a){return"y2"===this.getAxisId(a)?this.subY2:this.subY},f.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b[vb]?1:0,a.xMax=b[vb]?a.height:a.width,a.yMin=b[vb]?0:a.height,a.yMax=b[vb]?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b[vb]?0:a.height2,a.subYMax=b[vb]?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?void 0:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?void 0:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY2.domain()),a.xAxisTickFormat=a.getXAxisTickFormat(),a.xAxisTickValues=b[Gb]?b[Gb]:c?void 0:a.xAxis.tickValues(),a.xAxis=a.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues),a.subXAxis=a.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues),a.yAxis=a.getYAxis(a.y,a.yOrient,b[Ub],b[Xb]),a.y2Axis=a.getYAxis(a.y2,a.y2Orient,b[bc],b[ec]),c||(a.brush&&a.brush.scale(a.subX),b[o]&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},f.getYDomainMin=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i[F].length>0)for(g=h.hasNegativeValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=0>a?a:0}),c=1;c0||(k[d][b]+=+a)});return h.d3.min(Object.keys(k).map(function(a){return h.d3.min(k[a])}))},f.getYDomainMax=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i[F].length>0)for(g=h.hasPositiveValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=a>0?a:0}),c=1;c+a||(k[d][b]+=+a)});return h.d3.max(Object.keys(k).map(function(a){return h.d3.max(k[a])}))},f.getYDomain=function(a,b){var c,d,e,f,g,h,i,j,k,l,m=this,n=m.config,o=a.filter(function(a){return m.getAxisId(a.id)===b}),p="y2"===b?n[$b]:n[Rb],q="y2"===b?n[Zb]:n[Qb],r=qe(p)?p:m.getYDomainMin(o),s=qe(q)?q:m.getYDomainMax(o),t="y2"===b?n[_b]:n[Sb],u=m.hasType("bar",o)&&n[vc]||m.hasType("area",o)&&n[wc],v=m.hasDataLabel()&&n[vb],w=m.hasDataLabel()&&!n[vb];return 0===o.length?"y2"===b?m.y2.domain():m.y.domain():(r===s&&(0>r?s=0:r=0),k=r>=0&&s>=0,l=0>=r&&0>=s,u&&(k&&(r=0),l&&(s=0)),c=Math.abs(s-r),d=e=f=.1*c,t&&(g=Math.max(Math.abs(r),Math.abs(s)),s=g-t,r=t-g),v?(h=m.getDataLabelLength(r,s,b,"width"),i=xe(m.y.range()),j=[h[0]/i,h[1]/i],e+=c*(j[1]/(1-j[0]-j[1])),f+=c*(j[0]/(1-j[0]-j[1]))):w&&(h=m.getDataLabelLength(r,s,b,"height"),e+=h[1],f+=h[0]),"y"===b&&n[Wb]&&(e=m.getAxisPadding(n[Wb],"top",d,c),f=m.getAxisPadding(n[Wb],"bottom",d,c)),"y2"===b&&n[dc]&&(e=m.getAxisPadding(n[dc],"top",d,c),f=m.getAxisPadding(n[dc],"bottom",d,c)),u&&(k&&(f=r),l&&(e=-s)),[r-f,s+e])},f.getXDomainMin=function(a){var b=this,c=b.config;return c[Kb]?b.isTimeSeries()?this.parseDate(c[Kb]):c[Kb]:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},f.getXDomainMax=function(a){var b=this,c=b.config;return c[Jb]?b.isTimeSeries()?this.parseDate(c[Jb]):c[Jb]:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},f.getXDomainPadding=function(a){var b,c,d,e,f=this,g=f.config,h=this.getEdgeX(a),i=h[1]-h[0];return f.isCategorized()?c=0:f.hasType("bar",a)?(b=f.getMaxDataCount(),c=b>1?i/(b-1)/2:.5):c=.01*i,"object"==typeof g[Lb]&&ze(g[Lb])?(d=qe(g[Lb].left)?g[Lb].left:c,e=qe(g[Lb].right)?g[Lb].right:c):d=e="number"==typeof g[Lb]?g[Lb]:c,{left:d,right:e}},f.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(a),g=0,h=0;return d-e!==0||b.isCategorized()||(d=b.isTimeSeries()?new Date(.5*d.getTime()):-.5,e=b.isTimeSeries()?new Date(1.5*e.getTime()):.5),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},f.updateXDomain=function(a,b,c,d){var e=this,f=e.config;return c&&(e.x.domain(d?d:e.d3.extent(e.getXDomain(a))),e.orgXDomain=e.x.domain(),f[o]&&e.zoom.scale(e.x).updateScaleExtent(),e.subX.domain(e.x.domain()),e.brush&&e.brush.scale(e.subX)),b&&(e.x.domain(d?d:!e.brush||e.brush.empty()?e.orgXDomain:e.brush.extent()),f[o]&&e.zoom.scale(e.x).updateScaleExtent()),e.x.domain()},f.isX=function(a){var b=this,c=b.config;return c[y]&&a===c[y]||ze(c[z])&&Be(c[z],a)},f.isNotX=function(a){return!this.isX(a)},f.getXKey=function(a){var b=this,c=b.config;return c[y]?c[y]:ze(c[z])?c[z][a]:null},f.getXValuesOfXKey=function(a,b){var c,d=this,e=b&&ze(b)?d.mapToIds(b):[];return e.forEach(function(b){d.getXKey(b)===a&&(c=d.data.xs[b])}),c},f.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&qe(c.data.xs[a][b])?c.data.xs[a][b]:b},f.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},f.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a1},f.isMultipleX=function(){var a=this,b=a.config;return ze(b[z])&&a.hasMultipleX(b[z])},f.addName=function(a){var b,c=this;return a&&(b=c.config[D][a.id],a.name=b?b:a.id),a},f.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},f.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},f.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},f.generateTargetX=function(a,b,c){var d,e=this;return d=e.isTimeSeries()?e.parseDate(a?a:e.getXValue(b,c)):e.isCustomX()&&!e.isCategorized()?qe(a)?+a:e.getXValue(b,c):c},f.cloneTarget=function(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}},f.getPrevX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a-1);return c?c.x:null},f.getNextX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a+1);return c?c.x:null},f.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},f.getMaxDataCountTarget=function(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b},f.getEdgeX=function(a){var b,c,d=this.getMaxDataCountTarget(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]},f.mapToIds=function(a){return a.map(function(a){return a.id})},f.mapToTargetIds=function(a){var b=this;return a?se(a)?[a]:a:b.mapToIds(b.data.targets)},f.hasTarget=function(a,b){var c,d=this.mapToIds(a);for(c=0;ca})},f.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},f.isOrderDesc=function(){var a=this.config;return a[K]&&"desc"===a[K].toLowerCase()},f.isOrderAsc=function(){var a=this.config;return a[K]&&"asc"===a[K].toLowerCase()},f.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value) -},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):re(c[K])&&a.sort(c[K]),a},f.filterSameX=function(a,b){return this.d3.merge(a.map(function(a){return a.values})).filter(function(a){return a.x-b===0})},f.filterRemoveNull=function(a){return a.filter(function(a){return qe(a.value)})},f.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a[J]&&a[J]?!0:"object"==typeof a[J]&&ze(a[J])?!0:!1},f.getDataLabelLength=function(a,b,c,d){var e=this,f=[0,0],g=1.3;return e.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return e.formatByAxisId(c)(a)}).each(function(a,b){f[b]=this.getBoundingClientRect()[d]*g}).remove(),f},f.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},f.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},f.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?h=i:g=i,h-g===1||0===g&&0===h?(e=[],(a[g].x||0===a[g].x)&&(e=e.concat(f.findSameXOfValues(a,g))),(a[h].x||0===a[h].x)&&(e=e.concat(f.findSameXOfValues(a,h))),f.findClosest(e,b)):f.findClosestOfValues(a,b,g,h)},f.findClosestFromTargets=function(a,b){var c,d=this;return c=a.map(function(a){return d.findClosestOfValues(a.values,b)}),d.findClosest(c,b)},f.findClosest=function(a,b){var c,d,e=this;return a.forEach(function(a){var f=e.dist(a,b);(c>f||!c)&&(c=f,d=a)}),d},f.dist=function(a,b){var c=this,d=c.config,e="y"===c.getAxisId(a.id)?c.y:c.y2,f=d[vb]?1:0,g=d[vb]?0:1;return Math.pow(c.x(a.x)-b[f],2)+Math.pow(e(a.value)-b[g],2)},f.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):e.convertCsvToData(b.response),d.call(e,g)})},f.convertCsvToData=function(a){var b,c=this.d3,d=c.csv.parseRows(a);return 1===d.length?(b=[{}],d[0].forEach(function(a){b[0][a]=null})):b=c.csv.parse(a),b},f.convertJsonToData=function(a,b){var c,d,e=this,f=[];return b?(c=b.value,b.x&&(c.push(b.x),e.config[y]=b.x),f.push(c),a.forEach(function(a){var b=[];c.forEach(function(c){var d=te(a[c])?null:a[c];b.push(d)}),f.push(b)}),d=e.convertRowsToData(f)):(Object.keys(a).forEach(function(b){f.push([b].concat(a[b]))}),d=e.convertColumnsToData(f)),d},f.convertRowsToData=function(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?d.data.xs[c]=(b&&d.data.xs[c]?d.data.xs[c]:[]).concat(a.map(function(a){return a[f]}).filter(qe).map(function(a,b){return d.generateTargetX(a,c,b)})):e[y]?d.data.xs[c]=d.getOtherTargetXs():ze(e[z])&&(d.data.xs[c]=d.getXValuesOfXKey(f,d.data.targets)):d.data.xs[c]=a.map(function(a,b){return b})}),f.forEach(function(a){if(!d.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=f.map(function(b,c){var f=e[C](b);return{id:f,id_org:b,values:a.map(function(a,g){var h=d.getXKey(b),i=a[h],j=d.generateTargetX(i,b,g);return d.isCustomX()&&d.isCategorized()&&0===c&&i&&(0===g&&(e[zb]=[]),e[zb].push(i)),(te(a[b])||d.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return ue(a.x)})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++}),d.data.xs[a.id].sort(function(a,b){return a-b})}),e[H]&&d.setTargetType(d.mapToIds(c).filter(function(a){return!(a in e[I])}),e[H]),c.forEach(function(a){d.addCache(a.id_org,a)}),c},f.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){c.setTargetType(a.id,b.types?b.types[a.id]:b.type)}),c.data.targets.forEach(function(b){for(var c=0;ce?0:e},g=function(a){var b=h.getPrevX(a.index),c=h.data.xs[a.id][a.index];return(h.x(c)+h.x(b?b:c))/2}),b=i[vb]?0:g,c=i[vb]?g:0,d=i[vb]?h.width:f,e=i[vb]?f:h.height),a.attr("class",h.classEvent.bind(h)).attr("x",b).attr("y",c).attr("width",d).attr("height",e)},f.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d[Q]&&d[R]?"pointer":null).on("mouseover",function(a){var c,e,f=a.index;b.dragging||b.hasArcType()||(c=b.data.targets.map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),e=[],Object.keys(d[D]).forEach(function(a){for(var b=0;b0?c:320},f.getCurrentPaddingTop=function(){var a=this.config;return qe(a[m])?a[m]:0},f.getCurrentPaddingBottom=function(){var a=this.config;return qe(a[n])?a[n]:0},f.getCurrentPaddingLeft=function(){var a=this,b=a.config;return qe(b[k])?b[k]:b[vb]?b[wb]?Math.max(ve(a.getAxisWidthByAxisId("x")),40):1:b[Pb]?ve(a.getAxisWidthByAxisId("y")):1},f.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return qe(b[l])?b[l]+1:b[vb]?c+d:(b[Yb]?ve(a.getAxisWidthByAxisId("y2")):c)+d},f.getParentRectValue=function(a){for(var b,c=this.selectChart.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b},f.getParentWidth=function(){return this.getParentRectValue("width")},f.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},f.getSvgLeft=function(){var a=this,b=a.config,c=b[vb]?pe[_d]:pe[be],d=a.main.select("."+c).node(),e=d?d.getBoundingClientRect():{right:0},f=a.selectChart.node().getBoundingClientRect(),g=a.hasArcType(),h=e.right-f.left-(g?0:a.getCurrentPaddingLeft());return h>0?h:0},f.getAxisWidthByAxisId=function(a){var b=this,c=b.getAxisLabelPositionById(a);return c.isInner?20+b.getMaxTickWidth(a):40+b.getMaxTickWidth(a)},f.getHorizontalAxisHeight=function(a){var b=this,c=b.config;return"x"!==a||c[wb]?"x"===a&&c[Mb]?c[Mb]:"y"!==a||c[Pb]?"y2"!==a||c[Yb]?(b.getAxisLabelPositionById(a).isInner?30:40)+("y2"===a?-10:0):b.rotated_padding_top:!c[lb]||b.isLegendRight||b.isLegendInset?1:10:0},f.getEventRectWidth=function(){var a,b,c,d,e,f,g=this,h=g.getMaxDataCountTarget(g.data.targets);return h?(a=h.values[0],b=h.values[h.values.length-1],c=g.x(b.x)-g.x(a.x),0===c?g.config[vb]?g.height:g.width:(d=g.getMaxDataCount(),e=g.hasType("bar")?(d-(g.isCategorized()?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0},f.getShapeIndices=function(a){var b,c,d=this,e=d.config,f={},g=0;return d.filterTargetsToShow(d.data.targets.filter(a,d)).forEach(function(a){for(b=0;b=0&&(j+=h(c.values[g].value)-i)}),j}},f.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?"step-after":"linear"},f.initLine=function(){var a=this,b=a.CLASS;a.main.select("."+b[_c]).append("g").attr("class",b[bd])},f.updateTargetsForLine=function(a){var b,c,d=this,e=d.config,f=d.CLASS,g=d.classChartLine.bind(d),h=d.classLines.bind(d),i=d.classAreas.bind(d),j=d.classCircles.bind(d);b=d.main.select("."+f[bd]).selectAll("."+f[ad]).data(a).attr("class",g),c=b.enter().append("g").attr("class",g).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",h),c.append("g").attr("class",i),c.append("g").attr("class",function(a){return d.generateClass(f[od],a.id)}),c.append("g").attr("class",j).style("cursor",function(a){return e[S](a)?"pointer":null}),a.forEach(function(a){d.main.selectAll("."+f[od]+d.getTargetSelectorSuffix(a.id)).selectAll("."+f[nd]).each(function(b){b.value=a.values[b.index].value})})},f.redrawLine=function(a){var b=this,c=b.CLASS;b.mainLine=b.main.selectAll("."+c[Dd]).selectAll("."+c[Cd]).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForLine=function(a,b){var c=this;a.push(c.mainLine.transition().attr("d",b).style("stroke",c.color).style("opacity",1))},f.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d[F].length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d[vb]?e.x(i).y(h):e.x(h).y(i),d[rc]||(e=e.defined(function(a){return null!=a.value})),function(a){var f,h=d[rc]?c.filterRemoveNull(a.values):a.values,i=b?c.x:c.subX,j=g.call(c,a.id),k=0,l=0;return c.isLineType(a)?f=d[L][a.id]?c.lineWithRegions(h,i,j,d[L][a.id]):e.interpolate(c.getInterpolate(a))(h):(h[0]&&(k=i(h[0].x),l=j(h[0].value)),f=d[vb]?"M "+l+" "+k:"M "+k+" "+l),f?f:"M 0 0"}},f.generateGetLinePoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d[vb]&&(0l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)]]}},f.lineWithRegions=function(a,b,c,d){function e(a,b){var c;for(c=0;c=g;g+=o)u+=h(a[f-1],a[f],g,n);t=a[f].x}return u},f.redrawArea=function(a){var b=this,c=b.CLASS,d=b.d3;b.mainArea=b.main.selectAll("."+c[Ld]).selectAll("."+c[Kd]).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+d.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForArea=function(a,b){var c=this;a.push(c.mainArea.transition().attr("d",b).style("fill",c.color).style("opacity",c.orgAreaOpacity))},f.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d[F].length>0?f(a,b)[0][1]:g.call(c,a.id)(0)},j=function(a,b){return d[F].length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d[vb]?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d[rc]||(e=e.defined(function(a){return null!==a.value})),function(a){var b,f=d[rc]?c.filterRemoveNull(a.values):a.values,g=0,h=0;return c.isAreaType(a)?b=e.interpolate(c.getInterpolate(a))(f):(f[0]&&(g=c.x(f[0].x),h=c.getYScale(a.id)(f[0].value)),b=d[vb]?"M "+h+" "+g:"M "+g+" "+h),b?b:"M 0 0"}},f.generateGetAreaPoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d[vb]&&(0l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)]]}},f.redrawCircle=function(){var a=this,b=a.CLASS;a.mainCircle=a.main.selectAll("."+b[Hd]).selectAll("."+b[Gd]).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacity.bind(a)),a.mainCircle.exit().remove()},f.addTransitionForCircle=function(a,b,c){var d=this;a.push(d.mainCircle.transition().style("opacity",d.opacityForCircle.bind(d)).style("fill",d.color).attr("cx",b).attr("cy",c)),a.push(d.main.selectAll("."+pe[nd]).transition().attr("cx",b).attr("cy",c))},f.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},f.circleY=function(a,b){var c=this,d=c.getShapeIndices(c.isLineType),e=c.generateGetLinePoint(d);return c.config[F].length>0?e(a,b)[0][1]:c.getYScale(a.id)(a.value)},f.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+pe[Hd]+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+pe[Gd]+(qe(a)?"-"+a:""))},f.expandCircles=function(a,b){var c=this,d=c.pointExpandedR.bind(c);c.getCircles(a,b).classed(pe[me],!0).attr("r",d)},f.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(pe[me])}).classed(pe[me],!1).attr("r",c)},f.pointR=function(a){var b=this,c=b.config;return c[mc]&&!b.isStepType(a)?re(c[nc])?c[nc](a):c[nc]:0},f.pointExpandedR=function(a){var b=this,c=b.config;return c[oc]?c[pc]?c[pc]:1.75*b.pointR(a):b.pointR(a)},f.pointSelectR=function(a){var b=this,c=b.config;return c[qc]?c[qc]:4*b.pointR(a)},f.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=1*e.attr("cx"),g=1*e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))d[uc]?d[uc]:e},f.getBars=function(a){var b=this;return b.main.selectAll("."+pe[Ed]+(qe(a)?"-"+a:""))},f.expandBars=function(a){var b=this;b.getBars(a).classed(pe[me],!0)},f.unexpandBars=function(a){var b=this;b.getBars(a).classed(pe[me],!1)},f.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d[vb]?1:0,g=d[vb]?0:1,h="M "+c[0][f]+","+c[0][g]+" L"+c[1][f]+","+c[1][g]+" L"+c[2][f]+","+c[2][g]+" L"+c[3][f]+","+c[3][g]+" z";return h}},f.generateGetBarPoints=function(a,b){var c=this,d=a.__max__+1,e=c.getBarW(c.xAxis,d),f=c.getShapeX(e,d,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isBarType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var d=i.call(c,a.id)(0),j=h(a,b)||d,k=f(a),l=g(a);return c.config[vb]&&(0l||a.value<0&&l>d)&&(l=d),[[k,j],[k,l-(d-j)],[k+e,l-(d-j)],[k+e,j]]}},f.isWithinBar=function(a){var b=this.d3,c=b.mouse(a),d=a.getBoundingClientRect(),e=a.pathSegList.getItem(0),f=a.pathSegList.getItem(1),g=e.x,h=Math.min(e.y,f.y),i=d.width,j=d.height,k=2,l=g-k,m=g+i+k,n=h+j+k,o=h-k;return lf.width?f.width-g.width:d},f.getYForText=function(a,b,c){var d,e=this,f=c.getBoundingClientRect();return d=e.config[vb]?(a[0][0]+a[2][0]+.6*f.height)/2:a[2][1]+(b.value<0?f.height:e.isBarType(b)?-3:-6),d=0||!(b.id in d)&&"line"===a)&&(e=!0)}),e},f.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},f.isLineType=function(a){var b=this.config,c=se(a)?a:a.id;return!b[I][c]||["line","spline","area","area-spline","step","area-step"].indexOf(b[I][c])>=0},f.isStepType=function(a){var b=se(a)?a:a.id;return["step","area-step"].indexOf(this.config[I][b])>=0},f.isSplineType=function(a){var b=se(a)?a:a.id;return["spline","area-spline"].indexOf(this.config[I][b])>=0},f.isAreaType=function(a){var b=se(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config[I][b])>=0},f.isBarType=function(a){var b=se(a)?a:a.id;return"bar"===this.config[I][b]},f.isScatterType=function(a){var b=se(a)?a:a.id;return"scatter"===this.config[I][b]},f.isPieType=function(a){var b=se(a)?a:a.id;return"pie"===this.config[I][b]},f.isGaugeType=function(a){var b=se(a)?a:a.id;return"gauge"===this.config[I][b]},f.isDonutType=function(a){var b=se(a)?a:a.id;return"donut"===this.config[I][b]},f.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},f.lineData=function(a){return this.isLineType(a)?[a]:[]},f.arcData=function(a){return this.isArcType(a.data)?[a]:[]},f.barData=function(a){return this.isBarType(a)?a.values:[]},f.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},f.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},f.initGrid=function(){var a=this,b=a.config,c=a.CLASS,d=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPath).attr("class",c[Qd]),b[fc]&&a.grid.append("g").attr("class",c[Sd]),b[ic]&&a.grid.append("g").attr("class",c[Xd]),a.grid.append("g").attr("class",c[Ud]),a.grid.append("g").attr("class",c[Zd]),b[lc]&&a.grid.append("g").attr("class",c[Vd]).append("line").attr("class",c[Vd]),a.xgrid=d.selectAll([]),a.xgridLines=d.selectAll([])},f.updateXGrid=function(a){var b=this,c=b.config,d=b.CLASS,e=b.d3,f=b.generateGridData(c[gc],b.x),g=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c[vb]?{x1:0,x2:b.width,y1:function(a){return b.x(a)-g},y2:function(a){return b.x(a)-g}}:{x1:function(a){return b.x(a)+g},x2:function(a){return b.x(a)+g},y1:0,y2:b.height},b.xgrid=b.main.select("."+d[Sd]).selectAll("."+d[Rd]).data(f),b.xgrid.enter().append("line").attr("class",d[Rd]),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+e.select(this).attr(c[vb]?"y1":"x1")===(c[vb]?b.height:0)?0:1}),b.xgrid.exit().remove()},f.updateYGrid=function(){var a=this,b=a.config,c=a.CLASS;a.ygrid=a.main.select("."+c[Xd]).selectAll("."+c[Wd]).data(a.y.ticks(b[kc])),a.ygrid.enter().append("line").attr("class",c[Wd]),a.ygrid.attr("x1",b[vb]?a.y:0).attr("x2",b[vb]?a.y:a.width).attr("y1",b[vb]?0:a.y).attr("y2",b[vb]?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},f.redrawGrid=function(a,b){var c,d,e,f=this,g=f.main,h=f.config,i=f.CLASS;g.select("line."+i[Vd]).style("visibility","hidden"),h[fc]&&f.updateXGrid(),f.xgridLines=g.select("."+i[Ud]).selectAll("."+i[Td]).data(h[hc]),c=f.xgridLines.enter().append("g").attr("class",function(a){return i[Td]+(a.class?" "+a.class:"")}),c.append("line").style("opacity",0),c.append("text").attr("text-anchor","end").attr("transform",h[vb]?"":"rotate(-90)").attr("dx",h[vb]?0:-f.margin.top).attr("dy",-5).style("opacity",0),f.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),b&&h[ic]&&f.updateYGrid(),b&&(f.ygridLines=g.select("."+i[Zd]).selectAll("."+i[Yd]).data(h[jc]),d=f.ygridLines.enter().append("g").attr("class",function(a){return i[Yd]+(a.class?" "+a.class:"")}),d.append("line").style("opacity",0),d.append("text").attr("text-anchor","end").attr("transform",h[vb]?"rotate(-90)":"").attr("dx",h[vb]?0:-f.margin.top).attr("dy",-5).style("opacity",0),e=f.yv.bind(f),f.ygridLines.select("line").transition().duration(a).attr("x1",h[vb]?e:0).attr("x2",h[vb]?e:f.width).attr("y1",h[vb]?0:e).attr("y2",h[vb]?f.height:e).style("opacity",1),f.ygridLines.select("text").transition().duration(a).attr("x",h[vb]?0:f.width).attr("y",e).text(function(a){return a.text}).style("opacity",1),f.ygridLines.exit().transition().duration(a).style("opacity",0).remove())},f.addTransitionForGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b);a.push(b.xgridLines.select("line").transition().attr("x1",c[vb]?0:d).attr("x2",c[vb]?b.width:d).attr("y1",c[vb]?d:b.margin.top).attr("y2",c[vb]?d:b.height).style("opacity",1)),a.push(b.xgridLines.select("text").transition().attr("x",c[vb]?b.width:0).attr("y",d).text(function(a){return a.text}).style("opacity",1))},f.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&qe(a.value)}),e=b.main.selectAll("line."+pe[Vd]),f=b.xx.bind(b);c[Rc]&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c[vb]?"y1":"x1",f).attr(c[vb]?"y2":"x2",f),b.smoothLines(e,"grid")))},f.hideXGridFocus=function(){this.main.select("line."+pe[Vd]).style("visibility","hidden")},f.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+pe[Vd]).attr("x1",b[vb]?0:-10).attr("x2",b[vb]?a.width:-10).attr("y1",b[vb]?-10:0).attr("y2",b[vb]?-10:a.height)},f.generateGridData=function(a,b){var c,d,e,f,g=this,h=[],i=g.main.select("."+pe[_d]).selectAll(".tick").size();if("year"===a)for(c=g.getXDomain(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h},f.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b.class===a.class)&&(c=!0)}),c}:function(){return!0}},f.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},g=b?pe[Ud]:pe[Zd],h=b?pe[Td]:pe.ygridLine;c.main.select("."+g).selectAll("."+h).filter(e).transition().duration(d[x]).style("opacity",0).remove(),b?d[hc]=d[hc].filter(f):d[jc]=d[jc].filter(f)},f.initTooltip=function(){var a,b=this,c=b.config;if(b.tooltip=b.selectChart.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),c[Xc]){if(b.isTimeSeries()&&se(c[Yc])){for(c[Yc]=b.parseDate(c[Yc]),a=0;a"+(g||0===g?""+g+"":"")),i=n(a[f].name),h=o(a[f].value,a[f].ratio,a[f].id,a[f].index),j=k.levelColor?k.levelColor(a[f].value):d(a[f].id),e+="",e+=""+i+"",e+=""+h+"",e+=""); -return e+""},f.showTooltip=function(a,b){var c,d,e,f,g,h,i,j=this,k=j.config,l=j.hasArcType(),m=a.filter(function(a){return a&&qe(a.value)});0!==m.length&&k[Rc]&&(j.tooltip.html(k[Wc].call(j,a,j.getXAxisTickFormat(),j.getYFormat(l),j.color)).style("display","block"),c=j.tooltip.property("offsetWidth"),d=j.tooltip.property("offsetHeight"),l?(f=j.width/2+b[0],h=j.height/2+b[1]+20):(k[vb]?(e=j.getSvgLeft(),f=e+b[0]+100,g=f+c,i=j.getCurrentWidth()-j.getCurrentPaddingRight(),h=j.x(m[0].x)+20):(e=j.getSvgLeft(),f=e+j.getCurrentPaddingLeft()+j.x(m[0].x)+20,g=f+c,i=e+j.getCurrentWidth()-j.getCurrentPaddingRight(),h=b[1]+15),g>i&&(f-=g-i),h+d>j.getCurrentHeight()&&h>d+30&&(h-=d+30)),j.tooltip.style("top",h+"px").style("left",f+"px"))},f.hideTooltip=function(){this.tooltip.style("display","none")},f.initLegend=function(){var a=this;a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config[lb]||(a.legend.style("visibility","hidden"),a.hiddenLegendIds=a.mapToIds(a.data.targets)),a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},f.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d[pb]+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d[pb],left:c.isLegendLeft?c.getCurrentPaddingLeft()+d[ob]+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d[ob]+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},f.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},f.updateLegendStep=function(a){this.legendStep=a},f.updateLegendItemWidth=function(a){this.legendItemWidth=a},f.updateLegendItemHeight=function(a){this.legendItemHeight=a},f.getLegendWidth=function(){var a=this;return a.config[lb]?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},f.getLegendHeight=function(){var a=this,b=a.config,c=0;return b[lb]&&(c=a.isLegendRight?a.currentHeight:a.isLegendInset?b[qb]?Math.max(20,a.legendItemHeight)*(b[qb]+1):a.height:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),c},f.opacityForLegend=function(a){var b=this;return a.classed(pe[je])?b.legendOpacityForHidden:1},f.opacityForUnfocusedLegend=function(a){var b=this;return a.classed(pe[je])?b.legendOpacityForHidden:.3},f.toggleFocusLegend=function(a,b){var c=this;c.legend.selectAll("."+pe[ge]).transition().duration(100).style("opacity",function(d){var e=c.d3.select(this);return a&&d!==a?b?c.opacityForUnfocusedLegend(e):c.opacityForLegend(e):b?c.opacityForLegend(e):c.opacityForUnfocusedLegend(e)})},f.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+pe[ge]).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},f.showLegend=function(a){var b=this,c=b.config;c[lb]||(c[lb]=!0,b.legend.style("visibility","visible")),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},f.hideLegend=function(a){var b=this,c=b.config;c[lb]&&ye(a)&&(c[lb]=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},f.updateLegend=function(a,b,c){function d(b,c,d){function e(a,b){b||(f=(l-x-k)/2,w>f&&(f=(l-k)/2,x=0,E++)),C[a]=E,B[E]=q.isLegendInset?10:f,y[a]=x,x+=k}var f,g,h=q.getTextRect(b.textContent,pe[ge]),i=10*Math.ceil((h.width+t)/10),j=10*Math.ceil((h.height+s)/10),k=q.isLegendRight||q.isLegendInset?j:i,l=q.isLegendRight||q.isLegendInset?q.getLegendHeight():q.getLegendWidth();return d&&(x=0,E=0,u=0,v=0),r[lb]&&!q.isLegendToShow(c)?void(z[c]=A[c]=C[c]=y[c]=0):(z[c]=i,A[c]=j,(!u||i>=u)&&(u=i),(!v||j>=v)&&(v=j),g=q.isLegendRight||q.isLegendInset?v:u,void(r[ub]?(Object.keys(z).forEach(function(a){z[a]=u}),Object.keys(A).forEach(function(a){A[a]=v}),f=(l-g*a.length)/2,w>f?(x=0,E=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var e,f,g,h,i,j,k,l,m,n,o,p,q=this,r=q.config,s=4,t=36,u=0,v=0,w=10,x=0,y={},z={},A={},B=[0],C={},E=0,F=q.legend.selectAll("."+pe[ke]).size();b=b||{},l=Ae(b,"withTransition",!0),m=Ae(b,"withTransitionForTransform",!0),q.isLegendRight?(e=function(a){return u*C[a]},h=function(a){return B[C[a]]+y[a]}):q.isLegendInset?(e=function(a){return u*C[a]+10},h=function(a){return B[C[a]]+y[a]}):(e=function(a){return B[C[a]]+y[a]},h=function(a){return v*C[a]}),f=function(a,b){return e(a,b)+14},i=function(a,b){return h(a,b)+9},g=function(a,b){return e(a,b)-4},j=function(a,b){return h(a,b)-7},k=q.legend.selectAll("."+pe[ge]).data(a).enter().append("g").attr("class",function(a){return q.generateClass(pe[ge],a)}).style("visibility",function(a){return q.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){r[rb]?r[rb].call(q,a):q.api.toggle(a)}).on("mouseover",function(a){q.d3.select(this).classed(pe[ke],!0),q.transiting||q.api.focus(a),r[sb]&&r[sb].call(q,a)}).on("mouseout",function(a){q.d3.select(this).classed(pe[ke],!1),q.transiting||q.api.revert(),r[tb]&&r[tb].call(q,a)}),k.append("text").text(function(a){return ue(r[D][a])?r[D][a]:a}).each(function(a,b){d(this,a,0===b)}).style("pointer-events","none").attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:i),k.append("rect").attr("class",pe[he]).style("fill-opacity",0).attr("x",q.isLegendRight||q.isLegendInset?g:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:j),k.append("rect").attr("class",pe[ie]).style("pointer-events","none").style("fill",q.color).attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:h).attr("width",10).attr("height",10),q.isLegendInset&&0!==u&&q.legend.insert("g","."+pe[ge]).attr("class",pe[fe]).append("rect").attr("height",q.getLegendHeight()-10).attr("width",u*(E+1)+10),n=q.legend.selectAll("text").data(a).text(function(a){return ue(r[D][a])?r[D][a]:a}).each(function(a,b){d(this,a,0===b)}),(l?n.transition():n).attr("x",f).attr("y",i),o=q.legend.selectAll("rect."+pe[he]).data(a),(l?o.transition():o).attr("width",function(a){return z[a]}).attr("height",function(a){return A[a]}).attr("x",g).attr("y",j),p=q.legend.selectAll("rect."+pe[ie]).data(a),(l?p.transition():p).style("fill",q.color).attr("x",e).attr("y",h),q.legend.selectAll("."+pe[ge]).classed(pe[je],function(a){return!q.isTargetToShow(a)}).transition().style("opacity",function(a){var b=q.d3.select(this);return q.isTargetToShow(a)?!F||b.classed(pe[ke])?q.opacityForLegend(b):q.opacityForUnfocusedLegend(b):q.legendOpacityForHidden}),q.updateLegendItemWidth(u),q.updateLegendItemHeight(v),q.updateLegendStep(E),q.updateSizes(),q.updateScales(),q.updateSvgSize(),q.transformAll(m,c)},f.initAxis=function(){var a=this,b=a.config,c=a.main,d=a.CLASS;a.axes.x=c.append("g").attr("class",d[$d]+" "+d[_d]).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b[wb]?"visible":"hidden"),a.axes.x.append("text").attr("class",d[ae]).attr("transform",b[vb]?"rotate(-90)":"").style("text-anchor",a.textAnchorForXAxisLabel.bind(a)),a.axes.y=c.append("g").attr("class",d[$d]+" "+d[be]).attr("clip-path",a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b[Pb]?"visible":"hidden"),a.axes.y.append("text").attr("class",d[ce]).attr("transform",b[vb]?"":"rotate(-90)").style("text-anchor",a.textAnchorForYAxisLabel.bind(a)),a.axes.y2=c.append("g").attr("class",d[$d]+" "+d[de]).attr("transform",a.getTranslate("y2")).style("visibility",b[Yb]?"visible":"hidden"),a.axes.y2.append("text").attr("class",d[ee]).attr("transform",b[vb]?"":"rotate(-90)").style("text-anchor",a.textAnchorForY2AxisLabel.bind(a))},f.getXAxis=function(a,b,c,e){var f=this,g=f.config,h=d(f.d3,f.isCategorized()).scale(a).orient(b);return h.tickFormat(c).tickValues(e),f.isCategorized()?(h.tickCentered(g[Ab]),ye(g[Cb])&&(g[Cb]=!1)):h.tickOffset=function(){var a=f.getEdgeX(f.data.targets),b=f.x(a[1])-f.x(a[0]),c=b?b:g[vb]?f.height:f.width;return c/f.getMaxDataCount()/2},h},f.getYAxis=function(a,b,c,e){return d(this.d3).scale(a).orient(b).tickFormat(c).ticks(e)},f.getAxisId=function(a){var b=this.config;return a in b[G]?b[G][a]:"y"},f.getXAxisTickFormat=function(){var a=this,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b[Bb]&&(re(b[Bb])?c=b[Bb]:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b[Bb])(c):""})),re(c)?function(b){return c.call(a,b)}:c},f.getAxisLabelOptionByAxisId=function(a){var b,c=this,d=c.config;return"y"===a?b=d[Tb]:"y2"===a?b=d[ac]:"x"===a&&(b=d[Ob]),b},f.getAxisLabelText=function(a){var b=this.getAxisLabelOptionByAxisId(a);return se(b)?b:b?b.text:null},f.setAxisLabelText=function(a,b){var c=this,d=c.config,e=c.getAxisLabelOptionByAxisId(a);se(e)?"y"===a?d[Tb]=b:"y2"===a?d[ac]=b:"x"===a&&(d[Ob]=b):e&&(e.text=b)},f.getAxisLabelPosition=function(a,b){var c=this.getAxisLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},f.getXAxisLabelPosition=function(){return this.getAxisLabelPosition("x",this.config[vb]?"inner-top":"inner-right")},f.getYAxisLabelPosition=function(){return this.getAxisLabelPosition("y",this.config[vb]?"inner-right":"inner-top")},f.getY2AxisLabelPosition=function(){return this.getAxisLabelPosition("y2",this.config[vb]?"inner-right":"inner-top")},f.getAxisLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},f.textForXAxisLabel=function(){return this.getAxisLabelText("x")},f.textForYAxisLabel=function(){return this.getAxisLabelText("y")},f.textForY2AxisLabel=function(){return this.getAxisLabelText("y2")},f.xForAxisLabel=function(a,b){var c=this;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},f.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},f.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},f.xForXAxisLabel=function(){return this.xForAxisLabel(!this.config[vb],this.getXAxisLabelPosition())},f.xForYAxisLabel=function(){return this.xForAxisLabel(this.config[vb],this.getYAxisLabelPosition())},f.xForY2AxisLabel=function(){return this.xForAxisLabel(this.config[vb],this.getY2AxisLabelPosition())},f.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.config[vb],this.getXAxisLabelPosition())},f.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.config[vb],this.getYAxisLabelPosition())},f.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.config[vb],this.getY2AxisLabelPosition())},f.dyForXAxisLabel=function(){var a=this,b=a.config,c=a.getXAxisLabelPosition();return b[vb]?c.isInner?"1.2em":-25-a.getMaxTickWidth("x"):c.isInner?"-0.5em":b[Mb]?b[Mb]-10:"3em"},f.dyForYAxisLabel=function(){var a=this,b=a.getYAxisLabelPosition();return a.config[vb]?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-20-a.getMaxTickWidth("y")},f.dyForY2AxisLabel=function(){var a=this,b=a.getY2AxisLabelPosition();return a.config[vb]?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":30+this.getMaxTickWidth("y2")},f.textAnchorForXAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(!a.config[vb],a.getXAxisLabelPosition())},f.textAnchorForYAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config[vb],a.getYAxisLabelPosition())},f.textAnchorForY2AxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config[vb],a.getY2AxisLabelPosition())},f.xForRotatedTickText=function(a){return 10*Math.sin(Math.PI*(a/180))},f.yForRotatedTickText=function(a){return 11.5-2.5*(a/15)},f.rotateTickText=function(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",this.yForRotatedTickText(c)).attr("x",this.xForRotatedTickText(c)).attr("transform","rotate("+c+")")},f.getMaxTickWidth=function(a){var b,c,d,e=this,f=e.config,g=0;return e.svg&&(b=e.filterTargetsToShow(e.data.targets),"y"===a?(c=e.y.copy().domain(e.getYDomain(b,"y")),d=e.getYAxis(c,e.yOrient,f[Ub],f[Xb])):"y2"===a?(c=e.y2.copy().domain(e.getYDomain(b,"y2")),d=e.getYAxis(c,e.y2Orient,f[bc],f[ec])):(c=e.x.copy().domain(e.getXDomain(b)),d=e.getXAxis(c,e.xOrient,e.getXAxisTickFormat(),f[Gb]?f[Gb]:e.xAxis.tickValues())),e.main.append("g").call(d).each(function(){e.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();g=g?e.currentMaxTickWidth:g,e.currentMaxTickWidth},f.updateAxisLabels=function(a){var b=this,c=b.main.select("."+pe[_d]+" ."+pe[ae]),d=b.main.select("."+pe[be]+" ."+pe[ce]),e=b.main.select("."+pe[de]+" ."+pe[ee]);(a?c.transition():c).attr("x",b.xForXAxisLabel.bind(b)).attr("dx",b.dxForXAxisLabel.bind(b)).attr("dy",b.dyForXAxisLabel.bind(b)).text(b.textForXAxisLabel.bind(b)),(a?d.transition():d).attr("x",b.xForYAxisLabel.bind(b)).attr("dx",b.dxForYAxisLabel.bind(b)).attr("dy",b.dyForYAxisLabel.bind(b)).text(b.textForYAxisLabel.bind(b)),(a?e.transition():e).attr("x",b.xForY2AxisLabel.bind(b)).attr("dx",b.dxForY2AxisLabel.bind(b)).attr("dy",b.dyForY2AxisLabel.bind(b)).text(b.textForY2AxisLabel.bind(b))},f.getAxisPadding=function(a,b,c,d){var e="ratio"===a.unit?d:1;return qe(a[b])?a[b]*e:c},f.generateTickValues=function(a,b){var c,d,e,f,g,h,i,j=this,k=a;if(b)if(c=re(b)?b():b,1===c)k=[a[0]];else if(2===c)k=[a[0],a[a.length-1]];else if(c>2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),k=[d],h=0;f>h;h++)i=+d+g*(h+1),k.push(j.isTimeSeries()?new Date(i):i);k.push(e)}return j.isTimeSeries()||(k=k.sort(function(a,b){return a-b})),k},f.generateAxisTransitions=function(a){var b=this,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},f.redrawAxis=function(a,b){var c=this;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},f.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},f.getAxisClipX=function(a){return a?-31:-(this.margin.left-1)},f.getAxisClipY=function(a){return a?-20:-4},f.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config[vb])},f.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config[vb])},f.getYAxisClipX=function(){var a=this;return a.getAxisClipX(a.config[vb])},f.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config[vb])},f.getAxisClipWidth=function(a){var b=this;return a?b.width+2+30+30:b.margin.left+20},f.getAxisClipHeight=function(a){var b=this,c=b.config;return a?(c[Mb]?c[Mb]:0)+80:b.height+8},f.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config[vb])},f.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config[vb])},f.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config[vb])},f.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config[vb])},f.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c[K]&&c[Ac]&&c[Nc]||a.pie.sort(null)},f.updateRadius=function(){var a=this,b=a.config,c=b[Ic]||b[Mc];a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},f.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},f.updateAngle=function(a){var b=this,c=b.config,d=!1,e=0;if(b.pie(b.filterTargetsToShow(b.data.targets)).sort(b.descByStartAngle).forEach(function(b){d||b.data.id!==a.data.id||(d=!0,a=b,a.index=e),e++}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),b.isGaugeType(a.data)){var f=c[Fc],g=c[Gc],h=Math.abs(f)+g,i=Math.PI/h;a.startAngle=-1*(Math.PI/2)+i*Math.abs(f),a.endAngle=a.startAngle+i*(a.value>g?g:a.value)}return d?a:null},f.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},f.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},f.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},f.transformForArcLabel=function(a){var b,c,d,e,f,g=this,h=g.updateAngle(a),i="";return h&&!g.hasType("gauge")&&(b=this.svgArc.centroid(h),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=g.radius&&e?(36/g.radius>.375?1.175-36/g.radius:.8)*g.radius/e:0,i="translate("+c*f+","+d*f+")"),i},f.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},f.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},f.textForArcLabel=function(a){var b,c,d,e,f=this;return f.shouldShowArcLabel()?(b=f.updateAngle(a),c=b?b.value:null,d=f.getArcRatio(b),f.hasType("gauge")||f.meetsArcLabelThreshold(d)?(e=f.getArcLabelFormat(),e?e(c,d):f.defaultArcValueFormat(c,d)):""):""},f.expandArc=function(a,b){var c=this,d=c.svg.selectAll("."+pe[gd]+c.selectorTarget(a)),e=c.svg.selectAll("."+pe[Id]).filter(function(b){return b.data.id!==a});c.shouldExpand(a)&&d.selectAll("path").transition().duration(50).attr("d",c.svgArcExpanded).transition().duration(100).attr("d",c.svgArcExpandedSub).each(function(a){c.isDonutType(a.data)}),b||e.style("opacity",.3)},f.unexpandArc=function(a){var b=this,c=b.svg.selectAll("."+pe[gd]+b.selectorTarget(a));c.selectAll("path."+pe[Id]).transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+pe[Id]).style("opacity",1)},f.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c[Oc]||b.isGaugeType(a)&&c[Ec]||b.isPieType(a)&&c[Bc]},f.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b[Jc]:a.hasType("pie")&&(c=b[xc]),c},f.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c[Lc]:c[zc];return a>=d},f.getArcLabelFormat=function(){var a=this,b=a.config,c=b[yc];return a.hasType("gauge")?c=b[Dc]:a.hasType("donut")&&(c=b[Kc]),c},f.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config[Pc]:""},f.descByStartAngle=function(a,b){return a.startAngle-b.startAngle},f.updateTargetsForArc=function(a){var b,c,d=this,e=d.main,f=d.classChartArc.bind(d),g=d.classArcs.bind(d);b=e.select("."+pe[hd]).selectAll("."+pe[gd]).data(d.pie(a)).attr("class",f),c=b.enter().append("g").attr("class",f),c.append("g").attr("class",g),c.append("text").attr("dy",d.hasType("gauge")?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},f.initArc=function(){var a=this;a.arcs=a.main.select("."+pe[_c]).append("g").attr("class",pe[hd]).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",pe[id]).style("text-anchor","middle").text(a.getArcTitle())},f.redrawArc=function(a,b,c){var d,e=this,f=e.d3,g=e.config,h=e.main;d=h.selectAll("."+pe[Jd]).selectAll("."+pe[Id]).data(e.arcData.bind(e)),d.enter().append("path").attr("class",e.classArc.bind(e)).style("fill",function(a){return e.color(a.data)}).style("cursor",function(a){return g[S](a)?"pointer":null}).style("opacity",0).each(function(a){e.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.expandArc(b.data.id),e.toggleFocusLegend(b.data.id,!0),e.config[V](c,this))}).on("mousemove",function(a){var b=e.updateAngle(a),c=e.convertToArcData(b),d=[c];e.showTooltip(d,f.mouse(this))}).on("mouseout",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.unexpandArc(b.data.id),e.revertLegend(),e.hideTooltip(),e.config[W](c,this))}).on("click",function(a,b){var c,d;e.toggleShape&&(c=e.updateAngle(a),d=e.convertToArcData(c),e.toggleShape(this,d,b))}),d.attr("transform",function(a){return!e.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){e.transiting=!0}).transition().duration(a).attrTween("d",function(a){var b,c=e.updateAngle(a);return c?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=f.interpolate(this._current,c),this._current=b(0),function(a){return e.getArc(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return e.levelColor?e.levelColor(a.data.values[0].value):e.color(a.data.id)}).style("opacity",1).call(e.endall,function(){e.transiting=!1}),d.exit().transition().duration(b).style("opacity",0).remove(),h.selectAll("."+pe[gd]).select("text").style("opacity",0).attr("class",function(a){return e.isGaugeType(a.data)?pe[Pd]:""}).text(e.textForArcLabel.bind(e)).attr("transform",e.transformForArcLabel.bind(e)).transition().duration(a).style("opacity",function(a){return e.isTargetToShow(a.data.id)&&e.isArcType(a.data)?1:0}),h.select("."+pe[id]).style("opacity",e.hasType("donut")||e.hasType("gauge")?1:0)},f.initGauge=function(){var a=this,b=a.config,c=a.arcs;a.hasType("gauge")&&(c.append("path").attr("class",pe[jd]).attr("d",function(){var c={data:[{value:b[Gc]}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return a.getArc(c,!0,!0)}),c.append("text").attr("dy",".75em").attr("class",pe[kd]).style("text-anchor","middle").style("pointer-events","none").text(b[Cc]?b[Hc]:""),c.append("text").attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/2)+"px").attr("dy","1.2em").attr("class",pe[md]).style("text-anchor","middle").style("pointer-events","none").text(b[Cc]?b[Fc]:""),c.append("text").attr("dx",a.innerRadius+(a.radius-a.innerRadius)/2+"px").attr("dy","1.2em").attr("class",pe[ld]).style("text-anchor","middle").style("pointer-events","none").text(b[Cc]?b[Gc]:""))},f.initRegion=function(){var a=this,b=a.CLASS;a.main.append("g").attr("clip-path",a.clipPath).attr("class",b[xd])},f.redrawRegion=function(a){var b=this,c=b.config,d=b.CLASS;b.mainRegion=b.main.select("."+d[xd]).selectAll("."+d[wd]).data(c[Qc]),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForRegion=function(a){var b=this,c=b.regionX.bind(b),d=b.regionY.bind(b),e=b.regionWidth.bind(b),f=b.regionHeight.bind(b);a.push(b.mainRegion.selectAll("rect").transition().attr("x",c).attr("y",d).attr("width",e).attr("height",f).style("fill-opacity",function(a){return qe(a.opacity)?a.opacity:.1}))},f.regionX=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d[vb]?"start"in a?e(a.start):0:0:d[vb]?0:"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},f.regionY=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d[vb]?0:"end"in a?e(a.end):0:d[vb]?"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0:0},f.regionWidth=function(a){var b,c=this,d=c.config,e=c.regionX(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d[vb]?"end"in a?f(a.end):c.width:c.width:d[vb]?c.width:"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.width,e>b?0:b-e},f.regionHeight=function(a){var b,c=this,d=c.config,e=this.regionY(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d[vb]?c.height:"start"in a?f(a.start):c.height:d[vb]?"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.height:c.height,e>b?0:b-e},f.isRegionOnX=function(a){return!a.axis||"x"===a.axis},f.drag=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.config,l=j.main,m=j.d3;j.hasArcType()||k[Q]&&(!k[o]||j.zoom.altDomain)&&k[T]&&(b=j.dragStart[0],c=j.dragStart[1],d=a[0],e=a[1],f=Math.min(b,d),g=Math.max(b,d),h=k[R]?j.margin.top:Math.min(c,e),i=k[R]?j.height:Math.max(c,e),l.select("."+pe[le]).attr("x",f).attr("y",h).attr("width",g-f).attr("height",i-h),l.selectAll("."+pe[Bd]).selectAll("."+pe[Ad]).filter(function(a){return k[S](a)}).each(function(a,b){var c,d,e,k,l,n,o=m.select(this),p=o.classed(pe[ne]),q=o.classed(pe[oe]),r=!1;if(o.classed(pe[Gd]))c=1*o.attr("cx"),d=1*o.attr("cy"),l=j.togglePoint,r=c>f&&g>c&&d>h&&i>d;else{if(!o.classed(pe[Ed]))return;n=Ce(this),c=n.x,d=n.y,e=n.width,k=n.height,l=j.toggleBar,r=!(c>g||f>c+e||d>i||h>d+k)}r^q&&(o.classed(pe[oe],!q),o.classed(pe[ne],!p),l.call(j,!p,o,a,b))}))},f.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c[Q]&&(b.dragStart=a,b.main.select("."+pe[_c]).append("rect").attr("class",pe[le]).style("opacity",.1),b.dragging=!0,b.config[Z]())},f.dragend=function(){var a=this,b=a.config;a.hasArcType()||b[Q]&&(a.main.select("."+pe[le]).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+pe[Ad]).classed(pe[oe],!1),a.dragging=!1,a.config[$]())},f.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e[vb]?d.circleY:d.circleX).bind(d),g=(e[vb]?d.circleX:d.circleY).bind(d),h=d.pointSelectR.bind(d);e[X].call(d.api,b,a.node()),d.main.select("."+pe[od]+d.getTargetSelectorSuffix(b.id)).selectAll("."+pe[nd]+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(pe[nd],c)}).attr("cx",f).attr("cy",g).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",h)},f.unselectPoint=function(a,b,c){var d=this;d.config[Y](b,a.node()),d.main.select("."+pe[od]+d.getTargetSelectorSuffix(b.id)).selectAll("."+pe[nd]+"-"+c).transition().duration(100).attr("r",0).remove()},f.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},f.selectBar=function(a,b){var c=this;c.config[X].call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},f.unselectBar=function(a,b){var c=this;c.config[Y].call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},f.toggleBar=function(a,b,c,d){a?this.selectBar(b,c,d):this.unselectBar(b,c,d)},f.toggleArc=function(a,b,c,d){this.toggleBar(a,b,c.data,d)},f.getToggle=function(a){var b=this;return"circle"===a.nodeName?b.togglePoint:b.d3.select(a).classed(pe[Ed])?b.toggleBar:b.toggleArc},f.toggleShape=function(a,b,c){var d,e,f=this,g=f.d3,h=f.config,i=g.select(a),j=i.classed(pe[ne]);"circle"===a.nodeName?(d=f.isWithinCircle(a,1.5*f.pointSelectR(b)),e=f.togglePoint):"path"===a.nodeName&&(i.classed(pe[Ed])?(d=f.isWithinBar(a),e=f.toggleBar):(d=!0,e=f.toggleArc)),(h[R]||d)&&(h[Q]&&h[S](b)&&(h[T]||f.main.selectAll("."+pe[Bd]+(h[R]?f.getTargetSelectorSuffix(b.id):"")).selectAll("."+pe[Ad]).each(function(a,b){var c=g.select(this);c.classed(pe[ne])&&e.call(f,!1,c.classed(pe[ne],!1),a,b)}),i.classed(pe[ne],!j),e.call(f,!j,i,b,c)),f.config[U].call(f.api,b,a))},f.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+a.CLASS[ud]).call(this),this},a.brush.scale=function(b){return a.config[vb]?this.y(b):this.x(b)}},f.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));b[gb]||c.style("visibility","hidden"),c.append("g").attr("clip-path",a.clipPath).attr("class",pe[_c]),c.select("."+pe[_c]).append("g").attr("class",pe[dd]),c.select("."+pe[_c]).append("g").attr("class",pe[bd]),c.append("g").attr("clip-path",a.clipPath).attr("class",pe[ud]).call(a.brush).selectAll("rect").attr(b[vb]?"width":"height",b[vb]?a.width2:a.height2),a.axes.subx=c.append("g").attr("class",pe[_d]).attr("transform",a.getTranslate("subx")).attr("clip-path",b[vb]?"":a.clipPathForXAxis)},f.updateTargetsForSubchart=function(a){var b,c,d,e,f=this,g=f.context,h=f.config,i=f.classChartBar.bind(f),j=f.classBars.bind(f),k=f.classChartLine.bind(f),l=f.classLines.bind(f),m=f.classAreas.bind(f);h[gb]&&(e=g.select("."+pe[dd]).selectAll("."+pe[cd]).data(a).attr("class",i),d=e.enter().append("g").style("opacity",0).attr("class",i),d.append("g").attr("class",j),c=g.select("."+pe[bd]).selectAll("."+pe[ad]).data(a).attr("class",k),b=c.enter().append("g").style("opacity",0).attr("class",k),b.append("g").attr("class",l),b.append("g").attr("class",m))},f.redrawSubchart=function(a,b,c,d,e,f,g){var h,i,j,k,l,m,n=this,o=n.d3,p=n.context,q=n.config,r=n.barData.bind(n),s=n.lineData.bind(n),t=n.classBar.bind(n),u=n.classLine.bind(n),v=n.classArea.bind(n),w=n.initialOpacity.bind(n);q[gb]&&(o.event&&"zoom"===o.event.type&&n.brush.extent(n.x.orgDomain()).update(),a&&(!q[vb]&&q[Hb]&&n.rotateTickText(n.axes.subx,b.axisSubX,q[Hb]),n.brush.empty()||n.brush.extent(n.x.orgDomain()).update(),k=n.generateDrawArea(e,!0),l=n.generateDrawBar(f,!0),m=n.generateDrawLine(g,!0),j=p.selectAll("."+pe[Fd]).selectAll("."+pe[Ed]).data(r),j.enter().append("path").attr("class",t).style("stroke","none").style("fill",n.color),j.style("opacity",w).transition().duration(c).attr("d",l).style("opacity",1),j.exit().transition().duration(c).style("opacity",0).remove(),h=p.selectAll("."+pe[Dd]).selectAll("."+pe[Cd]).data(s),h.enter().append("path").attr("class",u).style("stroke",n.color),h.style("opacity",w).transition().duration(c).attr("d",m).style("opacity",1),h.exit().transition().duration(c).style("opacity",0).remove(),i=p.selectAll("."+pe[Ld]).selectAll("."+pe[Kd]).data(s),i.enter().append("path").attr("class",v).style("fill",n.color).style("opacity",function(){return n.orgAreaOpacity=+o.select(this).style("opacity"),0}),i.style("opacity",0).transition().duration(c).attr("d",k).style("fill",n.color).style("opacity",n.orgAreaOpacity),i.exit().transition().duration(d).style("opacity",0).remove()))},f.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0}),a.config[ib].call(a.api,b.orgDomain())},f.transformContext=function(a,b){var c,d=this;b&&b.axisSubX?c=b.axisSubX:(c=d.context.select("."+pe[_d]),a&&(c=c.transition())),d.context.attr("transform",d.getTranslate("context")),c.attr("transform",d.getTranslate("subx"))},f.initZoom=function(){var a=this,b=a.d3,c=a.config;a.zoom=b.behavior.zoom().on("zoomstart",function(){a.zoom.altDomain=b.event.sourceEvent.altKey?a.x.orgDomain():null}).on("zoom",function(){a.redrawForZoom.call(a)}),a.zoom.scale=function(a){return c[vb]?this.y(a):this.x(a)},a.zoom.orgScaleExtent=function(){var b=c[p]?c[p]:[1,10];return[b[0],Math.max(a.getMaxDataCount()/b[1],b[1])]},a.zoom.updateScaleExtent=function(){var b=xe(a.x.orgDomain())/xe(a.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*b,c[1]*b]),this}},f.updateZoom=function(){var a=this,b=a.config[o]?a.zoom:function(){};a.main.select("."+a.CLASS[td]).call(b),a.main.selectAll("."+a.CLASS[pd]).call(b)},f.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x,f=a.orgXDomain;if(c[o]&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),void d.scale(e).updateScaleExtent();a.isCategorized()&&e.orgDomain()[0]===f[0]&&e.domain([f[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c[r].call(a.api,e.orgDomain()) -}},f.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b[N],e=ze(b[jb])?b[jb]:c.scale.category10().range(),f=b[M],g=[];return function(a){var b,c=a.id||a;return d[c]instanceof Function?b=d[c](a):d[c]?b=d[c]:(g.indexOf(c)<0&&g.push(c),b=e[g.indexOf(c)%e.length],d[c]=b),f instanceof Function?f(b,a):b}},f.generateLevelColor=function(){var a=this,b=a.config,c=b[jb],d=b[kb],e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return ze(b[kb])?function(a){var b,d,h=c[c.length-1];for(b=0;b0},Ae=f.getOption=function(a,b,c){return ue(a[b])?a[b]:c},Be=f.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},Ce=f.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};e.focus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),this.defocus(),b(e.classed(pe[vd],!0)),b(f),c.hasArcType()&&c.expandArc(a,!0),c.toggleFocusLegend(a,!0)},e.defocus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",.3)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),b(e.classed(pe[vd],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.toggleFocusLegend(a,!1)},e.revert=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));b(e.classed(pe[vd],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.revertLegend()},e.show=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.removeHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",1),b.withLegend&&c.showLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.hide=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.addHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",0),b.withLegend&&c.hideLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.toggle=function(a){var b=this.internal;b.isTargetToShow(a)?this.hide(a):this.show(a)},e.zoom=function(){},e.zoom.enable=function(a){var b=this.internal;b.config[o]=a,b.updateAndRedraw()},e.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},e.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c[E][b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c[zb]=a.categories),"cacheIds"in a&&b.hasCaches(a.cacheIds)?void b.load(b.getCaches(a.cacheIds),a.done):void("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a))},e.unload=function(a){var b=this.internal;a=a||{},b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},e.flow=function(a){var b,c,d,e,f,g,h,i,j=this.internal,k=[],l=j.getMaxDataCount(),m=0,n=0;if(a.json)c=j.convertJsonToData(a.json,a.keys);else if(a.rows)c=j.convertRowsToData(a.rows);else{if(!a.columns)return;c=j.convertColumnsToData(a.columns)}b=j.convertDataToTargets(c,!0),j.data.targets.forEach(function(a){var c,d,e=!1;for(c=0;cd;d++)b[c].values[d].index=n+d,j.isTimeSeries()||(b[c].values[d].x=n+d);a.values=a.values.concat(b[c].values),b.splice(c,1);break}e||k.push(a.id)}),j.data.targets.forEach(function(a){var b,c;for(b=0;bc;c++)a.values.push({id:a.id,index:n+c,x:j.isTimeSeries()?j.getOtherTargetX(n+c):n+c,value:null})}),j.data.targets.length&&b.forEach(function(a){var b,c=[];for(b=j.data.targets[0].values[0].index;n>b;b++)c.push({id:a.id,index:b,x:j.isTimeSeries()?j.getOtherTargetX(b):b,value:null});a.values.forEach(function(a){a.index+=n,j.isTimeSeries()||(a.x+=n)}),a.values=c.concat(a.values)}),j.data.targets=j.data.targets.concat(b),d=j.getMaxDataCount(),f=j.data.targets[0],g=f.values[0],ue(a.to)?(m=0,i=j.isTimeSeries()?j.parseDate(a.to):a.to,f.values.forEach(function(a){a.x1?f.values[f.values.length-1].x-g.x:g.x-j.getXDomain(j.data.targets)[0]:1,e=[g.x-h,g.x],j.updateXDomain(null,!0,!0,e)),j.updateTargets(j.data.targets),j.redraw({flow:{index:g.index,length:m,duration:qe(a.duration)?a.duration:j.config[x],done:a.done,orgDataCount:l},withLegend:!0,withTransition:l>1})},f.generateFlow=function(a){var b=this,c=b.config,d=b.d3,e=b.CLASS;return function(){var f,g,h,i=a.targets,j=a.flow,k=a.drawBar,l=a.drawLine,m=a.drawArea,n=a.cx,o=a.cy,p=a.xv,q=a.xForText,r=a.yForText,s=a.duration,t=1,u=j.index,v=j.length,w=b.getValueOnIndex(b.data.targets[0].values,u),x=b.getValueOnIndex(b.data.targets[0].values,u+v),y=b.x.domain(),z=j.duration||s,A=j.done||function(){},B=b.generateWait(),C=b.xgrid||d.selectAll([]),D=b.xgridLines||d.selectAll([]),E=b.mainRegion||d.selectAll([]),F=b.mainText||d.selectAll([]),G=b.mainBar||d.selectAll([]),H=b.mainLine||d.selectAll([]),I=b.mainArea||d.selectAll([]),J=b.mainCircle||d.selectAll([]);b.data.targets.forEach(function(a){a.values.splice(0,v)}),h=b.updateXDomain(i,!0,!0),b.updateXGrid&&b.updateXGrid(!0),j.orgDataCount?f=1===j.orgDataCount||w.x===x.x?b.x(y[0])-b.x(h[0]):b.isTimeSeries()?b.x(y[0])-b.x(h[0]):b.x(w.x)-b.x(x.x):1!==b.data.targets[0].values.length?f=b.x(y[0])-b.x(h[0]):b.isTimeSeries()?(w=b.getValueOnIndex(b.data.targets[0].values,0),x=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),f=b.x(w.x)-b.x(x.x)):f=xe(h)/2,t=xe(y)/xe(h),g="translate("+f+",0) scale("+t+",1)",d.transition().ease("linear").duration(z).each(function(){B.add(b.axes.x.transition().call(b.xAxis)),B.add(G.transition().attr("transform",g)),B.add(H.transition().attr("transform",g)),B.add(I.transition().attr("transform",g)),B.add(J.transition().attr("transform",g)),B.add(F.transition().attr("transform",g)),B.add(E.filter(b.isRegionOnX).transition().attr("transform",g)),B.add(C.transition().attr("transform",g)),B.add(D.transition().attr("transform",g))}).call(B,function(){var a,d=[],f=[],g=[];if(v){for(a=0;v>a;a++)d.push("."+e[Ad]+"-"+(u+a)),f.push("."+e[Nd]+"-"+(u+a)),g.push("."+e[pd]+"-"+(u+a));b.svg.selectAll("."+e[Bd]).selectAll(d).remove(),b.svg.selectAll("."+e[Od]).selectAll(f).remove(),b.svg.selectAll("."+e[qd]).selectAll(g).remove(),b.svg.select("."+e[Rd]).remove()}C.attr("transform",null).attr(b.xgridAttr),D.attr("transform",null),D.select("line").attr("x1",c[vb]?0:p).attr("x2",c[vb]?b.width:p),D.select("text").attr("x",c[vb]?b.width:0).attr("y",p),G.attr("transform",null).attr("d",k),H.attr("transform",null).attr("d",l),I.attr("transform",null).attr("d",m),J.attr("transform",null).attr("cx",n).attr("cy",o),F.attr("transform",null).attr("x",q).attr("y",r).style("fill-opacity",b.opacityForText.bind(b)),E.attr("transform",null),E.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),b.updateEventRect(),A()})}},e.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+pe[Bd]+b.getTargetSelectorSuffix(a)).selectAll("."+pe[Ad]).filter(function(){return c.select(this).classed(pe[ne])}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},e.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f[Q]&&d.main.selectAll("."+pe[Bd]).selectAll("."+pe[Ad]).each(function(g,h){var i=e.select(this),j=g.data?g.data.id:g.id,k=d.getToggle(this),l=f[R]||!a||a.indexOf(j)>=0,m=!b||b.indexOf(h)>=0,n=i.classed(pe[ne]);i.classed(pe[Cd])||i.classed(pe[Kd])||(l&&m?f[S](g)&&!n&&k(!0,i.classed(pe[ne],!0),g,h):ue(c)&&c&&n&&k(!1,i.classed(pe[ne],!1),g,h))})},e.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e[Q]&&c.main.selectAll("."+pe[Bd]).selectAll("."+pe[Ad]).each(function(f,g){var h=d.select(this),i=f.data?f.data.id:f.id,j=c.getToggle(this),k=e[R]||!a||a.indexOf(i)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(pe[ne]);h.classed(pe[Cd])||h.classed(pe[Kd])||k&&l&&e[S](f)&&m&&j(!1,h.classed(pe[ne],!1),f,g)})},e.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},f.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateAndRedraw(f)},e.groups=function(a){var b=this.internal,c=b.config;return te(a)?c[F]:(c[F]=a,b.redraw(),c[F])},e.xgrids=function(a){var b=this.internal,c=b.config;return a?(c[hc]=a,b.redraw(),c[hc]):c[hc]},e.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config[hc].concat(a?a:[]))},e.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},e.ygrids=function(a){var b=this.internal,c=b.config;return a?(c[jc]=a,b.redraw(),c[jc]):c[jc]},e.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config[jc].concat(a?a:[]))},e.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},e.regions=function(a){var b=this.internal,c=b.config;return a?(c[Qc]=a,b.redraw(),c[Qc]):c[Qc]},e.regions.add=function(a){var b=this.internal,c=b.config;return a?(c[Qc]=c[Qc].concat(a),b.redraw(),c[Qc]):c[Qc]},e.regions.remove=function(a){var b,c,d,e=this.internal,f=e.config;return a=a||{},b=e.getOption(a,"duration",f[x]),c=e.getOption(a,"classes",[pe[wd]]),d=e.main.select("."+pe[xd]).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),f[Qc]=f[Qc].filter(function(a){var b=!1;return a.class?(a.class.split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0}),f[Qc]},e.data=function(){},e.data.get=function(a){var b=this.data.getAsTarget(a);return ue(b)?b.values.map(function(a){return a.value}):void 0},e.data.getAsTarget=function(a){var b=this.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:void 0},e.data.names=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c[D][b]=a[b]}),b.redraw({withLegend:!0}),c[D]):c[D]},e.data.colors=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c[N][b]=a[b]}),b.redraw({withLegend:!0}),c[N]):c[N]},e.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d[zb][a]=b,c.redraw()),d[zb][a]},e.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c[zb]=a,b.redraw(),c[zb]):c[zb]},e.color=function(a){var b=this.internal;return b.color(a)},e.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.axis=function(){},e.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.setAxisLabelText(c,a[c])}),b.updateAxisLabels())},e.axis.max=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(qe(a.x)&&(c[Jb]=a.x),qe(a.y)&&(c[Qb]=a.y),qe(a.y2)&&(c[Zb]=a.y2)):c[Qb]=c[Zb]=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.min=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(qe(a.x)&&(c[Kb]=a.x),qe(a.y)&&(c[Rb]=a.y),qe(a.y2)&&(c[$b]=a.y2)):c[Rb]=c[$b]=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.range=function(a){arguments.length&&(ue(a.max)&&this.axis.max(a.max),ue(a.min)&&this.axis.min(a.min))},e.legend=function(){},e.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.resize=function(a){var b=this.internal,c=b.config;c[i]=a?a.width:null,c[j]=a?a.height:null,this.flush()},e.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},e.destroy=function(){var b=this.internal;b.data.targets=void 0,b.data.xs={},b.selectChart.classed("c3",!1).html(""),a.onresize=null},"function"==typeof define&&define.amd?define("c3",["d3"],g):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=g:a.c3=g}(window); \ No newline at end of file +!function(a){"use strict";function b(a){var b=this.internal=new c(this);b.loadConfig(a),b.init(),function d(a,b,c){for(var e in a)b[e]=a[e].bind(c),Object.keys(a[e]).length>0&&d(a[e],b[e],c)}(e,this,this)}function c(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function d(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0&&B.select(this).style("display",b%y?"none":"block")})}else z.svg.selectAll("."+yb[ib]+" .tick text").style("display","block");!C.axis_rotated&&C.axis_x_tick_rotate&&z.rotateTickText(z.axes.x,b.axisX,C.axis_x_tick_rotate),l=z.generateDrawArea?z.generateDrawArea(D,!1):void 0,m=z.generateDrawBar?z.generateDrawBar(E):void 0,n=z.generateDrawLine?z.generateDrawLine(F,!1):void 0,o=z.generateXYForText(E,!0),p=z.generateXYForText(E,!1),z.subY.domain(z.y.domain()),z.subY2.domain(z.y2.domain()),z.tooltip.style("display","none"),z.updateXgridFocus(),A.select("text."+yb[W]+"."+yb[V]).attr("x",z.width/2).attr("y",z.height/2).text(C.data_empty_label_text).transition().style("opacity",H.length?0:1),z.redrawGrid(q,c),z.redrawRegion(q),z.redrawBar(r),z.redrawLine(r),z.redrawArea(r),C.point_show&&z.redrawCircle(),z.hasDataLabel()&&z.redrawText(r),z.redrawArc&&z.redrawArc(q,r,h),z.redrawSubchart&&z.redrawSubchart(d,b,q,r,D,E,F),A.selectAll("."+yb[x]).filter(z.isBarType.bind(z)).selectAll("circle").remove(),C.interaction_enabled&&z.redrawEventRect(),B.transition().duration(q).each(function(){var b=[];z.addTransitionForBar(b,m),z.addTransitionForLine(b,n),z.addTransitionForArea(b,l),z.addTransitionForCircle(b,J,K),z.addTransitionForText(b,o,p,a.flow),z.addTransitionForRegion(b),z.addTransitionForGrid(b),a.flow&&(t=z.generateWait(),b.forEach(function(a){t.add(a)}),u=z.generateFlow({targets:H,flow:a.flow,duration:q,drawBar:m,drawLine:n,drawArea:l,cx:J,cy:K,xv:I,xForText:o,yForText:p}))}).call(t||function(){},u||function(){}),z.mapToIds(z.data.targets).forEach(function(a){z.withoutFadeIn[a]=!0}),z.updateZoom&&z.updateZoom()},f.updateAndRedraw=function(a){var b,c=this,d=c.config;a=a||{},a.withTransition=Jb(a,"withTransition",!0),a.withTransform=Jb(a,"withTransform",!1),a.withLegend=Jb(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=Jb(a,"withTransitionForTransform",a.withTransition),c.updateSizes(),a.withLegend&&d.legend_show||(b=c.generateAxisTransitions(a.withTransitionForAxis?d.transition_duration:0),c.updateScales(),c.updateSvgSize(),c.transformAll(a.withTransitionForTransform,b)),c.redraw(a,b)},f.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},f.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},f.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b.data_x||Ib(b.data_xs))},f.getTranslate=function(a){var b,c,d=this,e=d.config;return"main"===a?(b=Fb(d.margin.left),c=Fb(d.margin.top)):"context"===a?(b=Fb(d.margin2.left),c=Fb(d.margin2.top)):"legend"===a?(b=d.margin3.left,c=d.margin3.top):"x"===a?(b=0,c=e.axis_rotated?0:d.height):"y"===a?(b=0,c=e.axis_rotated?d.height:0):"y2"===a?(b=e.axis_rotated?0:d.width,c=e.axis_rotated?1:0):"subx"===a?(b=0,c=e.axis_rotated?0:d.height2):"arc"===a&&(b=d.arcWidth/2,c=d.arcHeight/2),"translate("+b+","+c+")"},f.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},f.opacityForCircle=function(a){var b=this;return zb(a.value)?b.isScatterType(a)?.5:1:0},f.opacityForText=function(){return this.hasDataLabel()?1:0},f.xx=function(a){return a?this.x(a.x):null},f.xv=function(a){var b=this;return Math.ceil(b.x(b.isTimeSeries()?b.parseDate(a.value):a.value))},f.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},f.subxx=function(a){return a?this.subX(a.x):null},f.transformMain=function(a,b){var c,d,e,f=this;b&&b.axisX?c=b.axisX:(c=f.main.select("."+yb[ib]),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=f.main.select("."+yb[kb]),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=f.main.select("."+yb[mb]),a&&(e=e.transition())),(a?f.main.transition():f.main).attr("transform",f.getTranslate("main")),c.attr("transform",f.getTranslate("x")),d.attr("transform",f.getTranslate("y")),e.attr("transform",f.getTranslate("y2")),f.main.select("."+yb[q]).attr("transform",f.getTranslate("arc"))},f.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config.subchart_show&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},f.updateSvgSize=function(){var a=this;a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.select("#"+a.clipId).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("."+yb[C]).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},f.updateDimension=function(){var a=this;a.config.axis_rotated?(a.axes.x.call(a.xAxis),a.axes.subx.call(a.subXAxis)):(a.axes.y.call(a.yAxis),a.axes.y2.call(a.y2Axis)),a.updateSizes(),a.updateScales(),a.updateSvgSize(),a.transformAll(!1)},f.observeInserted=function(b){var c=this,d=new MutationObserver(function(e){e.forEach(function(e){if("childList"===e.type&&e.previousSibling){d.disconnect();var f=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(f),c.updateDimension(),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});d.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})},f.generateResize=function(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a},f.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},f.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},f.parseDate=function(b){var c,d=this;return c=b instanceof Date?b:"number"==typeof b?new Date(b):d.dataTimeFormat(d.config.data_xFormat).parse(b),(!c||isNaN(+c))&&a.console.error("Failed to parse x '"+b+"' to Date object"),c},f.getDefaultConfig=function(){var a={bindto:"#chart",size_width:void 0,size_height:void 0,padding_left:void 0,padding_right:void 0,padding_top:void 0,padding_bottom:void 0,zoom_enabled:!1,zoom_extent:void 0,zoom_privileged:!1,zoom_onzoom:function(){},interaction_enabled:!0,onmouseover:function(){},onmouseout:function(){},onresize:function(){},onresized:function(){},transition_duration:350,data_x:void 0,data_xs:{},data_xFormat:"%Y-%m-%d",data_xLocaltime:!0,data_idConverter:function(a){return a},data_names:{},data_classes:{},data_groups:[],data_axes:{},data_type:void 0,data_types:{},data_labels:{},data_order:"desc",data_regions:{},data_color:void 0,data_colors:{},data_hide:!1,data_filter:void 0,data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return!0},data_selection_multiple:!0,data_onclick:function(){},data_onmouseover:function(){},data_onmouseout:function(){},data_onselected:function(){},data_onunselected:function(){},data_ondragstart:function(){},data_ondragend:function(){},data_url:void 0,data_json:void 0,data_rows:void 0,data_columns:void 0,data_mimeType:void 0,data_keys:void 0,data_empty_label_text:"",subchart_show:!1,subchart_size_height:60,subchart_onbrush:function(){},color_pattern:[],color_threshold:{},legend_show:!0,legend_position:"bottom",legend_inset_anchor:"top-left",legend_inset_x:10,legend_inset_y:0,legend_inset_step:void 0,legend_item_onclick:void 0,legend_item_onmouseover:void 0,legend_item_onmouseout:void 0,legend_equally:!1,axis_rotated:!1,axis_x_show:!0,axis_x_type:"indexed",axis_x_localtime:!0,axis_x_categories:[],axis_x_tick_centered:!1,axis_x_tick_format:void 0,axis_x_tick_culling:{},axis_x_tick_culling_max:10,axis_x_tick_count:void 0,axis_x_tick_fit:!0,axis_x_tick_values:null,axis_x_tick_rotate:void 0,axis_x_tick_outer:!0,axis_x_max:null,axis_x_min:null,axis_x_padding:{},axis_x_height:void 0,axis_x_default:void 0,axis_x_label:{},axis_y_show:!0,axis_y_max:void 0,axis_y_min:void 0,axis_y_center:void 0,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_outer:!0,axis_y_padding:void 0,axis_y_ticks:10,axis_y2_show:!1,axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_center:void 0,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_outer:!0,axis_y2_padding:void 0,axis_y2_ticks:10,grid_x_show:!1,grid_x_type:"tick",grid_x_lines:[],grid_y_show:!1,grid_y_lines:[],grid_y_ticks:10,grid_focus_show:!0,point_show:!0,point_r:2.5,point_focus_expand_enabled:!0,point_focus_expand_r:void 0,point_select_r:void 0,line_connect_null:!1,bar_width:void 0,bar_width_ratio:.6,bar_width_max:void 0,bar_zerobased:!0,area_zerobased:!0,pie_label_show:!0,pie_label_format:void 0,pie_label_threshold:.05,pie_sort:!0,pie_expand:!0,gauge_label_show:!0,gauge_label_format:void 0,gauge_expand:!0,gauge_min:0,gauge_max:100,gauge_units:void 0,gauge_width:void 0,donut_label_show:!0,donut_label_format:void 0,donut_label_threshold:.05,donut_width:void 0,donut_sort:!0,donut_expand:!0,donut_title:"",regions:[],tooltip_show:!0,tooltip_grouped:!0,tooltip_format_title:void 0,tooltip_format_name:void 0,tooltip_format_value:void 0,tooltip_contents:function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},tooltip_init_show:!1,tooltip_init_x:0,tooltip_init_position:{top:"0px",left:"50px"}};return Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},f.additionalConfig={},f.loadConfig=function(a){function b(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],b()):a?void 0:c}var c,d,e,f=this.config;Object.keys(f).forEach(function(g){c=a,d=g.split("_"),e=b(),Db(e)&&(f[g]=e)})},f.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},f.getX=function(a,b,c,d){var e,f=this,g=f.getScale(a,b,f.isTimeSeries()),h=c?g.domain(c):g;f.isCategorized()?(d=d||function(){return 0},g=function(a,b){var c=h(a)+d(a);return b?c:Math.ceil(c)}):g=function(a,b){var c=h(a);return b?c:Math.ceil(c)};for(e in h)g[e]=h[e];return g.orgDomain=function(){return h.domain()},f.isCategorized()&&(g.domain=function(a){return arguments.length?(h.domain(a),g):(a=this.orgDomain(),[a[0],a[1]+1])}),g},f.getY=function(a,b,c){var d=this.getScale(a,b);return c&&d.domain(c),d},f.getYScale=function(a){return"y2"===this.getAxisId(a)?this.y2:this.y},f.getSubYScale=function(a){return"y2"===this.getAxisId(a)?this.subY2:this.subY},f.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b.axis_rotated?1:0,a.xMax=b.axis_rotated?a.height:a.width,a.yMin=b.axis_rotated?0:a.height,a.yMax=b.axis_rotated?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b.axis_rotated?0:a.height2,a.subYMax=b.axis_rotated?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?void 0:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?void 0:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?void 0:a.subY2.domain()),a.xAxisTickFormat=a.getXAxisTickFormat(),a.xAxisTickValues=b.axis_x_tick_values?b.axis_x_tick_values:c?void 0:a.xAxis.tickValues(),a.xAxis=a.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues),a.subXAxis=a.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues),a.yAxis=a.getYAxis(a.y,a.yOrient,b.axis_y_tick_format,b.axis_y_ticks),a.y2Axis=a.getYAxis(a.y2,a.y2Orient,b.axis_y2_tick_format,b.axis_y2_ticks),c||(a.brush&&a.brush.scale(a.subX),b.zoom_enabled&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},f.getYDomainMin=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasNegativeValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=0>a?a:0}),c=1;c0||(k[d][b]+=+a)});return h.d3.min(Object.keys(k).map(function(a){return h.d3.min(k[a])}))},f.getYDomainMax=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasPositiveValueInTargets(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=a>0?a:0}),c=1;c+a||(k[d][b]+=+a)});return h.d3.max(Object.keys(k).map(function(a){return h.d3.max(k[a])}))},f.getYDomain=function(a,b){var c,d,e,f,g,h,i,j,k,l,m=this,n=m.config,o=a.filter(function(a){return m.getAxisId(a.id)===b}),p="y2"===b?n.axis_y2_min:n.axis_y_min,q="y2"===b?n.axis_y2_max:n.axis_y_max,r=zb(p)?p:m.getYDomainMin(o),s=zb(q)?q:m.getYDomainMax(o),t="y2"===b?n.axis_y2_center:n.axis_y_center,u=m.hasType("bar",o)&&n.bar_zerobased||m.hasType("area",o)&&n.area_zerobased,v=m.hasDataLabel()&&n.axis_rotated,w=m.hasDataLabel()&&!n.axis_rotated;return 0===o.length?"y2"===b?m.y2.domain():m.y.domain():(r===s&&(0>r?s=0:r=0),k=r>=0&&s>=0,l=0>=r&&0>=s,u&&(k&&(r=0),l&&(s=0)),c=Math.abs(s-r),d=e=f=.1*c,t&&(g=Math.max(Math.abs(r),Math.abs(s)),s=g-t,r=t-g),v?(h=m.getDataLabelLength(r,s,b,"width"),i=Gb(m.y.range()),j=[h[0]/i,h[1]/i],e+=c*(j[1]/(1-j[0]-j[1])),f+=c*(j[0]/(1-j[0]-j[1]))):w&&(h=m.getDataLabelLength(r,s,b,"height"),e+=h[1],f+=h[0]),"y"===b&&n.axis_y_padding&&(e=m.getAxisPadding(n.axis_y_padding,"top",d,c),f=m.getAxisPadding(n.axis_y_padding,"bottom",d,c)),"y2"===b&&n.axis_y2_padding&&(e=m.getAxisPadding(n.axis_y2_padding,"top",d,c),f=m.getAxisPadding(n.axis_y2_padding,"bottom",d,c)),u&&(k&&(f=r),l&&(e=-s)),[r-f,s+e])},f.getXDomainMin=function(a){var b=this,c=b.config;return c.axis_x_min?b.isTimeSeries()?this.parseDate(c.axis_x_min):c.axis_x_min:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},f.getXDomainMax=function(a){var b=this,c=b.config;return c.axis_x_max?b.isTimeSeries()?this.parseDate(c.axis_x_max):c.axis_x_max:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},f.getXDomainPadding=function(a){var b,c,d,e,f=this,g=f.config,h=this.getEdgeX(a),i=h[1]-h[0];return f.isCategorized()?c=0:f.hasType("bar",a)?(b=f.getMaxDataCount(),c=b>1?i/(b-1)/2:.5):c=.01*i,"object"==typeof g.axis_x_padding&&Ib(g.axis_x_padding)?(d=zb(g.axis_x_padding.left)?g.axis_x_padding.left:c,e=zb(g.axis_x_padding.right)?g.axis_x_padding.right:c):d=e="number"==typeof g.axis_x_padding?g.axis_x_padding:c,{left:d,right:e}},f.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(a),g=0,h=0;return d-e!==0||b.isCategorized()||(d=b.isTimeSeries()?new Date(.5*d.getTime()):-.5,e=b.isTimeSeries()?new Date(1.5*e.getTime()):.5),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},f.updateXDomain=function(a,b,c,d){var e=this,f=e.config;return c&&(e.x.domain(d?d:e.d3.extent(e.getXDomain(a))),e.orgXDomain=e.x.domain(),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent(),e.subX.domain(e.x.domain()),e.brush&&e.brush.scale(e.subX)),b&&(e.x.domain(d?d:!e.brush||e.brush.empty()?e.orgXDomain:e.brush.extent()),f.zoom_enabled&&e.zoom.scale(e.x).updateScaleExtent()),e.x.domain()},f.isX=function(a){var b=this,c=b.config;return c.data_x&&a===c.data_x||Ib(c.data_xs)&&Kb(c.data_xs,a)},f.isNotX=function(a){return!this.isX(a)},f.getXKey=function(a){var b=this,c=b.config;return c.data_x?c.data_x:Ib(c.data_xs)?c.data_xs[a]:null},f.getXValuesOfXKey=function(a,b){var c,d=this,e=b&&Ib(b)?d.mapToIds(b):[];return e.forEach(function(b){d.getXKey(b)===a&&(c=d.data.xs[b])}),c},f.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&zb(c.data.xs[a][b])?c.data.xs[a][b]:b},f.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},f.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a1},f.isMultipleX=function(){var a=this,b=a.config;return Ib(b.data_xs)&&a.hasMultipleX(b.data_xs)},f.addName=function(a){var b,c=this;return a&&(b=c.config.data_names[a.id],a.name=b?b:a.id),a},f.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},f.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},f.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},f.generateTargetX=function(a,b,c){var d,e=this;return d=e.isTimeSeries()?e.parseDate(a?a:e.getXValue(b,c)):e.isCustomX()&&!e.isCategorized()?zb(a)?+a:e.getXValue(b,c):c},f.cloneTarget=function(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}},f.getPrevX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a-1);return c?c.x:null},f.getNextX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a+1);return c?c.x:null},f.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},f.getMaxDataCountTarget=function(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b},f.getEdgeX=function(a){var b,c,d=this.getMaxDataCountTarget(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]},f.mapToIds=function(a){return a.map(function(a){return a.id})},f.mapToTargetIds=function(a){var b=this;return a?Bb(a)?[a]:a:b.mapToIds(b.data.targets)},f.hasTarget=function(a,b){var c,d=this.mapToIds(a);for(c=0;ca})},f.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},f.isOrderDesc=function(){var a=this.config;return a.data_order&&"desc"===a.data_order.toLowerCase()},f.isOrderAsc=function(){var a=this.config;return a.data_order&&"asc"===a.data_order.toLowerCase()},f.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):Ab(c.data_order)&&a.sort(c.data_order),a},f.filterSameX=function(a,b){return this.d3.merge(a.map(function(a){return a.values +})).filter(function(a){return a.x-b===0})},f.filterRemoveNull=function(a){return a.filter(function(a){return zb(a.value)})},f.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a.data_labels&&a.data_labels?!0:"object"==typeof a.data_labels&&Ib(a.data_labels)?!0:!1},f.getDataLabelLength=function(a,b,c,d){var e=this,f=[0,0],g=1.3;return e.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return e.formatByAxisId(c)(a)}).each(function(a,b){f[b]=this.getBoundingClientRect()[d]*g}).remove(),f},f.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},f.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},f.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?h=i:g=i,h-g===1||0===g&&0===h?(e=[],(a[g].x||0===a[g].x)&&(e=e.concat(f.findSameXOfValues(a,g))),(a[h].x||0===a[h].x)&&(e=e.concat(f.findSameXOfValues(a,h))),f.findClosest(e,b)):f.findClosestOfValues(a,b,g,h)},f.findClosestFromTargets=function(a,b){var c,d=this;return c=a.map(function(a){return d.findClosestOfValues(a.values,b)}),d.findClosest(c,b)},f.findClosest=function(a,b){var c,d,e=this;return a.forEach(function(a){var f=e.dist(a,b);(c>f||!c)&&(c=f,d=a)}),d},f.dist=function(a,b){var c=this,d=c.config,e="y"===c.getAxisId(a.id)?c.y:c.y2,f=d.axis_rotated?1:0,g=d.axis_rotated?0:1;return Math.pow(c.x(a.x)-b[f],2)+Math.pow(e(a.value)-b[g],2)},f.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):e.convertCsvToData(b.response),d.call(e,g)})},f.convertCsvToData=function(a){var b,c=this.d3,d=c.csv.parseRows(a);return 1===d.length?(b=[{}],d[0].forEach(function(a){b[0][a]=null})):b=c.csv.parse(a),b},f.convertJsonToData=function(a,b){var c,d,e=this,f=[];return b?(c=b.value,b.x&&(c.push(b.x),e.config.data_x=b.x),f.push(c),a.forEach(function(a){var b=[];c.forEach(function(c){var d=Cb(a[c])?null:a[c];b.push(d)}),f.push(b)}),d=e.convertRowsToData(f)):(Object.keys(a).forEach(function(b){f.push([b].concat(a[b]))}),d=e.convertColumnsToData(f)),d},f.convertRowsToData=function(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?d.data.xs[c]=(b&&d.data.xs[c]?d.data.xs[c]:[]).concat(a.map(function(a){return a[f]}).filter(zb).map(function(a,b){return d.generateTargetX(a,c,b)})):e.data_x?d.data.xs[c]=d.getOtherTargetXs():Ib(e.data_xs)&&(d.data.xs[c]=d.getXValuesOfXKey(f,d.data.targets)):d.data.xs[c]=a.map(function(a,b){return b})}),f.forEach(function(a){if(!d.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=f.map(function(b,c){var f=e.data_idConverter(b);return{id:f,id_org:b,values:a.map(function(a,g){var h=d.getXKey(b),i=a[h],j=d.generateTargetX(i,b,g);return d.isCustomX()&&d.isCategorized()&&0===c&&i&&(0===g&&(e.axis_x_categories=[]),e.axis_x_categories.push(i)),(Cb(a[b])||d.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return Db(a.x)})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++}),d.data.xs[a.id].sort(function(a,b){return a-b})}),e.data_type&&d.setTargetType(d.mapToIds(c).filter(function(a){return!(a in e.data_types)}),e.data_type),c.forEach(function(a){d.addCache(a.id_org,a)}),c},f.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){c.setTargetType(a.id,b.types?b.types[a.id]:b.type)}),c.data.targets.forEach(function(b){for(var c=0;ce?0:e},g=function(a){var b=h.getPrevX(a.index),c=h.data.xs[a.id][a.index];return(h.x(c)+h.x(b?b:c))/2}),b=i.axis_rotated?0:g,c=i.axis_rotated?g:0,d=i.axis_rotated?h.width:f,e=i.axis_rotated?f:h.height),a.attr("class",h.classEvent.bind(h)).attr("x",b).attr("y",c).attr("width",d).attr("height",e)},f.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d.data_selection_enabled&&d.data_selection_grouped?"pointer":null).on("mouseover",function(a){var c,e,f=a.index;b.dragging||b.hasArcType()||(c=b.data.targets.map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),e=[],Object.keys(d.data_names).forEach(function(a){for(var b=0;b0?c:320},f.getCurrentPaddingTop=function(){var a=this.config;return zb(a.padding_top)?a.padding_top:0},f.getCurrentPaddingBottom=function(){var a=this.config;return zb(a.padding_bottom)?a.padding_bottom:0},f.getCurrentPaddingLeft=function(){var a=this,b=a.config;return zb(b.padding_left)?b.padding_left:b.axis_rotated?b.axis_x_show?Math.max(Eb(a.getAxisWidthByAxisId("x")),40):1:b.axis_y_show?Eb(a.getAxisWidthByAxisId("y")):1},f.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return zb(b.padding_right)?b.padding_right+1:b.axis_rotated?c+d:(b.axis_y2_show?Eb(a.getAxisWidthByAxisId("y2")):c)+d},f.getParentRectValue=function(a){for(var b,c=this.selectChart.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b},f.getParentWidth=function(){return this.getParentRectValue("width")},f.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},f.getSvgLeft=function(){var a=this,b=a.config,c=b.axis_rotated?yb[ib]:yb[kb],d=a.main.select("."+c).node(),e=d?d.getBoundingClientRect():{right:0},f=a.selectChart.node().getBoundingClientRect(),g=a.hasArcType(),h=e.right-f.left-(g?0:a.getCurrentPaddingLeft());return h>0?h:0},f.getAxisWidthByAxisId=function(a){var b=this,c=b.getAxisLabelPositionById(a);return c.isInner?20+b.getMaxTickWidth(a):40+b.getMaxTickWidth(a)},f.getHorizontalAxisHeight=function(a){var b=this,c=b.config;return"x"!==a||c.axis_x_show?"x"===a&&c.axis_x_height?c.axis_x_height:"y"!==a||c.axis_y_show?"y2"!==a||c.axis_y2_show?(b.getAxisLabelPositionById(a).isInner?30:40)+("y2"===a?-10:0):b.rotated_padding_top:!c.legend_show||b.isLegendRight||b.isLegendInset?1:10:0},f.getEventRectWidth=function(){var a,b,c,d,e,f,g=this,h=g.getMaxDataCountTarget(g.data.targets);return h?(a=h.values[0],b=h.values[h.values.length-1],c=g.x(b.x)-g.x(a.x),0===c?g.config.axis_rotated?g.height:g.width:(d=g.getMaxDataCount(),e=g.hasType("bar")?(d-(g.isCategorized()?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0},f.getShapeIndices=function(a){var b,c,d=this,e=d.config,f={},g=0;return d.filterTargetsToShow(d.data.targets.filter(a,d)).forEach(function(a){for(b=0;b=0&&(j+=h(c.values[g].value)-i)}),j}},f.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?"step-after":"linear"},f.initLine=function(){var a=this,b=a.CLASS;a.main.select("."+b[i]).append("g").attr("class",b[k])},f.updateTargetsForLine=function(a){var b,c,d=this,e=d.config,f=d.CLASS,g=d.classChartLine.bind(d),h=d.classLines.bind(d),i=d.classAreas.bind(d),l=d.classCircles.bind(d);b=d.main.select("."+f[k]).selectAll("."+f[j]).data(a).attr("class",g),c=b.enter().append("g").attr("class",g).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",h),c.append("g").attr("class",i),c.append("g").attr("class",function(a){return d.generateClass(f[x],a.id)}),c.append("g").attr("class",l).style("cursor",function(a){return e.data_selection_isselectable(a)?"pointer":null}),a.forEach(function(a){d.main.selectAll("."+f[x]+d.getTargetSelectorSuffix(a.id)).selectAll("."+f[w]).each(function(b){b.value=a.values[b.index].value})})},f.redrawLine=function(a){var b=this,c=b.CLASS;b.mainLine=b.main.selectAll("."+c[M]).selectAll("."+c[L]).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForLine=function(a,b){var c=this;a.push(c.mainLine.transition().attr("d",b).style("stroke",c.color).style("opacity",1))},f.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x(i).y(h):e.x(h).y(i),d.line_connect_null||(e=e.defined(function(a){return null!=a.value})),function(a){var f,h=d.line_connect_null?c.filterRemoveNull(a.values):a.values,i=b?c.x:c.subX,j=g.call(c,a.id),k=0,l=0;return c.isLineType(a)?f=d.data_regions[a.id]?c.lineWithRegions(h,i,j,d.data_regions[a.id]):e.interpolate(c.getInterpolate(a))(h):(h[0]&&(k=i(h[0].x),l=j(h[0].value)),f=d.axis_rotated?"M "+l+" "+k:"M "+k+" "+l),f?f:"M 0 0"}},f.generateGetLinePoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)]]}},f.lineWithRegions=function(a,b,c,d){function e(a,b){var c;for(c=0;c=g;g+=o)u+=h(a[f-1],a[f],g,n);t=a[f].x}return u},f.redrawArea=function(a){var b=this,c=b.CLASS,d=b.d3;b.mainArea=b.main.selectAll("."+c[U]).selectAll("."+c[T]).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+d.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForArea=function(a,b){var c=this;a.push(c.mainArea.transition().attr("d",b).style("fill",c.color).style("opacity",c.orgAreaOpacity))},f.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoint(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(0)},j=function(a,b){return d.data_groups.length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d.line_connect_null||(e=e.defined(function(a){return null!==a.value})),function(a){var b,f=d.line_connect_null?c.filterRemoveNull(a.values):a.values,g=0,h=0;return c.isAreaType(a)?b=e.interpolate(c.getInterpolate(a))(f):(f[0]&&(g=c.x(f[0].x),h=c.getYScale(a.id)(f[0].value)),b=d.axis_rotated?"M "+h+" "+g:"M "+g+" "+h),b?b:"M 0 0"}},f.generateGetAreaPoint=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)]]}},f.redrawCircle=function(){var a=this,b=a.CLASS;a.mainCircle=a.main.selectAll("."+b[Q]).selectAll("."+b[P]).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacity.bind(a)),a.mainCircle.exit().remove()},f.addTransitionForCircle=function(a,b,c){var d=this;a.push(d.mainCircle.transition().style("opacity",d.opacityForCircle.bind(d)).style("fill",d.color).attr("cx",b).attr("cy",c)),a.push(d.main.selectAll("."+yb[w]).transition().attr("cx",b).attr("cy",c))},f.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},f.circleY=function(a,b){var c=this,d=c.getShapeIndices(c.isLineType),e=c.generateGetLinePoint(d);return c.config.data_groups.length>0?e(a,b)[0][1]:c.getYScale(a.id)(a.value)},f.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+yb[Q]+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+yb[P]+(zb(a)?"-"+a:""))},f.expandCircles=function(a,b){var c=this,d=c.pointExpandedR.bind(c);c.getCircles(a,b).classed(yb[vb],!0).attr("r",d)},f.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(yb[vb])}).classed(yb[vb],!1).attr("r",c)},f.pointR=function(a){var b=this,c=b.config;return c.point_show&&!b.isStepType(a)?Ab(c.point_r)?c.point_r(a):c.point_r:0},f.pointExpandedR=function(a){var b=this,c=b.config;return c.point_focus_expand_enabled?c.point_focus_expand_r?c.point_focus_expand_r:1.75*b.pointR(a):b.pointR(a)},f.pointSelectR=function(a){var b=this,c=b.config;return c.point_select_r?c.point_select_r:4*b.pointR(a)},f.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=1*e.attr("cx"),g=1*e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))d.bar_width_max?d.bar_width_max:e},f.getBars=function(a){var b=this;return b.main.selectAll("."+yb[N]+(zb(a)?"-"+a:""))},f.expandBars=function(a){var b=this;b.getBars(a).classed(yb[vb],!0)},f.unexpandBars=function(a){var b=this;b.getBars(a).classed(yb[vb],!1)},f.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d.axis_rotated?1:0,g=d.axis_rotated?0:1,h="M "+c[0][f]+","+c[0][g]+" L"+c[1][f]+","+c[1][g]+" L"+c[2][f]+","+c[2][g]+" L"+c[3][f]+","+c[3][g]+" z";return h}},f.generateGetBarPoints=function(a,b){var c=this,d=a.__max__+1,e=c.getBarW(c.xAxis,d),f=c.getShapeX(e,d,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isBarType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var d=i.call(c,a.id)(0),j=h(a,b)||d,k=f(a),l=g(a);return c.config.axis_rotated&&(0l||a.value<0&&l>d)&&(l=d),[[k,j],[k,l-(d-j)],[k+e,l-(d-j)],[k+e,j]]}},f.isWithinBar=function(a){var b=this.d3,c=b.mouse(a),d=a.getBoundingClientRect(),e=a.pathSegList.getItem(0),f=a.pathSegList.getItem(1),g=e.x,h=Math.min(e.y,f.y),i=d.width,j=d.height,k=2,l=g-k,m=g+i+k,n=h+j+k,o=h-k;return lf.width?f.width-g.width:d},f.getYForText=function(a,b,c){var d,e=this,f=c.getBoundingClientRect();return d=e.config.axis_rotated?(a[0][0]+a[2][0]+.6*f.height)/2:a[2][1]+(b.value<0?f.height:e.isBarType(b)?-3:-6),d=0||!(b.id in d)&&"line"===a)&&(e=!0)}),e},f.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},f.isLineType=function(a){var b=this.config,c=Bb(a)?a:a.id;return!b.data_types[c]||["line","spline","area","area-spline","step","area-step"].indexOf(b.data_types[c])>=0},f.isStepType=function(a){var b=Bb(a)?a:a.id;return["step","area-step"].indexOf(this.config.data_types[b])>=0},f.isSplineType=function(a){var b=Bb(a)?a:a.id;return["spline","area-spline"].indexOf(this.config.data_types[b])>=0},f.isAreaType=function(a){var b=Bb(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[b])>=0},f.isBarType=function(a){var b=Bb(a)?a:a.id;return"bar"===this.config.data_types[b]},f.isScatterType=function(a){var b=Bb(a)?a:a.id;return"scatter"===this.config.data_types[b]},f.isPieType=function(a){var b=Bb(a)?a:a.id;return"pie"===this.config.data_types[b]},f.isGaugeType=function(a){var b=Bb(a)?a:a.id;return"gauge"===this.config.data_types[b]},f.isDonutType=function(a){var b=Bb(a)?a:a.id;return"donut"===this.config.data_types[b]},f.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},f.lineData=function(a){return this.isLineType(a)?[a]:[]},f.arcData=function(a){return this.isArcType(a.data)?[a]:[]},f.barData=function(a){return this.isBarType(a)?a.values:[]},f.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},f.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},f.initGrid=function(){var a=this,b=a.config,c=a.CLASS,d=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPath).attr("class",c[Z]),b.grid_x_show&&a.grid.append("g").attr("class",c[_]),b.grid_y_show&&a.grid.append("g").attr("class",c[eb]),a.grid.append("g").attr("class",c[bb]),a.grid.append("g").attr("class",c[gb]),b.grid_focus_show&&a.grid.append("g").attr("class",c[cb]).append("line").attr("class",c[cb]),a.xgrid=d.selectAll([]),a.xgridLines=d.selectAll([])},f.updateXGrid=function(a){var b=this,c=b.config,d=b.CLASS,e=b.d3,f=b.generateGridData(c.grid_x_type,b.x),g=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c.axis_rotated?{x1:0,x2:b.width,y1:function(a){return b.x(a)-g},y2:function(a){return b.x(a)-g}}:{x1:function(a){return b.x(a)+g},x2:function(a){return b.x(a)+g},y1:0,y2:b.height},b.xgrid=b.main.select("."+d[_]).selectAll("."+d[$]).data(f),b.xgrid.enter().append("line").attr("class",d[$]),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+e.select(this).attr(c.axis_rotated?"y1":"x1")===(c.axis_rotated?b.height:0)?0:1}),b.xgrid.exit().remove()},f.updateYGrid=function(){var a=this,b=a.config,c=a.CLASS;a.ygrid=a.main.select("."+c[eb]).selectAll("."+c[db]).data(a.y.ticks(b.grid_y_ticks)),a.ygrid.enter().append("line").attr("class",c[db]),a.ygrid.attr("x1",b.axis_rotated?a.y:0).attr("x2",b.axis_rotated?a.y:a.width).attr("y1",b.axis_rotated?0:a.y).attr("y2",b.axis_rotated?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},f.redrawGrid=function(a,b){var c,d,e,f=this,g=f.main,h=f.config,i=f.CLASS;g.select("line."+i[cb]).style("visibility","hidden"),h.grid_x_show&&f.updateXGrid(),f.xgridLines=g.select("."+i[bb]).selectAll("."+i[ab]).data(h.grid_x_lines),c=f.xgridLines.enter().append("g").attr("class",function(a){return i[ab]+(a.class?" "+a.class:"")}),c.append("line").style("opacity",0),c.append("text").attr("text-anchor","end").attr("transform",h.axis_rotated?"":"rotate(-90)").attr("dx",h.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),f.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),b&&h.grid_y_show&&f.updateYGrid(),b&&(f.ygridLines=g.select("."+i[gb]).selectAll("."+i[fb]).data(h.grid_y_lines),d=f.ygridLines.enter().append("g").attr("class",function(a){return i[fb]+(a.class?" "+a.class:"")}),d.append("line").style("opacity",0),d.append("text").attr("text-anchor","end").attr("transform",h.axis_rotated?"rotate(-90)":"").attr("dx",h.axis_rotated?0:-f.margin.top).attr("dy",-5).style("opacity",0),e=f.yv.bind(f),f.ygridLines.select("line").transition().duration(a).attr("x1",h.axis_rotated?e:0).attr("x2",h.axis_rotated?e:f.width).attr("y1",h.axis_rotated?0:e).attr("y2",h.axis_rotated?f.height:e).style("opacity",1),f.ygridLines.select("text").transition().duration(a).attr("x",h.axis_rotated?0:f.width).attr("y",e).text(function(a){return a.text}).style("opacity",1),f.ygridLines.exit().transition().duration(a).style("opacity",0).remove())},f.addTransitionForGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b);a.push(b.xgridLines.select("line").transition().attr("x1",c.axis_rotated?0:d).attr("x2",c.axis_rotated?b.width:d).attr("y1",c.axis_rotated?d:b.margin.top).attr("y2",c.axis_rotated?d:b.height).style("opacity",1)),a.push(b.xgridLines.select("text").transition().attr("x",c.axis_rotated?b.width:0).attr("y",d).text(function(a){return a.text}).style("opacity",1))},f.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&zb(a.value)}),e=b.main.selectAll("line."+yb[cb]),f=b.xx.bind(b);c.tooltip_show&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c.axis_rotated?"y1":"x1",f).attr(c.axis_rotated?"y2":"x2",f),b.smoothLines(e,"grid")))},f.hideXGridFocus=function(){this.main.select("line."+yb[cb]).style("visibility","hidden")},f.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+yb[cb]).attr("x1",b.axis_rotated?0:-10).attr("x2",b.axis_rotated?a.width:-10).attr("y1",b.axis_rotated?-10:0).attr("y2",b.axis_rotated?-10:a.height)},f.generateGridData=function(a,b){var c,d,e,f,g=this,h=[],i=g.main.select("."+yb[ib]).selectAll(".tick").size();if("year"===a)for(c=g.getXDomain(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h},f.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b.class===a.class)&&(c=!0) +}),c}:function(){return!0}},f.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},g=b?yb[bb]:yb[gb],h=b?yb[ab]:yb.ygridLine;c.main.select("."+g).selectAll("."+h).filter(e).transition().duration(d.transition_duration).style("opacity",0).remove(),b?d.grid_x_lines=d.grid_x_lines.filter(f):d.grid_y_lines=d.grid_y_lines.filter(f)},f.initTooltip=function(){var a,b=this,c=b.config;if(b.tooltip=b.selectChart.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),c.tooltip_init_show){if(b.isTimeSeries()&&Bb(c.tooltip_init_x)){for(c.tooltip_init_x=b.parseDate(c.tooltip_init_x),a=0;a"+(g||0===g?""+g+"":"")),i=n(a[f].name),h=o(a[f].value,a[f].ratio,a[f].id,a[f].index),j=k.levelColor?k.levelColor(a[f].value):d(a[f].id),e+="",e+=""+i+"",e+=""+h+"",e+="");return e+""},f.showTooltip=function(a,b){var c,d,e,f,g,h,i,j=this,k=j.config,l=j.hasArcType(),m=a.filter(function(a){return a&&zb(a.value)});0!==m.length&&k.tooltip_show&&(j.tooltip.html(k.tooltip_contents.call(j,a,j.getXAxisTickFormat(),j.getYFormat(l),j.color)).style("display","block"),c=j.tooltip.property("offsetWidth"),d=j.tooltip.property("offsetHeight"),l?(f=j.width/2+b[0],h=j.height/2+b[1]+20):(k.axis_rotated?(e=j.getSvgLeft(),f=e+b[0]+100,g=f+c,i=j.getCurrentWidth()-j.getCurrentPaddingRight(),h=j.x(m[0].x)+20):(e=j.getSvgLeft(),f=e+j.getCurrentPaddingLeft()+j.x(m[0].x)+20,g=f+c,i=e+j.getCurrentWidth()-j.getCurrentPaddingRight(),h=b[1]+15),g>i&&(f-=g-i),h+d>j.getCurrentHeight()&&h>d+30&&(h-=d+30)),j.tooltip.style("top",h+"px").style("left",f+"px"))},f.hideTooltip=function(){this.tooltip.style("display","none")},f.initLegend=function(){var a=this;a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config.legend_show||(a.legend.style("visibility","hidden"),a.hiddenLegendIds=a.mapToIds(a.data.targets)),a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},f.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d.legend_inset_y+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d.legend_inset_y,left:c.isLegendLeft?c.getCurrentPaddingLeft()+d.legend_inset_x+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d.legend_inset_x+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},f.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},f.updateLegendStep=function(a){this.legendStep=a},f.updateLegendItemWidth=function(a){this.legendItemWidth=a},f.updateLegendItemHeight=function(a){this.legendItemHeight=a},f.getLegendWidth=function(){var a=this;return a.config.legend_show?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},f.getLegendHeight=function(){var a=this,b=a.config,c=0;return b.legend_show&&(c=a.isLegendRight?a.currentHeight:a.isLegendInset?b.legend_inset_step?Math.max(20,a.legendItemHeight)*(b.legend_inset_step+1):a.height:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),c},f.opacityForLegend=function(a){var b=this;return a.classed(yb[sb])?b.legendOpacityForHidden:1},f.opacityForUnfocusedLegend=function(a){var b=this;return a.classed(yb[sb])?b.legendOpacityForHidden:.3},f.toggleFocusLegend=function(a,b){var c=this;c.legend.selectAll("."+yb[pb]).transition().duration(100).style("opacity",function(d){var e=c.d3.select(this);return a&&d!==a?b?c.opacityForUnfocusedLegend(e):c.opacityForLegend(e):b?c.opacityForLegend(e):c.opacityForUnfocusedLegend(e)})},f.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+yb[pb]).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},f.showLegend=function(a){var b=this,c=b.config;c.legend_show||(c.legend_show=!0,b.legend.style("visibility","visible")),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},f.hideLegend=function(a){var b=this,c=b.config;c.legend_show&&Hb(a)&&(c.legend_show=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},f.updateLegend=function(a,b,c){function d(b,c,d){function e(a,b){b||(f=(l-x-k)/2,w>f&&(f=(l-k)/2,x=0,D++)),C[a]=D,B[D]=q.isLegendInset?10:f,y[a]=x,x+=k}var f,g,h=q.getTextRect(b.textContent,yb[pb]),i=10*Math.ceil((h.width+t)/10),j=10*Math.ceil((h.height+s)/10),k=q.isLegendRight||q.isLegendInset?j:i,l=q.isLegendRight||q.isLegendInset?q.getLegendHeight():q.getLegendWidth();return d&&(x=0,D=0,u=0,v=0),r.legend_show&&!q.isLegendToShow(c)?void(z[c]=A[c]=C[c]=y[c]=0):(z[c]=i,A[c]=j,(!u||i>=u)&&(u=i),(!v||j>=v)&&(v=j),g=q.isLegendRight||q.isLegendInset?v:u,void(r.legend_equally?(Object.keys(z).forEach(function(a){z[a]=u}),Object.keys(A).forEach(function(a){A[a]=v}),f=(l-g*a.length)/2,w>f?(x=0,D=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var e,f,g,h,i,j,k,l,m,n,o,p,q=this,r=q.config,s=4,t=36,u=0,v=0,w=10,x=0,y={},z={},A={},B=[0],C={},D=0,E=q.legend.selectAll("."+yb[tb]).size();b=b||{},l=Jb(b,"withTransition",!0),m=Jb(b,"withTransitionForTransform",!0),q.isLegendRight?(e=function(a){return u*C[a]},h=function(a){return B[C[a]]+y[a]}):q.isLegendInset?(e=function(a){return u*C[a]+10},h=function(a){return B[C[a]]+y[a]}):(e=function(a){return B[C[a]]+y[a]},h=function(a){return v*C[a]}),f=function(a,b){return e(a,b)+14},i=function(a,b){return h(a,b)+9},g=function(a,b){return e(a,b)-4},j=function(a,b){return h(a,b)-7},k=q.legend.selectAll("."+yb[pb]).data(a).enter().append("g").attr("class",function(a){return q.generateClass(yb[pb],a)}).style("visibility",function(a){return q.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){r.legend_item_onclick?r.legend_item_onclick.call(q,a):q.api.toggle(a)}).on("mouseover",function(a){q.d3.select(this).classed(yb[tb],!0),q.transiting||q.api.focus(a),r.legend_item_onmouseover&&r.legend_item_onmouseover.call(q,a)}).on("mouseout",function(a){q.d3.select(this).classed(yb[tb],!1),q.transiting||q.api.revert(),r.legend_item_onmouseout&&r.legend_item_onmouseout.call(q,a)}),k.append("text").text(function(a){return Db(r.data_names[a])?r.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}).style("pointer-events","none").attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:i),k.append("rect").attr("class",yb[qb]).style("fill-opacity",0).attr("x",q.isLegendRight||q.isLegendInset?g:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:j),k.append("rect").attr("class",yb[rb]).style("pointer-events","none").style("fill",q.color).attr("x",q.isLegendRight||q.isLegendInset?f:-200).attr("y",q.isLegendRight||q.isLegendInset?-200:h).attr("width",10).attr("height",10),q.isLegendInset&&0!==u&&q.legend.insert("g","."+yb[pb]).attr("class",yb[ob]).append("rect").attr("height",q.getLegendHeight()-10).attr("width",u*(D+1)+10),n=q.legend.selectAll("text").data(a).text(function(a){return Db(r.data_names[a])?r.data_names[a]:a}).each(function(a,b){d(this,a,0===b)}),(l?n.transition():n).attr("x",f).attr("y",i),o=q.legend.selectAll("rect."+yb[qb]).data(a),(l?o.transition():o).attr("width",function(a){return z[a]}).attr("height",function(a){return A[a]}).attr("x",g).attr("y",j),p=q.legend.selectAll("rect."+yb[rb]).data(a),(l?p.transition():p).style("fill",q.color).attr("x",e).attr("y",h),q.legend.selectAll("."+yb[pb]).classed(yb[sb],function(a){return!q.isTargetToShow(a)}).transition().style("opacity",function(a){var b=q.d3.select(this);return q.isTargetToShow(a)?!E||b.classed(yb[tb])?q.opacityForLegend(b):q.opacityForUnfocusedLegend(b):q.legendOpacityForHidden}),q.updateLegendItemWidth(u),q.updateLegendItemHeight(v),q.updateLegendStep(D),q.updateSizes(),q.updateScales(),q.updateSvgSize(),q.transformAll(m,c)},f.initAxis=function(){var a=this,b=a.config,c=a.main,d=a.CLASS;a.axes.x=c.append("g").attr("class",d[hb]+" "+d[ib]).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b.axis_x_show?"visible":"hidden"),a.axes.x.append("text").attr("class",d[jb]).attr("transform",b.axis_rotated?"rotate(-90)":"").style("text-anchor",a.textAnchorForXAxisLabel.bind(a)),a.axes.y=c.append("g").attr("class",d[hb]+" "+d[kb]).attr("clip-path",a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b.axis_y_show?"visible":"hidden"),a.axes.y.append("text").attr("class",d[lb]).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForYAxisLabel.bind(a)),a.axes.y2=c.append("g").attr("class",d[hb]+" "+d[mb]).attr("transform",a.getTranslate("y2")).style("visibility",b.axis_y2_show?"visible":"hidden"),a.axes.y2.append("text").attr("class",d[nb]).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForY2AxisLabel.bind(a))},f.getXAxis=function(a,b,c,e){var f=this,g=f.config,h=d(f.d3,f.isCategorized()).scale(a).orient(b);return h.tickFormat(c).tickValues(e),f.isCategorized()?(h.tickCentered(g.axis_x_tick_centered),Hb(g.axis_x_tick_culling)&&(g.axis_x_tick_culling=!1)):h.tickOffset=function(){var a=f.getEdgeX(f.data.targets),b=f.x(a[1])-f.x(a[0]),c=b?b:g.axis_rotated?f.height:f.width;return c/f.getMaxDataCount()/2},h},f.getYAxis=function(a,b,c,e){return d(this.d3).scale(a).orient(b).tickFormat(c).ticks(e)},f.getAxisId=function(a){var b=this.config;return a in b.data_axes?b.data_axes[a]:"y"},f.getXAxisTickFormat=function(){var a=this,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b.axis_x_tick_format&&(Ab(b.axis_x_tick_format)?c=b.axis_x_tick_format:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b.axis_x_tick_format)(c):""})),Ab(c)?function(b){return c.call(a,b)}:c},f.getAxisLabelOptionByAxisId=function(a){var b,c=this,d=c.config;return"y"===a?b=d.axis_y_label:"y2"===a?b=d.axis_y2_label:"x"===a&&(b=d.axis_x_label),b},f.getAxisLabelText=function(a){var b=this.getAxisLabelOptionByAxisId(a);return Bb(b)?b:b?b.text:null},f.setAxisLabelText=function(a,b){var c=this,d=c.config,e=c.getAxisLabelOptionByAxisId(a);Bb(e)?"y"===a?d.axis_y_label=b:"y2"===a?d.axis_y2_label=b:"x"===a&&(d.axis_x_label=b):e&&(e.text=b)},f.getAxisLabelPosition=function(a,b){var c=this.getAxisLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},f.getXAxisLabelPosition=function(){return this.getAxisLabelPosition("x",this.config.axis_rotated?"inner-top":"inner-right")},f.getYAxisLabelPosition=function(){return this.getAxisLabelPosition("y",this.config.axis_rotated?"inner-right":"inner-top")},f.getY2AxisLabelPosition=function(){return this.getAxisLabelPosition("y2",this.config.axis_rotated?"inner-right":"inner-top")},f.getAxisLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},f.textForXAxisLabel=function(){return this.getAxisLabelText("x")},f.textForYAxisLabel=function(){return this.getAxisLabelText("y")},f.textForY2AxisLabel=function(){return this.getAxisLabelText("y2")},f.xForAxisLabel=function(a,b){var c=this;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},f.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},f.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},f.xForXAxisLabel=function(){return this.xForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.xForYAxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.xForY2AxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},f.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},f.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},f.dyForXAxisLabel=function(){var a=this,b=a.config,c=a.getXAxisLabelPosition();return b.axis_rotated?c.isInner?"1.2em":-25-a.getMaxTickWidth("x"):c.isInner?"-0.5em":b.axis_x_height?b.axis_x_height-10:"3em"},f.dyForYAxisLabel=function(){var a=this,b=a.getYAxisLabelPosition();return a.config.axis_rotated?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-20-a.getMaxTickWidth("y")},f.dyForY2AxisLabel=function(){var a=this,b=a.getY2AxisLabelPosition();return a.config.axis_rotated?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":30+this.getMaxTickWidth("y2")},f.textAnchorForXAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(!a.config.axis_rotated,a.getXAxisLabelPosition())},f.textAnchorForYAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getYAxisLabelPosition())},f.textAnchorForY2AxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getY2AxisLabelPosition())},f.xForRotatedTickText=function(a){return 10*Math.sin(Math.PI*(a/180))},f.yForRotatedTickText=function(a){return 11.5-2.5*(a/15)},f.rotateTickText=function(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",this.yForRotatedTickText(c)).attr("x",this.xForRotatedTickText(c)).attr("transform","rotate("+c+")")},f.getMaxTickWidth=function(a){var b,c,d,e=this,f=e.config,g=0;return e.svg&&(b=e.filterTargetsToShow(e.data.targets),"y"===a?(c=e.y.copy().domain(e.getYDomain(b,"y")),d=e.getYAxis(c,e.yOrient,f.axis_y_tick_format,f.axis_y_ticks)):"y2"===a?(c=e.y2.copy().domain(e.getYDomain(b,"y2")),d=e.getYAxis(c,e.y2Orient,f.axis_y2_tick_format,f.axis_y2_ticks)):(c=e.x.copy().domain(e.getXDomain(b)),d=e.getXAxis(c,e.xOrient,e.getXAxisTickFormat(),f.axis_x_tick_values?f.axis_x_tick_values:e.xAxis.tickValues())),e.main.append("g").call(d).each(function(){e.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();g=g?e.currentMaxTickWidth:g,e.currentMaxTickWidth},f.updateAxisLabels=function(a){var b=this,c=b.main.select("."+yb[ib]+" ."+yb[jb]),d=b.main.select("."+yb[kb]+" ."+yb[lb]),e=b.main.select("."+yb[mb]+" ."+yb[nb]);(a?c.transition():c).attr("x",b.xForXAxisLabel.bind(b)).attr("dx",b.dxForXAxisLabel.bind(b)).attr("dy",b.dyForXAxisLabel.bind(b)).text(b.textForXAxisLabel.bind(b)),(a?d.transition():d).attr("x",b.xForYAxisLabel.bind(b)).attr("dx",b.dxForYAxisLabel.bind(b)).attr("dy",b.dyForYAxisLabel.bind(b)).text(b.textForYAxisLabel.bind(b)),(a?e.transition():e).attr("x",b.xForY2AxisLabel.bind(b)).attr("dx",b.dxForY2AxisLabel.bind(b)).attr("dy",b.dyForY2AxisLabel.bind(b)).text(b.textForY2AxisLabel.bind(b))},f.getAxisPadding=function(a,b,c,d){var e="ratio"===a.unit?d:1;return zb(a[b])?a[b]*e:c},f.generateTickValues=function(a,b){var c,d,e,f,g,h,i,j=this,k=a;if(b)if(c=Ab(b)?b():b,1===c)k=[a[0]];else if(2===c)k=[a[0],a[a.length-1]];else if(c>2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),k=[d],h=0;f>h;h++)i=+d+g*(h+1),k.push(j.isTimeSeries()?new Date(i):i);k.push(e)}return j.isTimeSeries()||(k=k.sort(function(a,b){return a-b})),k},f.generateAxisTransitions=function(a){var b=this,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},f.redrawAxis=function(a,b){var c=this;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},f.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},f.getAxisClipX=function(a){return a?-31:-(this.margin.left-1)},f.getAxisClipY=function(a){return a?-20:-4},f.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config.axis_rotated)},f.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config.axis_rotated)},f.getYAxisClipX=function(){var a=this;return a.getAxisClipX(a.config.axis_rotated)},f.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config.axis_rotated)},f.getAxisClipWidth=function(a){var b=this;return a?b.width+2+30+30:b.margin.left+20},f.getAxisClipHeight=function(a){var b=this,c=b.config;return a?(c.axis_x_height?c.axis_x_height:0)+80:b.height+8},f.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config.axis_rotated)},f.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config.axis_rotated)},f.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config.axis_rotated)},f.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config.axis_rotated)},f.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c.data_order&&c.pie_sort&&c.donut_sort||a.pie.sort(null)},f.updateRadius=function(){var a=this,b=a.config,c=b.gauge_width||b.donut_width;a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},f.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},f.updateAngle=function(a){var b=this,c=b.config,d=!1,e=0;if(b.pie(b.filterTargetsToShow(b.data.targets)).sort(b.descByStartAngle).forEach(function(b){d||b.data.id!==a.data.id||(d=!0,a=b,a.index=e),e++}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),b.isGaugeType(a.data)){var f=c.gauge_min,g=c.gauge_max,h=Math.abs(f)+g,i=Math.PI/h;a.startAngle=-1*(Math.PI/2)+i*Math.abs(f),a.endAngle=a.startAngle+i*(a.value>g?g:a.value)}return d?a:null},f.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},f.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},f.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},f.transformForArcLabel=function(a){var b,c,d,e,f,g=this,h=g.updateAngle(a),i="";return h&&!g.hasType("gauge")&&(b=this.svgArc.centroid(h),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=g.radius&&e?(36/g.radius>.375?1.175-36/g.radius:.8)*g.radius/e:0,i="translate("+c*f+","+d*f+")"),i},f.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},f.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},f.textForArcLabel=function(a){var b,c,d,e,f=this;return f.shouldShowArcLabel()?(b=f.updateAngle(a),c=b?b.value:null,d=f.getArcRatio(b),f.hasType("gauge")||f.meetsArcLabelThreshold(d)?(e=f.getArcLabelFormat(),e?e(c,d):f.defaultArcValueFormat(c,d)):""):""},f.expandArc=function(a,b){var c=this,d=c.svg.selectAll("."+yb[p]+c.selectorTarget(a)),e=c.svg.selectAll("."+yb[R]).filter(function(b){return b.data.id!==a});c.shouldExpand(a)&&d.selectAll("path").transition().duration(50).attr("d",c.svgArcExpanded).transition().duration(100).attr("d",c.svgArcExpandedSub).each(function(a){c.isDonutType(a.data)}),b||e.style("opacity",.3)},f.unexpandArc=function(a){var b=this,c=b.svg.selectAll("."+yb[p]+b.selectorTarget(a));c.selectAll("path."+yb[R]).transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+yb[R]).style("opacity",1)},f.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c.donut_expand||b.isGaugeType(a)&&c.gauge_expand||b.isPieType(a)&&c.pie_expand},f.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b.donut_label_show:a.hasType("pie")&&(c=b.pie_label_show),c},f.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c.donut_label_threshold:c.pie_label_threshold;return a>=d},f.getArcLabelFormat=function(){var a=this,b=a.config,c=b.pie_label_format;return a.hasType("gauge")?c=b.gauge_label_format:a.hasType("donut")&&(c=b.donut_label_format),c},f.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config.donut_title:""},f.descByStartAngle=function(a,b){return a.startAngle-b.startAngle},f.updateTargetsForArc=function(a){var b,c,d=this,e=d.main,f=d.classChartArc.bind(d),g=d.classArcs.bind(d);b=e.select("."+yb[q]).selectAll("."+yb[p]).data(d.pie(a)).attr("class",f),c=b.enter().append("g").attr("class",f),c.append("g").attr("class",g),c.append("text").attr("dy",d.hasType("gauge")?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},f.initArc=function(){var a=this;a.arcs=a.main.select("."+yb[i]).append("g").attr("class",yb[q]).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",yb[r]).style("text-anchor","middle").text(a.getArcTitle())},f.redrawArc=function(a,b,c){var d,e=this,f=e.d3,g=e.config,h=e.main;d=h.selectAll("."+yb[S]).selectAll("."+yb[R]).data(e.arcData.bind(e)),d.enter().append("path").attr("class",e.classArc.bind(e)).style("fill",function(a){return e.color(a.data)}).style("cursor",function(a){return g.data_selection_isselectable(a)?"pointer":null}).style("opacity",0).each(function(a){e.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.expandArc(b.data.id),e.toggleFocusLegend(b.data.id,!0),e.config.data_onmouseover(c,this))}).on("mousemove",function(a){var b=e.updateAngle(a),c=e.convertToArcData(b),d=[c];e.showTooltip(d,f.mouse(this))}).on("mouseout",function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.unexpandArc(b.data.id),e.revertLegend(),e.hideTooltip(),e.config.data_onmouseout(c,this))}).on("click",function(a,b){var c,d;e.toggleShape&&(c=e.updateAngle(a),d=e.convertToArcData(c),e.toggleShape(this,d,b))}),d.attr("transform",function(a){return!e.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){e.transiting=!0}).transition().duration(a).attrTween("d",function(a){var b,c=e.updateAngle(a);return c?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=f.interpolate(this._current,c),this._current=b(0),function(a){return e.getArc(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return e.levelColor?e.levelColor(a.data.values[0].value):e.color(a.data.id)}).style("opacity",1).call(e.endall,function(){e.transiting=!1}),d.exit().transition().duration(b).style("opacity",0).remove(),h.selectAll("."+yb[p]).select("text").style("opacity",0).attr("class",function(a){return e.isGaugeType(a.data)?yb[Y]:""}).text(e.textForArcLabel.bind(e)).attr("transform",e.transformForArcLabel.bind(e)).transition().duration(a).style("opacity",function(a){return e.isTargetToShow(a.data.id)&&e.isArcType(a.data)?1:0}),h.select("."+yb[r]).style("opacity",e.hasType("donut")||e.hasType("gauge")?1:0)},f.initGauge=function(){var a=this,b=a.config,c=a.arcs;a.hasType("gauge")&&(c.append("path").attr("class",yb[s]).attr("d",function(){var c={data:[{value:b.gauge_max}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return a.getArc(c,!0,!0)}),c.append("text").attr("dy",".75em").attr("class",yb[t]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_units:""),c.append("text").attr("dx",-1*(a.innerRadius+(a.radius-a.innerRadius)/2)+"px").attr("dy","1.2em").attr("class",yb[v]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_min:""),c.append("text").attr("dx",a.innerRadius+(a.radius-a.innerRadius)/2+"px").attr("dy","1.2em").attr("class",yb[u]).style("text-anchor","middle").style("pointer-events","none").text(b.gauge_label_show?b.gauge_max:""))},f.initRegion=function(){var a=this,b=a.CLASS;a.main.append("g").attr("clip-path",a.clipPath).attr("class",b[G])},f.redrawRegion=function(a){var b=this,c=b.config,d=b.CLASS;b.mainRegion=b.main.select("."+d[G]).selectAll("."+d[F]).data(c.regions),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},f.addTransitionForRegion=function(a){var b=this,c=b.regionX.bind(b),d=b.regionY.bind(b),e=b.regionWidth.bind(b),f=b.regionHeight.bind(b);a.push(b.mainRegion.selectAll("rect").transition().attr("x",c).attr("y",d).attr("width",e).attr("height",f).style("fill-opacity",function(a){return zb(a.opacity)?a.opacity:.1}))},f.regionX=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"start"in a?e(a.start):0:0:d.axis_rotated?0:"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},f.regionY=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?0:"end"in a?e(a.end):0:d.axis_rotated?"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0:0},f.regionWidth=function(a){var b,c=this,d=c.config,e=c.regionX(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?"end"in a?f(a.end):c.width:c.width:d.axis_rotated?c.width:"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.width,e>b?0:b-e},f.regionHeight=function(a){var b,c=this,d=c.config,e=this.regionY(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?c.height:"start"in a?f(a.start):c.height:d.axis_rotated?"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.height:c.height,e>b?0:b-e},f.isRegionOnX=function(a){return!a.axis||"x"===a.axis},f.drag=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.config,l=j.main,m=j.d3;j.hasArcType()||k.data_selection_enabled&&(!k.zoom_enabled||j.zoom.altDomain)&&k.data_selection_multiple&&(b=j.dragStart[0],c=j.dragStart[1],d=a[0],e=a[1],f=Math.min(b,d),g=Math.max(b,d),h=k.data_selection_grouped?j.margin.top:Math.min(c,e),i=k.data_selection_grouped?j.height:Math.max(c,e),l.select("."+yb[ub]).attr("x",f).attr("y",h).attr("width",g-f).attr("height",i-h),l.selectAll("."+yb[K]).selectAll("."+yb[J]).filter(function(a){return k.data_selection_isselectable(a)}).each(function(a,b){var c,d,e,k,l,n,o=m.select(this),p=o.classed(yb[wb]),q=o.classed(yb[xb]),r=!1;if(o.classed(yb[P]))c=1*o.attr("cx"),d=1*o.attr("cy"),l=j.togglePoint,r=c>f&&g>c&&d>h&&i>d;else{if(!o.classed(yb[N]))return;n=Lb(this),c=n.x,d=n.y,e=n.width,k=n.height,l=j.toggleBar,r=!(c>g||f>c+e||d>i||h>d+k)}r^q&&(o.classed(yb[xb],!q),o.classed(yb[wb],!p),l.call(j,!p,o,a,b))}))},f.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c.data_selection_enabled&&(b.dragStart=a,b.main.select("."+yb[i]).append("rect").attr("class",yb[ub]).style("opacity",.1),b.dragging=!0,b.config.data_ondragstart())},f.dragend=function(){var a=this,b=a.config;a.hasArcType()||b.data_selection_enabled&&(a.main.select("."+yb[ub]).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+yb[J]).classed(yb[xb],!1),a.dragging=!1,a.config.data_ondragend())},f.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e.axis_rotated?d.circleY:d.circleX).bind(d),g=(e.axis_rotated?d.circleX:d.circleY).bind(d),h=d.pointSelectR.bind(d);e.data_onselected.call(d.api,b,a.node()),d.main.select("."+yb[x]+d.getTargetSelectorSuffix(b.id)).selectAll("."+yb[w]+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(yb[w],c)}).attr("cx",f).attr("cy",g).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",h)},f.unselectPoint=function(a,b,c){var d=this;d.config.data_onunselected(b,a.node()),d.main.select("."+yb[x]+d.getTargetSelectorSuffix(b.id)).selectAll("."+yb[w]+"-"+c).transition().duration(100).attr("r",0).remove()},f.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},f.selectBar=function(a,b){var c=this;c.config.data_onselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},f.unselectBar=function(a,b){var c=this;c.config.data_onunselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},f.toggleBar=function(a,b,c,d){a?this.selectBar(b,c,d):this.unselectBar(b,c,d)},f.toggleArc=function(a,b,c,d){this.toggleBar(a,b,c.data,d)},f.getToggle=function(a){var b=this;return"circle"===a.nodeName?b.togglePoint:b.d3.select(a).classed(yb[N])?b.toggleBar:b.toggleArc},f.toggleShape=function(a,b,c){var d,e,f=this,g=f.d3,h=f.config,i=g.select(a),j=i.classed(yb[wb]);"circle"===a.nodeName?(d=f.isWithinCircle(a,1.5*f.pointSelectR(b)),e=f.togglePoint):"path"===a.nodeName&&(i.classed(yb[N])?(d=f.isWithinBar(a),e=f.toggleBar):(d=!0,e=f.toggleArc)),(h.data_selection_grouped||d)&&(h.data_selection_enabled&&h.data_selection_isselectable(b)&&(h.data_selection_multiple||f.main.selectAll("."+yb[K]+(h.data_selection_grouped?f.getTargetSelectorSuffix(b.id):"")).selectAll("."+yb[J]).each(function(a,b){var c=g.select(this);c.classed(yb[wb])&&e.call(f,!1,c.classed(yb[wb],!1),a,b)}),i.classed(yb[wb],!j),e.call(f,!j,i,b,c)),f.config.data_onclick.call(f.api,b,a))},f.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+a.CLASS[D]).call(this),this},a.brush.scale=function(b){return a.config.axis_rotated?this.y(b):this.x(b)}},f.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));b.subchart_show||c.style("visibility","hidden"),c.append("g").attr("clip-path",a.clipPath).attr("class",yb[i]),c.select("."+yb[i]).append("g").attr("class",yb[m]),c.select("."+yb[i]).append("g").attr("class",yb[k]),c.append("g").attr("clip-path",a.clipPath).attr("class",yb[D]).call(a.brush).selectAll("rect").attr(b.axis_rotated?"width":"height",b.axis_rotated?a.width2:a.height2),a.axes.subx=c.append("g").attr("class",yb[ib]).attr("transform",a.getTranslate("subx")).attr("clip-path",b.axis_rotated?"":a.clipPathForXAxis)},f.updateTargetsForSubchart=function(a){var b,c,d,e,f=this,g=f.context,h=f.config,i=f.classChartBar.bind(f),n=f.classBars.bind(f),o=f.classChartLine.bind(f),p=f.classLines.bind(f),q=f.classAreas.bind(f); +h.subchart_show&&(e=g.select("."+yb[m]).selectAll("."+yb[l]).data(a).attr("class",i),d=e.enter().append("g").style("opacity",0).attr("class",i),d.append("g").attr("class",n),c=g.select("."+yb[k]).selectAll("."+yb[j]).data(a).attr("class",o),b=c.enter().append("g").style("opacity",0).attr("class",o),b.append("g").attr("class",p),b.append("g").attr("class",q))},f.redrawSubchart=function(a,b,c,d,e,f,g){var h,i,j,k,l,m,n=this,o=n.d3,p=n.context,q=n.config,r=n.barData.bind(n),s=n.lineData.bind(n),t=n.classBar.bind(n),u=n.classLine.bind(n),v=n.classArea.bind(n),w=n.initialOpacity.bind(n);q.subchart_show&&(o.event&&"zoom"===o.event.type&&n.brush.extent(n.x.orgDomain()).update(),a&&(!q.axis_rotated&&q.axis_x_tick_rotate&&n.rotateTickText(n.axes.subx,b.axisSubX,q.axis_x_tick_rotate),n.brush.empty()||n.brush.extent(n.x.orgDomain()).update(),k=n.generateDrawArea(e,!0),l=n.generateDrawBar(f,!0),m=n.generateDrawLine(g,!0),j=p.selectAll("."+yb[O]).selectAll("."+yb[N]).data(r),j.enter().append("path").attr("class",t).style("stroke","none").style("fill",n.color),j.style("opacity",w).transition().duration(c).attr("d",l).style("opacity",1),j.exit().transition().duration(c).style("opacity",0).remove(),h=p.selectAll("."+yb[M]).selectAll("."+yb[L]).data(s),h.enter().append("path").attr("class",u).style("stroke",n.color),h.style("opacity",w).transition().duration(c).attr("d",m).style("opacity",1),h.exit().transition().duration(c).style("opacity",0).remove(),i=p.selectAll("."+yb[U]).selectAll("."+yb[T]).data(s),i.enter().append("path").attr("class",v).style("fill",n.color).style("opacity",function(){return n.orgAreaOpacity=+o.select(this).style("opacity"),0}),i.style("opacity",0).transition().duration(c).attr("d",k).style("fill",n.color).style("opacity",n.orgAreaOpacity),i.exit().transition().duration(d).style("opacity",0).remove()))},f.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0}),a.config.subchart_onbrush.call(a.api,b.orgDomain())},f.transformContext=function(a,b){var c,d=this;b&&b.axisSubX?c=b.axisSubX:(c=d.context.select("."+yb[ib]),a&&(c=c.transition())),d.context.attr("transform",d.getTranslate("context")),c.attr("transform",d.getTranslate("subx"))},f.initZoom=function(){var a=this,b=a.d3,c=a.config;a.zoom=b.behavior.zoom().on("zoomstart",function(){a.zoom.altDomain=b.event.sourceEvent.altKey?a.x.orgDomain():null}).on("zoom",function(){a.redrawForZoom.call(a)}),a.zoom.scale=function(a){return c.axis_rotated?this.y(a):this.x(a)},a.zoom.orgScaleExtent=function(){var b=c.zoom_extent?c.zoom_extent:[1,10];return[b[0],Math.max(a.getMaxDataCount()/b[1],b[1])]},a.zoom.updateScaleExtent=function(){var b=Gb(a.x.orgDomain())/Gb(a.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*b,c[1]*b]),this}},f.updateZoom=function(){var a=this,b=a.config.zoom_enabled?a.zoom:function(){};a.main.select("."+a.CLASS[C]).call(b),a.main.selectAll("."+a.CLASS[y]).call(b)},f.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x,f=a.orgXDomain;if(c.zoom_enabled&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),void d.scale(e).updateScaleExtent();a.isCategorized()&&e.orgDomain()[0]===f[0]&&e.domain([f[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c.zoom_onzoom.call(a.api,e.orgDomain())}},f.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b.data_colors,e=Ib(b.color_pattern)?b.color_pattern:c.scale.category10().range(),f=b.data_color,g=[];return function(a){var b,c=a.id||a;return d[c]instanceof Function?b=d[c](a):d[c]?b=d[c]:(g.indexOf(c)<0&&g.push(c),b=e[g.indexOf(c)%e.length],d[c]=b),f instanceof Function?f(b,a):b}},f.generateLevelColor=function(){var a=this,b=a.config,c=b.color_pattern,d=b.color_threshold,e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return Ib(b.color_threshold)?function(a){var b,d,h=c[c.length-1];for(b=0;b0},Jb=f.getOption=function(a,b,c){return Db(a[b])?a[b]:c},Kb=f.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},Lb=f.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};e.focus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),this.defocus(),b(e.classed(yb[E],!0)),b(f),c.hasArcType()&&c.expandArc(a,!0),c.toggleFocusLegend(a,!0)},e.defocus=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",.3)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));this.revert(),b(e.classed(yb[E],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.toggleFocusLegend(a,!1)},e.revert=function(a){function b(a){c.filterTargetsToShow(a).transition().duration(100).style("opacity",1)}var c=this.internal,d=c.svg.selectAll(c.selectorTarget(a)),e=d.filter(c.isNoneArc.bind(c)),f=d.filter(c.isArc.bind(c));b(e.classed(yb[E],!1)),b(f),c.hasArcType()&&c.unexpandArc(a),c.revertLegend()},e.show=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.removeHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",1),b.withLegend&&c.showLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.hide=function(a,b){var c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.addHiddenTargetIds(a),c.svg.selectAll(c.selectorTargets(a)).transition().style("opacity",0),b.withLegend&&c.hideLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},e.toggle=function(a){var b=this.internal;b.isTargetToShow(a)?this.hide(a):this.show(a)},e.zoom=function(){},e.zoom.enable=function(a){var b=this.internal;b.config.zoom_enabled=a,b.updateAndRedraw()},e.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},e.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c.data_classes[b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c.axis_x_categories=a.categories),"cacheIds"in a&&b.hasCaches(a.cacheIds)?void b.load(b.getCaches(a.cacheIds),a.done):void("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a))},e.unload=function(a){var b=this.internal;a=a||{},b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},e.flow=function(a){var b,c,d,e,f,g,h,i,j=this.internal,k=[],l=j.getMaxDataCount(),m=0,n=0;if(a.json)c=j.convertJsonToData(a.json,a.keys);else if(a.rows)c=j.convertRowsToData(a.rows);else{if(!a.columns)return;c=j.convertColumnsToData(a.columns)}b=j.convertDataToTargets(c,!0),j.data.targets.forEach(function(a){var c,d,e=!1;for(c=0;cd;d++)b[c].values[d].index=n+d,j.isTimeSeries()||(b[c].values[d].x=n+d);a.values=a.values.concat(b[c].values),b.splice(c,1);break}e||k.push(a.id)}),j.data.targets.forEach(function(a){var b,c;for(b=0;bc;c++)a.values.push({id:a.id,index:n+c,x:j.isTimeSeries()?j.getOtherTargetX(n+c):n+c,value:null})}),j.data.targets.length&&b.forEach(function(a){var b,c=[];for(b=j.data.targets[0].values[0].index;n>b;b++)c.push({id:a.id,index:b,x:j.isTimeSeries()?j.getOtherTargetX(b):b,value:null});a.values.forEach(function(a){a.index+=n,j.isTimeSeries()||(a.x+=n)}),a.values=c.concat(a.values)}),j.data.targets=j.data.targets.concat(b),d=j.getMaxDataCount(),f=j.data.targets[0],g=f.values[0],Db(a.to)?(m=0,i=j.isTimeSeries()?j.parseDate(a.to):a.to,f.values.forEach(function(a){a.x1?f.values[f.values.length-1].x-g.x:g.x-j.getXDomain(j.data.targets)[0]:1,e=[g.x-h,g.x],j.updateXDomain(null,!0,!0,e)),j.updateTargets(j.data.targets),j.redraw({flow:{index:g.index,length:m,duration:zb(a.duration)?a.duration:j.config.transition_duration,done:a.done,orgDataCount:l},withLegend:!0,withTransition:l>1})},f.generateFlow=function(a){var b=this,c=b.config,d=b.d3,e=b.CLASS;return function(){var f,g,h,i=a.targets,j=a.flow,k=a.drawBar,l=a.drawLine,m=a.drawArea,n=a.cx,o=a.cy,p=a.xv,q=a.xForText,r=a.yForText,s=a.duration,t=1,u=j.index,v=j.length,w=b.getValueOnIndex(b.data.targets[0].values,u),x=b.getValueOnIndex(b.data.targets[0].values,u+v),A=b.x.domain(),B=j.duration||s,C=j.done||function(){},D=b.generateWait(),E=b.xgrid||d.selectAll([]),F=b.xgridLines||d.selectAll([]),G=b.mainRegion||d.selectAll([]),H=b.mainText||d.selectAll([]),I=b.mainBar||d.selectAll([]),L=b.mainLine||d.selectAll([]),M=b.mainArea||d.selectAll([]),N=b.mainCircle||d.selectAll([]);b.data.targets.forEach(function(a){a.values.splice(0,v)}),h=b.updateXDomain(i,!0,!0),b.updateXGrid&&b.updateXGrid(!0),j.orgDataCount?f=1===j.orgDataCount||w.x===x.x?b.x(A[0])-b.x(h[0]):b.isTimeSeries()?b.x(A[0])-b.x(h[0]):b.x(w.x)-b.x(x.x):1!==b.data.targets[0].values.length?f=b.x(A[0])-b.x(h[0]):b.isTimeSeries()?(w=b.getValueOnIndex(b.data.targets[0].values,0),x=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),f=b.x(w.x)-b.x(x.x)):f=Gb(h)/2,t=Gb(A)/Gb(h),g="translate("+f+",0) scale("+t+",1)",d.transition().ease("linear").duration(B).each(function(){D.add(b.axes.x.transition().call(b.xAxis)),D.add(I.transition().attr("transform",g)),D.add(L.transition().attr("transform",g)),D.add(M.transition().attr("transform",g)),D.add(N.transition().attr("transform",g)),D.add(H.transition().attr("transform",g)),D.add(G.filter(b.isRegionOnX).transition().attr("transform",g)),D.add(E.transition().attr("transform",g)),D.add(F.transition().attr("transform",g))}).call(D,function(){var a,d=[],f=[],g=[];if(v){for(a=0;v>a;a++)d.push("."+e[J]+"-"+(u+a)),f.push("."+e[W]+"-"+(u+a)),g.push("."+e[y]+"-"+(u+a));b.svg.selectAll("."+e[K]).selectAll(d).remove(),b.svg.selectAll("."+e[X]).selectAll(f).remove(),b.svg.selectAll("."+e[z]).selectAll(g).remove(),b.svg.select("."+e[$]).remove()}E.attr("transform",null).attr(b.xgridAttr),F.attr("transform",null),F.select("line").attr("x1",c.axis_rotated?0:p).attr("x2",c.axis_rotated?b.width:p),F.select("text").attr("x",c.axis_rotated?b.width:0).attr("y",p),I.attr("transform",null).attr("d",k),L.attr("transform",null).attr("d",l),M.attr("transform",null).attr("d",m),N.attr("transform",null).attr("cx",n).attr("cy",o),H.attr("transform",null).attr("x",q).attr("y",r).style("fill-opacity",b.opacityForText.bind(b)),G.attr("transform",null),G.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),b.updateEventRect(),C()})}},e.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+yb[K]+b.getTargetSelectorSuffix(a)).selectAll("."+yb[J]).filter(function(){return c.select(this).classed(yb[wb])}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},e.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f.data_selection_enabled&&d.main.selectAll("."+yb[K]).selectAll("."+yb[J]).each(function(g,h){var i=e.select(this),j=g.data?g.data.id:g.id,k=d.getToggle(this),l=f.data_selection_grouped||!a||a.indexOf(j)>=0,m=!b||b.indexOf(h)>=0,n=i.classed(yb[wb]);i.classed(yb[L])||i.classed(yb[T])||(l&&m?f.data_selection_isselectable(g)&&!n&&k(!0,i.classed(yb[wb],!0),g,h):Db(c)&&c&&n&&k(!1,i.classed(yb[wb],!1),g,h))})},e.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e.data_selection_enabled&&c.main.selectAll("."+yb[K]).selectAll("."+yb[J]).each(function(f,g){var h=d.select(this),i=f.data?f.data.id:f.id,j=c.getToggle(this),k=e.data_selection_grouped||!a||a.indexOf(i)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(yb[wb]);h.classed(yb[L])||h.classed(yb[T])||k&&l&&e.data_selection_isselectable(f)&&m&&j(!1,h.classed(yb[wb],!1),f,g)})},e.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},f.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateAndRedraw(f)},e.groups=function(a){var b=this.internal,c=b.config;return Cb(a)?c.data_groups:(c.data_groups=a,b.redraw(),c.data_groups)},e.xgrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_x_lines=a,b.redraw(),c.grid_x_lines):c.grid_x_lines},e.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config.grid_x_lines.concat(a?a:[]))},e.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},e.ygrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_y_lines=a,b.redraw(),c.grid_y_lines):c.grid_y_lines},e.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config.grid_y_lines.concat(a?a:[]))},e.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},e.regions=function(a){var b=this.internal,c=b.config;return a?(c.regions=a,b.redraw(),c.regions):c.regions},e.regions.add=function(a){var b=this.internal,c=b.config;return a?(c.regions=c.regions.concat(a),b.redraw(),c.regions):c.regions},e.regions.remove=function(a){var b,c,d,e=this.internal,f=e.config;return a=a||{},b=e.getOption(a,"duration",f.transition_duration),c=e.getOption(a,"classes",[yb[F]]),d=e.main.select("."+yb[G]).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),f.regions=f.regions.filter(function(a){var b=!1;return a.class?(a.class.split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0}),f.regions},e.data=function(){},e.data.get=function(a){var b=this.data.getAsTarget(a);return Db(b)?b.values.map(function(a){return a.value}):void 0},e.data.getAsTarget=function(a){var b=this.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:void 0},e.data.names=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_names[b]=a[b]}),b.redraw({withLegend:!0}),c.data_names):c.data_names},e.data.colors=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_colors[b]=a[b]}),b.redraw({withLegend:!0}),c.data_colors):c.data_colors},e.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d.axis_x_categories[a]=b,c.redraw()),d.axis_x_categories[a]},e.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c.axis_x_categories=a,b.redraw(),c.axis_x_categories):c.axis_x_categories},e.color=function(a){var b=this.internal;return b.color(a)},e.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},e.axis=function(){},e.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.setAxisLabelText(c,a[c])}),b.updateAxisLabels())},e.axis.max=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(zb(a.x)&&(c.axis_x_max=a.x),zb(a.y)&&(c.axis_y_max=a.y),zb(a.y2)&&(c.axis_y2_max=a.y2)):c.axis_y_max=c.axis_y2_max=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.min=function(a){var b=this.internal,c=b.config;arguments.length&&("object"==typeof a?(zb(a.x)&&(c.axis_x_min=a.x),zb(a.y)&&(c.axis_y_min=a.y),zb(a.y2)&&(c.axis_y2_min=a.y2)):c.axis_y_min=c.axis_y2_min=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},e.axis.range=function(a){arguments.length&&(Db(a.max)&&this.axis.max(a.max),Db(a.min)&&this.axis.min(a.min))},e.legend=function(){},e.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},e.resize=function(a){var b=this.internal,c=b.config;c.size_width=a?a.width:null,c.size_height=a?a.height:null,this.flush()},e.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},e.destroy=function(){var b=this.internal;b.data.targets=void 0,b.data.xs={},b.selectChart.classed("c3",!1).html(""),a.onresize=null},"function"==typeof define&&define.amd?define("c3",["d3"],g):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=g:a.c3=g}(window); \ No newline at end of file diff --git a/src/api.axis.js b/src/api.axis.js index 104a69b..775ac1f 100644 --- a/src/api.axis.js +++ b/src/api.axis.js @@ -13,11 +13,11 @@ c3_chart_fn.axis.max = function (max) { var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof max === 'object') { - if (isValue(max.x)) { config[__axis_x_max] = max.x; } - if (isValue(max.y)) { config[__axis_y_max] = max.y; } - if (isValue(max.y2)) { config[__axis_y2_max] = max.y2; } + if (isValue(max.x)) { config.axis_x_max = max.x; } + if (isValue(max.y)) { config.axis_y_max = max.y; } + if (isValue(max.y2)) { config.axis_y2_max = max.y2; } } else { - config[__axis_y_max] = config[__axis_y2_max] = max; + config.axis_y_max = config.axis_y2_max = max; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } @@ -26,11 +26,11 @@ c3_chart_fn.axis.min = function (min) { var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof min === 'object') { - if (isValue(min.x)) { config[__axis_x_min] = min.x; } - if (isValue(min.y)) { config[__axis_y_min] = min.y; } - if (isValue(min.y2)) { config[__axis_y2_min] = min.y2; } + if (isValue(min.x)) { config.axis_x_min = min.x; } + if (isValue(min.y)) { config.axis_y_min = min.y; } + if (isValue(min.y2)) { config.axis_y2_min = min.y2; } } else { - config[__axis_y_min] = config[__axis_y2_min] = min; + config.axis_y_min = config.axis_y2_min = min; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } diff --git a/src/api.category.js b/src/api.category.js index 8fca10a..1616c4a 100644 --- a/src/api.category.js +++ b/src/api.category.js @@ -1,15 +1,15 @@ c3_chart_fn.category = function (i, category) { var $$ = this.internal, config = $$.config; if (arguments.length > 1) { - config[__axis_x_categories][i] = category; + config.axis_x_categories[i] = category; $$.redraw(); } - return config[__axis_x_categories][i]; + return config.axis_x_categories[i]; }; c3_chart_fn.categories = function (categories) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__axis_x_categories]; } - config[__axis_x_categories] = categories; + if (!arguments.length) { return config.axis_x_categories; } + config.axis_x_categories = categories; $$.redraw(); - return config[__axis_x_categories]; + return config.axis_x_categories; }; diff --git a/src/api.chart.js b/src/api.chart.js index ee15243..ad4d170 100644 --- a/src/api.chart.js +++ b/src/api.chart.js @@ -1,7 +1,7 @@ c3_chart_fn.resize = function (size) { var $$ = this.internal, config = $$.config; - config[__size_width] = size ? size.width : null; - config[__size_height] = size ? size.height : null; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; this.flush(); }; diff --git a/src/api.data.js b/src/api.data.js index c6f6da3..b761eaa 100644 --- a/src/api.data.js +++ b/src/api.data.js @@ -9,19 +9,19 @@ c3_chart_fn.data.getAsTarget = function (targetId) { }; c3_chart_fn.data.names = function (names) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__data_names]; } + if (!arguments.length) { return config.data_names; } Object.keys(names).forEach(function (id) { - config[__data_names][id] = names[id]; + config.data_names[id] = names[id]; }); $$.redraw({withLegend: true}); - return config[__data_names]; + return config.data_names; }; c3_chart_fn.data.colors = function (colors) { var $$ = this.internal, config = $$.config; - if (!arguments.length) { return config[__data_colors]; } + if (!arguments.length) { return config.data_colors; } Object.keys(colors).forEach(function (id) { - config[__data_colors][id] = colors[id]; + config.data_colors[id] = colors[id]; }); $$.redraw({withLegend: true}); - return config[__data_colors]; + return config.data_colors; }; diff --git a/src/api.flow.js b/src/api.flow.js index 3b0e3a2..861b678 100644 --- a/src/api.flow.js +++ b/src/api.flow.js @@ -130,7 +130,7 @@ c3_chart_fn.flow = function (args) { flow: { index: baseValue.index, length: length, - duration: isValue(args.duration) ? args.duration : $$.config[__transition_duration], + duration: isValue(args.duration) ? args.duration : $$.config.transition_duration, done: args.done, orgDataCount: orgDataCount, }, @@ -243,10 +243,10 @@ c3_chart_internal_fn.generateFlow = function (args) { xgridLines .attr('transform', null); xgridLines.select('line') - .attr("x1", config[__axis_rotated] ? 0 : xv) - .attr("x2", config[__axis_rotated] ? $$.width : xv); + .attr("x1", config.axis_rotated ? 0 : xv) + .attr("x2", config.axis_rotated ? $$.width : xv); xgridLines.select('text') - .attr("x", config[__axis_rotated] ? $$.width : 0) + .attr("x", config.axis_rotated ? $$.width : 0) .attr("y", xv); mainBar .attr('transform', null) diff --git a/src/api.grid.js b/src/api.grid.js index 5d38050..52db2ea 100644 --- a/src/api.grid.js +++ b/src/api.grid.js @@ -1,13 +1,13 @@ c3_chart_fn.xgrids = function (grids) { var $$ = this.internal, config = $$.config; - if (! grids) { return config[__grid_x_lines]; } - config[__grid_x_lines] = grids; + if (! grids) { return config.grid_x_lines; } + config.grid_x_lines = grids; $$.redraw(); - return config[__grid_x_lines]; + return config.grid_x_lines; }; c3_chart_fn.xgrids.add = function (grids) { var $$ = this.internal; - return this.xgrids($$.config[__grid_x_lines].concat(grids ? grids : [])); + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); }; c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple var $$ = this.internal; @@ -16,14 +16,14 @@ c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple c3_chart_fn.ygrids = function (grids) { var $$ = this.internal, config = $$.config; - if (! grids) { return config[__grid_y_lines]; } - config[__grid_y_lines] = grids; + if (! grids) { return config.grid_y_lines; } + config.grid_y_lines = grids; $$.redraw(); - return config[__grid_y_lines]; + return config.grid_y_lines; }; c3_chart_fn.ygrids.add = function (grids) { var $$ = this.internal; - return this.ygrids($$.config[__grid_y_lines].concat(grids ? grids : [])); + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); }; c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple var $$ = this.internal; diff --git a/src/api.group.js b/src/api.group.js index 7c85494..47fedb4 100644 --- a/src/api.group.js +++ b/src/api.group.js @@ -1,7 +1,7 @@ c3_chart_fn.groups = function (groups) { var $$ = this.internal, config = $$.config; - if (isUndefined(groups)) { return config[__data_groups]; } - config[__data_groups] = groups; + if (isUndefined(groups)) { return config.data_groups; } + config.data_groups = groups; $$.redraw(); - return config[__data_groups]; + return config.data_groups; }; diff --git a/src/api.load.js b/src/api.load.js index 98d8dad..3f87393 100644 --- a/src/api.load.js +++ b/src/api.load.js @@ -7,12 +7,12 @@ c3_chart_fn.load = function (args) { // update classes if exists if ('classes' in args) { Object.keys(args.classes).forEach(function (id) { - config[__data_classes][id] = args.classes[id]; + config.data_classes[id] = args.classes[id]; }); } // update categories if exists if ('categories' in args && $$.isCategorized()) { - config[__axis_x_categories] = args.categories; + config.axis_x_categories = args.categories; } // use cache if exists if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { diff --git a/src/api.region.js b/src/api.region.js index 39b7219..9316e1f 100644 --- a/src/api.region.js +++ b/src/api.region.js @@ -1,23 +1,23 @@ c3_chart_fn.regions = function (regions) { var $$ = this.internal, config = $$.config; - if (!regions) { return config[__regions]; } - config[__regions] = regions; + if (!regions) { return config.regions; } + config.regions = regions; $$.redraw(); - return config[__regions]; + return config.regions; }; c3_chart_fn.regions.add = function (regions) { var $$ = this.internal, config = $$.config; - if (!regions) { return config[__regions]; } - config[__regions] = config[__regions].concat(regions); + if (!regions) { return config.regions; } + config.regions = config.regions.concat(regions); $$.redraw(); - return config[__regions]; + return config.regions; }; c3_chart_fn.regions.remove = function (options) { var $$ = this.internal, config = $$.config, duration, classes, regions; options = options || {}; - duration = $$.getOption(options, "duration", config[__transition_duration]); + duration = $$.getOption(options, "duration", config.transition_duration); classes = $$.getOption(options, "classes", [CLASS[_region]]); regions = $$.main.select('.' + CLASS[_regions]).selectAll(classes.map(function (c) { return '.' + c; })); @@ -25,7 +25,7 @@ c3_chart_fn.regions.remove = function (options) { .style('opacity', 0) .remove(); - config[__regions] = config[__regions].filter(function (region) { + config.regions = config.regions.filter(function (region) { var found = false; if (!region.class) { return true; @@ -36,5 +36,5 @@ c3_chart_fn.regions.remove = function (options) { return !found; }); - return config[__regions]; + return config.regions; }; diff --git a/src/api.selection.js b/src/api.selection.js index e647116..cbfc5ba 100644 --- a/src/api.selection.js +++ b/src/api.selection.js @@ -8,10 +8,10 @@ c3_chart_fn.selected = function (targetId) { }; c3_chart_fn.select = function (ids, indices, resetOther) { var $$ = this.internal, d3 = $$.d3, config = $$.config; - if (! config[__data_selection_enabled]) { return; } + if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), - isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0, + isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS[_SELECTED]); // line/area selection not supported yet @@ -19,7 +19,7 @@ c3_chart_fn.select = function (ids, indices, resetOther) { return; } if (isTargetId && isTargetIndex) { - if (config[__data_selection_isselectable](d) && !isSelected) { + if (config.data_selection_isselectable(d) && !isSelected) { toggle(true, shape.classed(CLASS[_SELECTED], true), d, i); } } else if (isDefined(resetOther) && resetOther) { @@ -31,10 +31,10 @@ c3_chart_fn.select = function (ids, indices, resetOther) { }; c3_chart_fn.unselect = function (ids, indices) { var $$ = this.internal, d3 = $$.d3, config = $$.config; - if (! config[__data_selection_enabled]) { return; } + if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this), - isTargetId = config[__data_selection_grouped] || !ids || ids.indexOf(id) >= 0, + isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS[_SELECTED]); // line/area selection not supported yet @@ -42,7 +42,7 @@ c3_chart_fn.unselect = function (ids, indices) { return; } if (isTargetId && isTargetIndex) { - if (config[__data_selection_isselectable](d)) { + if (config.data_selection_isselectable(d)) { if (isSelected) { toggle(false, shape.classed(CLASS[_SELECTED], false), d, i); } diff --git a/src/api.zoom.js b/src/api.zoom.js index 12e1a5c..0d08e88 100644 --- a/src/api.zoom.js +++ b/src/api.zoom.js @@ -2,7 +2,7 @@ c3_chart_fn.zoom = function () { }; c3_chart_fn.zoom.enable = function (enabled) { var $$ = this.internal; - $$.config[__zoom_enabled] = enabled; + $$.config.zoom_enabled = enabled; $$.updateAndRedraw(); }; c3_chart_fn.unzoom = function () { diff --git a/src/arc.js b/src/arc.js index e1dd5eb..007ef63 100644 --- a/src/arc.js +++ b/src/arc.js @@ -3,14 +3,14 @@ c3_chart_internal_fn.initPie = function () { $$.pie = d3.layout.pie().value(function (d) { return d.values.reduce(function (a, b) { return a + b.value; }, 0); }); - if (!config[__data_order] || !config[__pie_sort] || !config[__donut_sort]) { + if (!config.data_order || !config.pie_sort || !config.donut_sort) { $$.pie.sort(null); } }; c3_chart_internal_fn.updateRadius = function () { var $$ = this, config = $$.config, - w = config[__gauge_width] || config[__donut_width]; + w = config.gauge_width || config.donut_width; $$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2; $$.radius = $$.radiusExpanded * 0.95; $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; @@ -39,7 +39,7 @@ c3_chart_internal_fn.updateAngle = function (d) { d.endAngle = d.startAngle; } if ($$.isGaugeType(d.data)) { - var gMin = config[__gauge_min], gMax = config[__gauge_max], + var gMin = config.gauge_min, gMax = config.gauge_max, gF = Math.abs(gMin) + gMax, aTic = (Math.PI) / gF; d.startAngle = (-1 * (Math.PI / 2)) + (aTic * Math.abs(gMin)); @@ -152,15 +152,15 @@ c3_chart_internal_fn.unexpandArc = function (id) { c3_chart_internal_fn.shouldExpand = function (id) { var $$ = this, config = $$.config; - return ($$.isDonutType(id) && config[__donut_expand]) || ($$.isGaugeType(id) && config[__gauge_expand]) || ($$.isPieType(id) && config[__pie_expand]); + return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand); }; c3_chart_internal_fn.shouldShowArcLabel = function () { var $$ = this, config = $$.config, shouldShow = true; if ($$.hasType('donut')) { - shouldShow = config[__donut_label_show]; + shouldShow = config.donut_label_show; } else if ($$.hasType('pie')) { - shouldShow = config[__pie_label_show]; + shouldShow = config.pie_label_show; } // when gauge, always true return shouldShow; @@ -168,24 +168,24 @@ c3_chart_internal_fn.shouldShowArcLabel = function () { c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) { var $$ = this, config = $$.config, - threshold = $$.hasType('donut') ? config[__donut_label_threshold] : config[__pie_label_threshold]; + threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold; return ratio >= threshold; }; c3_chart_internal_fn.getArcLabelFormat = function () { var $$ = this, config = $$.config, - format = config[__pie_label_format]; + format = config.pie_label_format; if ($$.hasType('gauge')) { - format = config[__gauge_label_format]; + format = config.gauge_label_format; } else if ($$.hasType('donut')) { - format = config[__donut_label_format]; + format = config.donut_label_format; } return format; }; c3_chart_internal_fn.getArcTitle = function () { var $$ = this; - return $$.hasType('donut') ? $$.config[__donut_title] : ""; + return $$.hasType('donut') ? $$.config.donut_title : ""; }; c3_chart_internal_fn.descByStartAngle = function (a, b) { @@ -232,7 +232,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf mainArc.enter().append('path') .attr("class", $$.classArc.bind($$)) .style("fill", function (d) { return $$.color(d.data); }) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }) + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }) .style("opacity", 0) .each(function (d) { if ($$.isGaugeType(d.data)) { @@ -250,7 +250,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf // transitions $$.expandArc(updated.data.id); $$.toggleFocusLegend(updated.data.id, true); - $$.config[__data_onmouseover](arcData, this); + $$.config.data_onmouseover(arcData, this); }) .on('mousemove', function (d) { var updated = $$.updateAngle(d), @@ -269,7 +269,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf $$.unexpandArc(updated.data.id); $$.revertLegend(); $$.hideTooltip(); - $$.config[__data_onmouseout](arcData, this); + $$.config.data_onmouseout(arcData, this); }) .on('click', function (d, i) { var updated, arcData; @@ -332,7 +332,7 @@ c3_chart_internal_fn.initGauge = function () { .attr("class", CLASS[_chartArcsBackground]) .attr("d", function () { var d = { - data: [{value: config[__gauge_max]}], + data: [{value: config.gauge_max}], startAngle: -1 * (Math.PI / 2), endAngle: Math.PI / 2 }; @@ -343,20 +343,20 @@ c3_chart_internal_fn.initGauge = function () { .attr("class", CLASS[_chartArcsGaugeUnit]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_units] : ''); + .text(config.gauge_label_show ? config.gauge_units : ''); arcs.append("text") .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px") .attr("dy", "1.2em") .attr("class", CLASS[_chartArcsGaugeMin]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_min] : ''); + .text(config.gauge_label_show ? config.gauge_min : ''); arcs.append("text") .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") .attr("dy", "1.2em") .attr("class", CLASS[_chartArcsGaugeMax]) .style("text-anchor", "middle") .style("pointer-events", "none") - .text(config[__gauge_label_show] ? config[__gauge_max] : ''); + .text(config.gauge_label_show ? config.gauge_max : ''); } }; diff --git a/src/axis.js b/src/axis.js index 0de1dc4..7f28b91 100644 --- a/src/axis.js +++ b/src/axis.js @@ -4,30 +4,30 @@ c3_chart_internal_fn.initAxis = function () { .attr("class", CLASS[_axis] + ' ' + CLASS[_axisX]) .attr("clip-path", $$.clipPathForXAxis) .attr("transform", $$.getTranslate('x')) - .style("visibility", config[__axis_x_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_x_show ? 'visible' : 'hidden'); $$.axes.x.append("text") .attr("class", CLASS[_axisXLabel]) - .attr("transform", config[__axis_rotated] ? "rotate(-90)" : "") + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .style("text-anchor", $$.textAnchorForXAxisLabel.bind($$)); $$.axes.y = main.append("g") .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY]) .attr("clip-path", $$.clipPathForYAxis) .attr("transform", $$.getTranslate('y')) - .style("visibility", config[__axis_y_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text") .attr("class", CLASS[_axisYLabel]) - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForYAxisLabel.bind($$)); $$.axes.y2 = main.append("g") .attr("class", CLASS[_axis] + ' ' + CLASS[_axisY2]) // clip-path? .attr("transform", $$.getTranslate('y2')) - .style("visibility", config[__axis_y2_show] ? 'visible' : 'hidden'); + .style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text") .attr("class", CLASS[_axisY2Label]) - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", $$.textAnchorForY2AxisLabel.bind($$)); }; c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues) { @@ -37,15 +37,15 @@ c3_chart_internal_fn.getXAxis = function (scale, orient, tickFormat, tickValues) // Set tick axis.tickFormat(tickFormat).tickValues(tickValues); if ($$.isCategorized()) { - axis.tickCentered(config[__axis_x_tick_centered]); - if (isEmpty(config[__axis_x_tick_culling])) { - config[__axis_x_tick_culling] = false; + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; } } else { // TODO: move this to c3_axis axis.tickOffset = function () { var edgeX = $$.getEdgeX($$.data.targets), diff = $$.x(edgeX[1]) - $$.x(edgeX[0]), - base = diff ? diff : (config[__axis_rotated] ? $$.height : $$.width); + base = diff ? diff : (config.axis_rotated ? $$.height : $$.width); return (base / $$.getMaxDataCount()) / 2; }; } @@ -57,17 +57,17 @@ c3_chart_internal_fn.getYAxis = function (scale, orient, tickFormat, ticks) { }; c3_chart_internal_fn.getAxisId = function (id) { var config = this.config; - return id in config[__data_axes] ? config[__data_axes][id] : 'y'; + return id in config.data_axes ? config.data_axes[id] : 'y'; }; c3_chart_internal_fn.getXAxisTickFormat = function () { var $$ = this, config = $$.config, format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : v; }; - if (config[__axis_x_tick_format]) { - if (isFunction(config[__axis_x_tick_format])) { - format = config[__axis_x_tick_format]; + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; } else if ($$.isTimeSeries()) { format = function (date) { - return date ? $$.axisTimeFormat(config[__axis_x_tick_format])(date) : ""; + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : ""; }; } } @@ -76,11 +76,11 @@ c3_chart_internal_fn.getXAxisTickFormat = function () { c3_chart_internal_fn.getAxisLabelOptionByAxisId = function (axisId) { var $$ = this, config = $$.config, option; if (axisId === 'y') { - option = config[__axis_y_label]; + option = config.axis_y_label; } else if (axisId === 'y2') { - option = config[__axis_y2_label]; + option = config.axis_y2_label; } else if (axisId === 'x') { - option = config[__axis_x_label]; + option = config.axis_x_label; } return option; }; @@ -93,11 +93,11 @@ c3_chart_internal_fn.setAxisLabelText = function (axisId, text) { option = $$.getAxisLabelOptionByAxisId(axisId); if (isString(option)) { if (axisId === 'y') { - config[__axis_y_label] = text; + config.axis_y_label = text; } else if (axisId === 'y2') { - config[__axis_y2_label] = text; + config.axis_y2_label = text; } else if (axisId === 'x') { - config[__axis_x_label] = text; + config.axis_x_label = text; } } else if (option) { option.text = text; @@ -118,13 +118,13 @@ c3_chart_internal_fn.getAxisLabelPosition = function (axisId, defaultPosition) { }; }; c3_chart_internal_fn.getXAxisLabelPosition = function () { - return this.getAxisLabelPosition('x', this.config[__axis_rotated] ? 'inner-top' : 'inner-right'); + return this.getAxisLabelPosition('x', this.config.axis_rotated ? 'inner-top' : 'inner-right'); }; c3_chart_internal_fn.getYAxisLabelPosition = function () { - return this.getAxisLabelPosition('y', this.config[__axis_rotated] ? 'inner-right' : 'inner-top'); + return this.getAxisLabelPosition('y', this.config.axis_rotated ? 'inner-right' : 'inner-top'); }; c3_chart_internal_fn.getY2AxisLabelPosition = function () { - return this.getAxisLabelPosition('y2', this.config[__axis_rotated] ? 'inner-right' : 'inner-top'); + return this.getAxisLabelPosition('y2', this.config.axis_rotated ? 'inner-right' : 'inner-top'); }; c3_chart_internal_fn.getAxisLabelPositionById = function (id) { return id === 'y2' ? this.getY2AxisLabelPosition() : id === 'y' ? this.getYAxisLabelPosition() : this.getXAxisLabelPosition(); @@ -161,36 +161,36 @@ c3_chart_internal_fn.textAnchorForAxisLabel = function (forHorizontal, position) } }; c3_chart_internal_fn.xForXAxisLabel = function () { - return this.xForAxisLabel(!this.config[__axis_rotated], this.getXAxisLabelPosition()); + return this.xForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition()); }; c3_chart_internal_fn.xForYAxisLabel = function () { - return this.xForAxisLabel(this.config[__axis_rotated], this.getYAxisLabelPosition()); + return this.xForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition()); }; c3_chart_internal_fn.xForY2AxisLabel = function () { - return this.xForAxisLabel(this.config[__axis_rotated], this.getY2AxisLabelPosition()); + return this.xForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition()); }; c3_chart_internal_fn.dxForXAxisLabel = function () { - return this.dxForAxisLabel(!this.config[__axis_rotated], this.getXAxisLabelPosition()); + return this.dxForAxisLabel(!this.config.axis_rotated, this.getXAxisLabelPosition()); }; c3_chart_internal_fn.dxForYAxisLabel = function () { - return this.dxForAxisLabel(this.config[__axis_rotated], this.getYAxisLabelPosition()); + return this.dxForAxisLabel(this.config.axis_rotated, this.getYAxisLabelPosition()); }; c3_chart_internal_fn.dxForY2AxisLabel = function () { - return this.dxForAxisLabel(this.config[__axis_rotated], this.getY2AxisLabelPosition()); + return this.dxForAxisLabel(this.config.axis_rotated, this.getY2AxisLabelPosition()); }; c3_chart_internal_fn.dyForXAxisLabel = function () { var $$ = this, config = $$.config, position = $$.getXAxisLabelPosition(); - if (config[__axis_rotated]) { + if (config.axis_rotated) { return position.isInner ? "1.2em" : -25 - $$.getMaxTickWidth('x'); } else { - return position.isInner ? "-0.5em" : config[__axis_x_height] ? config[__axis_x_height] - 10 : "3em"; + return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; } }; c3_chart_internal_fn.dyForYAxisLabel = function () { var $$ = this, position = $$.getYAxisLabelPosition(); - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { return position.isInner ? "-0.5em" : "3em"; } else { return position.isInner ? "1.2em" : -20 - $$.getMaxTickWidth('y'); @@ -199,7 +199,7 @@ c3_chart_internal_fn.dyForYAxisLabel = function () { c3_chart_internal_fn.dyForY2AxisLabel = function () { var $$ = this, position = $$.getY2AxisLabelPosition(); - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { return position.isInner ? "1.2em" : "-2.2em"; } else { return position.isInner ? "-0.5em" : 30 + this.getMaxTickWidth('y2'); @@ -207,15 +207,15 @@ c3_chart_internal_fn.dyForY2AxisLabel = function () { }; c3_chart_internal_fn.textAnchorForXAxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel(!$$.config[__axis_rotated], $$.getXAxisLabelPosition()); + return $$.textAnchorForAxisLabel(!$$.config.axis_rotated, $$.getXAxisLabelPosition()); }; c3_chart_internal_fn.textAnchorForYAxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel($$.config[__axis_rotated], $$.getYAxisLabelPosition()); + return $$.textAnchorForAxisLabel($$.config.axis_rotated, $$.getYAxisLabelPosition()); }; c3_chart_internal_fn.textAnchorForY2AxisLabel = function () { var $$ = this; - return $$.textAnchorForAxisLabel($$.config[__axis_rotated], $$.getY2AxisLabelPosition()); + return $$.textAnchorForAxisLabel($$.config.axis_rotated, $$.getY2AxisLabelPosition()); }; c3_chart_internal_fn.xForRotatedTickText = function (r) { @@ -240,13 +240,13 @@ c3_chart_internal_fn.getMaxTickWidth = function (id) { targetsToShow = $$.filterTargetsToShow($$.data.targets); if (id === 'y') { scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); - axis = $$.getYAxis(scale, $$.yOrient, config[__axis_y_tick_format], config[__axis_y_ticks]); + axis = $$.getYAxis(scale, $$.yOrient, config.axis_y_tick_format, config.axis_y_ticks); } else if (id === 'y2') { scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); - axis = $$.getYAxis(scale, $$.y2Orient, config[__axis_y2_tick_format], config[__axis_y2_ticks]); + axis = $$.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, config.axis_y2_ticks); } else { scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); - axis = $$.getXAxis(scale, $$.xOrient, $$.getXAxisTickFormat(), config[__axis_x_tick_values] ? config[__axis_x_tick_values] : $$.xAxis.tickValues()); + axis = $$.getXAxis(scale, $$.xOrient, $$.getXAxisTickFormat(), config.axis_x_tick_values ? config.axis_x_tick_values : $$.xAxis.tickValues()); } $$.main.append("g").call(axis).each(function () { $$.d3.select(this).selectAll('text').each(function () { diff --git a/src/category.js b/src/category.js index 5abe0ba..5143c6c 100644 --- a/src/category.js +++ b/src/category.js @@ -1,4 +1,4 @@ c3_chart_internal_fn.categoryName = function (i) { var config = this.config; - return i < config[__axis_x_categories].length ? config[__axis_x_categories][i] : i; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; }; diff --git a/src/class.js b/src/class.js index 4fc3b5c..10d9f17 100644 --- a/src/class.js +++ b/src/class.js @@ -196,7 +196,7 @@ c3_chart_internal_fn.classEvent = function (d) { }; c3_chart_internal_fn.classTarget = function (id) { var $$ = this; - var additionalClassSuffix = $$.config[__data_classes][id], additionalClass = ''; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; if (additionalClassSuffix) { additionalClass = ' ' + CLASS[_target] + '-' + additionalClassSuffix; } diff --git a/src/clip.js b/src/clip.js index 668c4a1..41a42bb 100644 --- a/src/clip.js +++ b/src/clip.js @@ -11,19 +11,19 @@ c3_chart_internal_fn.getAxisClipY = function (forHorizontal) { }; c3_chart_internal_fn.getXAxisClipX = function () { var $$ = this; - return $$.getAxisClipX(!$$.config[__axis_rotated]); + return $$.getAxisClipX(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipY = function () { var $$ = this; - return $$.getAxisClipY(!$$.config[__axis_rotated]); + return $$.getAxisClipY(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipX = function () { var $$ = this; - return $$.getAxisClipX($$.config[__axis_rotated]); + return $$.getAxisClipX($$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipY = function () { var $$ = this; - return $$.getAxisClipY($$.config[__axis_rotated]); + return $$.getAxisClipY($$.config.axis_rotated); }; c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) { var $$ = this; @@ -32,21 +32,21 @@ c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) { }; c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) { var $$ = this, config = $$.config; - return forHorizontal ? (config[__axis_x_height] ? config[__axis_x_height] : 0) + 80 : $$.height + 8; + return forHorizontal ? (config.axis_x_height ? config.axis_x_height : 0) + 80 : $$.height + 8; }; c3_chart_internal_fn.getXAxisClipWidth = function () { var $$ = this; - return $$.getAxisClipWidth(!$$.config[__axis_rotated]); + return $$.getAxisClipWidth(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipHeight = function () { var $$ = this; - return $$.getAxisClipHeight(!$$.config[__axis_rotated]); + return $$.getAxisClipHeight(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipWidth = function () { var $$ = this; - return $$.getAxisClipWidth($$.config[__axis_rotated]); + return $$.getAxisClipWidth($$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipHeight = function () { var $$ = this; - return $$.getAxisClipHeight($$.config[__axis_rotated]); + return $$.getAxisClipHeight($$.config.axis_rotated); }; diff --git a/src/color.js b/src/color.js index 85a9109..4243f65 100644 --- a/src/color.js +++ b/src/color.js @@ -1,8 +1,8 @@ c3_chart_internal_fn.generateColor = function () { var $$ = this, config = $$.config, d3 = $$.d3, - colors = config[__data_colors], - pattern = notEmpty(config[__color_pattern]) ? config[__color_pattern] : d3.scale.category10().range(), - callback = config[__data_color], + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), + callback = config.data_color, ids = []; return function (d) { @@ -27,12 +27,12 @@ c3_chart_internal_fn.generateColor = function () { }; c3_chart_internal_fn.generateLevelColor = function () { var $$ = this, config = $$.config, - colors = config[__color_pattern], - threshold = config[__color_threshold], + colors = config.color_pattern, + threshold = config.color_threshold, asValue = threshold.unit === 'value', values = threshold.values && threshold.values.length ? threshold.values : [], max = threshold.max || 100; - return notEmpty(config[__color_threshold]) ? function (value) { + return notEmpty(config.color_threshold) ? function (value) { var i, v, color = colors[colors.length - 1]; for (i = 0; i < values.length; i++) { v = asValue ? value : (value * 100 / max); diff --git a/src/config.js b/src/config.js index 56193a9..58c93c3 100644 --- a/src/config.js +++ b/src/config.js @@ -1,330 +1,177 @@ -var __bindto = 'bindto', - __size_width = 'size_width', - __size_height = 'size_height', - __padding_left = 'padding_left', - __padding_right = 'padding_right', - __padding_top = 'padding_top', - __padding_bottom = 'padding_bottom', - __zoom_enabled = 'zoom_enabled', - __zoom_extent = 'zoom_extent', - __zoom_privileged = 'zoom_privileged', - __zoom_onzoom = 'zoom_onzoom', - __interaction_enabled = 'interaction_enabled', - __onmouseover = 'onmouseover', - __onmouseout = 'onmouseout', - __onresize = 'onresize', - __onresized = 'onresized', - __transition_duration = 'transition_duration', - __data_x = 'data_x', - __data_xs = 'data_xs', - __data_xFormat = 'data_xFormat', - __data_xLocaltime = 'data_xLocaltime', - __data_idConverter = 'data_idConverter', - __data_names = 'data_names', - __data_classes = 'data_classes', - __data_groups = 'data_groups', - __data_axes = 'data_axes', - __data_type = 'data_type', - __data_types = 'data_types', - __data_labels = 'data_labels', - __data_order = 'data_order', - __data_regions = 'data_regions', - __data_color = 'data_color', - __data_colors = 'data_colors', - __data_hide = 'data_hide', - __data_filter = 'data_filter', - __data_selection_enabled = 'data_selection_enabled', - __data_selection_grouped = 'data_selection_grouped', - __data_selection_isselectable = 'data_selection_isselectable', - __data_selection_multiple = 'data_selection_multiple', - __data_onclick = 'data_onclick', - __data_onmouseover = 'data_onmouseover', - __data_onmouseout = 'data_onmouseout', - __data_onselected = 'data_onselected', - __data_onunselected = 'data_onunselected', - __data_ondragstart = 'data_ondragstart', - __data_ondragend = 'data_ondragend', - __data_url = 'data_url', - __data_json = 'data_json', - __data_rows = 'data_rows', - __data_columns = 'data_columns', - __data_mimeType = 'data_mimeType', - __data_keys = 'data_keys', - __data_empty_label_text = 'data_empty_label_text', - __subchart_show = 'subchart_show', - __subchart_size_height = 'subchart_size_height', - __subchart_onbrush = 'subchart_onbrush', - __color_pattern = 'color_pattern', - __color_threshold = 'color_threshold', - __legend_show = 'legend_show', - __legend_position = 'legend_position', - __legend_inset_anchor = 'legend_inset_anchor', - __legend_inset_x = 'legend_inset_x', - __legend_inset_y = 'legend_inset_y', - __legend_inset_step = 'legend_inset_step', - __legend_item_onclick = 'legend_item_onclick', - __legend_item_onmouseover = 'legend_item_onmouseover', - __legend_item_onmouseout = 'legend_item_onmouseout', - __legend_equally = 'legend_equally', - __axis_rotated = 'axis_rotated', - __axis_x_show = 'axis_x_show', - __axis_x_type = 'axis_x_type', - __axis_x_localtime = 'axis_x_localtime', - __axis_x_categories = 'axis_x_categories', - __axis_x_tick_centered = 'axis_x_tick_centered', - __axis_x_tick_format = 'axis_x_tick_format', - __axis_x_tick_culling = 'axis_x_tick_culling', - __axis_x_tick_culling_max = 'axis_x_tick_culling_max', - __axis_x_tick_count = 'axis_x_tick_count', - __axis_x_tick_fit = 'axis_x_tick_fit', - __axis_x_tick_values = 'axis_x_tick_values', - __axis_x_tick_rotate = 'axis_x_tick_rotate', - __axis_x_tick_outer = 'axis_x_tick_outer', - __axis_x_max = 'axis_x_max', - __axis_x_min = 'axis_x_min', - __axis_x_padding = 'axis_x_padding', - __axis_x_height = 'axis_x_height', - __axis_x_default = 'axis_x_default', - __axis_x_label = 'axis_x_label', - __axis_y_show = 'axis_y_show', - __axis_y_max = 'axis_y_max', - __axis_y_min = 'axis_y_min', - __axis_y_center = 'axis_y_center', - __axis_y_label = 'axis_y_label', - __axis_y_tick_format = 'axis_y_tick_format', - __axis_y_tick_outer = 'axis_y_tick_outer', - __axis_y_padding = 'axis_y_padding', - __axis_y_ticks = 'axis_y_ticks', - __axis_y2_show = 'axis_y2_show', - __axis_y2_max = 'axis_y2_max', - __axis_y2_min = 'axis_y2_min', - __axis_y2_center = 'axis_y2_center', - __axis_y2_label = 'axis_y2_label', - __axis_y2_tick_format = 'axis_y2_tick_format', - __axis_y2_tick_outer = 'axis_y2_tick_outer', - __axis_y2_padding = 'axis_y2_padding', - __axis_y2_ticks = 'axis_y2_ticks', - __grid_x_show = 'grid_x_show', - __grid_x_type = 'grid_x_type', - __grid_x_lines = 'grid_x_lines', - __grid_y_show = 'grid_y_show', - __grid_y_lines = 'grid_y_lines', - __grid_y_ticks = 'grid_y_ticks', - __grid_focus_show = 'grid_focus_show', - __point_show = 'point_show', - __point_r = 'point_r', - __point_focus_expand_enabled = 'point_focus_expand_enabled', - __point_focus_expand_r = 'point_focus_expand_r', - __point_select_r = 'point_select_r', - __line_connect_null = 'line_connect_null', - __bar_width = 'bar_width', - __bar_width_ratio = 'bar_width_ratio', - __bar_width_max = 'bar_width_max', - __bar_zerobased = 'bar_zerobased', - __area_zerobased = 'area_zerobased', - __pie_label_show = 'pie_label_show', - __pie_label_format = 'pie_label_format', - __pie_label_threshold = 'pie_label_threshold', - __pie_sort = 'pie_sort', - __pie_expand = 'pie_expand', - __gauge_label_show = 'gauge_label_show', - __gauge_label_format = 'gauge_label_format', - __gauge_expand = 'gauge_expand', - __gauge_min = 'gauge_min', - __gauge_max = 'gauge_max', - __gauge_units = 'gauge_units', - __gauge_width = 'gauge_width', - __donut_label_show = 'donut_label_show', - __donut_label_format = 'donut_label_format', - __donut_label_threshold = 'donut_label_threshold', - __donut_width = 'donut_width', - __donut_sort = 'donut_sort', - __donut_expand = 'donut_expand', - __donut_title = 'donut_title', - __regions = 'regions', - __tooltip_show = 'tooltip_show', - __tooltip_grouped = 'tooltip_grouped', - __tooltip_format_title = 'tooltip_format_title', - __tooltip_format_name = 'tooltip_format_name', - __tooltip_format_value = 'tooltip_format_value', - __tooltip_contents = 'tooltip_contents', - __tooltip_init_show = 'tooltip_init_show', - __tooltip_init_x = 'tooltip_init_x', - __tooltip_init_position = 'tooltip_init_position'; - c3_chart_internal_fn.getDefaultConfig = function () { - var config = {}; - config[__bindto] = '#chart'; - config[__size_width] = undefined; - config[__size_height] = undefined; - config[__padding_left] = undefined; - config[__padding_right] = undefined; - config[__padding_top] = undefined; - config[__padding_bottom] = undefined; - config[__zoom_enabled] = false; - config[__zoom_extent] = undefined; - config[__zoom_privileged] = false; - config[__zoom_onzoom] = function () {}; - config[__interaction_enabled] = true; - config[__onmouseover] = function () {}; - config[__onmouseout] = function () {}; - config[__onresize] = function () {}; - config[__onresized] = function () {}; - config[__transition_duration] = 350; - config[__data_x] = undefined; - config[__data_xs] = {}; - config[__data_xFormat] = '%Y-%m-%d'; - config[__data_xLocaltime] = true; - config[__data_idConverter] = function (id) { return id; }; - config[__data_names] = {}; - config[__data_classes] = {}; - config[__data_groups] = []; - config[__data_axes] = {}; - config[__data_type] = undefined; - config[__data_types] = {}; - config[__data_labels] = {}; - config[__data_order] = 'desc'; - config[__data_regions] = {}; - config[__data_color] = undefined; - config[__data_colors] = {}; - config[__data_hide] = false; - config[__data_filter] = undefined; - config[__data_selection_enabled] = false; - config[__data_selection_grouped] = false; - config[__data_selection_isselectable] = function () { return true; }; - config[__data_selection_multiple] = true; - config[__data_onclick] = function () {}; - config[__data_onmouseover] = function () {}; - config[__data_onmouseout] = function () {}; - config[__data_onselected] = function () {}; - config[__data_onunselected] = function () {}; - config[__data_ondragstart] = function () {}; - config[__data_ondragend] = function () {}; - config[__data_url] = undefined; - config[__data_json] = undefined; - config[__data_rows] = undefined; - config[__data_columns] = undefined; - config[__data_mimeType] = undefined; - config[__data_keys] = undefined; - // configuration for no plot-able data supplied. - config[__data_empty_label_text] = ""; - // subchart - config[__subchart_show] = false; - config[__subchart_size_height] = 60; - config[__subchart_onbrush] = function () {}; - // color - config[__color_pattern] = []; - config[__color_threshold] = {}; - // legend - config[__legend_show] = true; - config[__legend_position] = 'bottom'; - config[__legend_inset_anchor] = 'top-left'; - config[__legend_inset_x] = 10; - config[__legend_inset_y] = 0; - config[__legend_inset_step] = undefined; - config[__legend_item_onclick] = undefined; - config[__legend_item_onmouseover] = undefined; - config[__legend_item_onmouseout] = undefined; - config[__legend_equally] = false; - // axis - config[__axis_rotated] = false; - config[__axis_x_show] = true; - config[__axis_x_type] = 'indexed'; - config[__axis_x_localtime] = true; - config[__axis_x_categories] = []; - config[__axis_x_tick_centered] = false; - config[__axis_x_tick_format] = undefined; - config[__axis_x_tick_culling] = {}; - config[__axis_x_tick_culling_max] = 10; - config[__axis_x_tick_count] = undefined; - config[__axis_x_tick_fit] = true; - config[__axis_x_tick_values] = null; - config[__axis_x_tick_rotate] = undefined; - config[__axis_x_tick_outer] = true; - config[__axis_x_max] = null; - config[__axis_x_min] = null; - config[__axis_x_padding] = {}; - config[__axis_x_height] = undefined; - config[__axis_x_default] = undefined; - config[__axis_x_label] = {}; - config[__axis_y_show] = true; - config[__axis_y_max] = undefined; - config[__axis_y_min] = undefined; - config[__axis_y_center] = undefined; - config[__axis_y_label] = {}; - config[__axis_y_tick_format] = undefined; - config[__axis_y_tick_outer] = true; - config[__axis_y_padding] = undefined; - config[__axis_y_ticks] = 10; - config[__axis_y2_show] = false; - config[__axis_y2_max] = undefined; - config[__axis_y2_min] = undefined; - config[__axis_y2_center] = undefined; - config[__axis_y2_label] = {}; - config[__axis_y2_tick_format] = undefined; - config[__axis_y2_tick_outer] = true; - config[__axis_y2_padding] = undefined; - config[__axis_y2_ticks] = 10; - // grid - config[__grid_x_show] = false; - config[__grid_x_type] = 'tick'; - config[__grid_x_lines] = []; - config[__grid_y_show] = false; - // not used - // grid_y_type: {}, 'tick'), - config[__grid_y_lines] = []; - config[__grid_y_ticks] = 10; - config[__grid_focus_show] = true; - // point - point of each data - config[__point_show] = true; - config[__point_r] = 2.5; - config[__point_focus_expand_enabled] = true; - config[__point_focus_expand_r] = undefined; - config[__point_select_r] = undefined; - config[__line_connect_null] = false; - // bar - config[__bar_width] = undefined; - config[__bar_width_ratio] = 0.6; - config[__bar_width_max] = undefined; - config[__bar_zerobased] = true; - // area - config[__area_zerobased] = true; - // pie - config[__pie_label_show] = true; - config[__pie_label_format] = undefined; - config[__pie_label_threshold] = 0.05; - config[__pie_sort] = true; - config[__pie_expand] = true; - // gauge - config[__gauge_label_show] = true; - config[__gauge_label_format] = undefined; - config[__gauge_expand] = true; - config[__gauge_min] = 0; - config[__gauge_max] = 100; - config[__gauge_units] = undefined; - config[__gauge_width] = undefined; - // donut - config[__donut_label_show] = true; - config[__donut_label_format] = undefined; - config[__donut_label_threshold] = 0.05; - config[__donut_width] = undefined; - config[__donut_sort] = true; - config[__donut_expand] = true; - config[__donut_title] = ""; - // region - region to change style - config[__regions] = []; - // tooltip - show when mouseover on each data - config[__tooltip_show] = true; - config[__tooltip_grouped] = true; - config[__tooltip_format_title] = undefined; - config[__tooltip_format_name] = undefined; - config[__tooltip_format_value] = undefined; - config[__tooltip_contents] = function (d, defaultTitleFormat, defaultValueFormat, color) { - return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : ''; - }, - config[__tooltip_init_show] = false; - config[__tooltip_init_x] = 0; - config[__tooltip_init_position] = {top: '0px', left: '50px'}; + var 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_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_idConverter: 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: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: "", + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_onbrush: function () {}, + // color + color_pattern: [], + color_threshold: {}, + // legend + 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: 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_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_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_padding: undefined, + axis_y2_ticks: 10, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + line_connect_null: false, + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + // area + area_zerobased: true, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_sort: true, + pie_expand: true, + // gauge + 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: 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: [], + // tooltip - show when mouseover on each data + 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) { + return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : ''; + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: {top: '0px', left: '50px'} + }; Object.keys(this.additionalConfig).forEach(function (key) { config[key] = this.additionalConfig[key]; diff --git a/src/core.js b/src/core.js index 21c2b22..e6e76ee 100644 --- a/src/core.js +++ b/src/core.js @@ -47,17 +47,17 @@ c3_chart_internal_fn.init = function () { $$.initParams(); - if (config[__data_url]) { - $$.convertUrlToData(config[__data_url], config[__data_mimeType], config[__data_keys], $$.initWithData); + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_keys, $$.initWithData); } - else if (config[__data_json]) { - $$.initWithData($$.convertJsonToData(config[__data_json], config[__data_keys])); + else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); } - else if (config[__data_rows]) { - $$.initWithData($$.convertRowsToData(config[__data_rows])); + else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); } - else if (config[__data_columns]) { - $$.initWithData($$.convertColumnsToData(config[__data_columns])); + else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); } else { throw Error('url or json or rows or columns is required.'); @@ -84,8 +84,8 @@ c3_chart_internal_fn.initParams = function () { $$.color = $$.generateColor(); $$.levelColor = $$.generateLevelColor(); - $$.dataTimeFormat = config[__data_xLocaltime] ? d3.time.format : d3.time.format.utc; - $$.axisTimeFormat = config[__axis_x_localtime] ? d3.time.format : d3.time.format.utc; + $$.dataTimeFormat = config.data_xLocaltime ? 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(); }], @@ -100,15 +100,15 @@ c3_chart_internal_fn.initParams = function () { $$.hiddenTargetIds = []; $$.hiddenLegendIds = []; - $$.xOrient = config[__axis_rotated] ? "left" : "bottom"; - $$.yOrient = config[__axis_rotated] ? "bottom" : "left"; - $$.y2Orient = config[__axis_rotated] ? "top" : "right"; - $$.subXOrient = config[__axis_rotated] ? "left" : "bottom"; + $$.xOrient = config.axis_rotated ? "left" : "bottom"; + $$.yOrient = config.axis_rotated ? "bottom" : "left"; + $$.y2Orient = config.axis_rotated ? "top" : "right"; + $$.subXOrient = config.axis_rotated ? "left" : "bottom"; - $$.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'; + $$.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; @@ -117,7 +117,7 @@ c3_chart_internal_fn.initParams = function () { $$.currentMaxTickWidth = 0; $$.rotated_padding_left = 30; - $$.rotated_padding_right = config[__axis_rotated] && !config[__axis_x_show] ? 0 : 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; $$.rotated_padding_top = 5; $$.withoutFadeIn = {}; @@ -133,7 +133,7 @@ c3_chart_internal_fn.initWithData = function (data) { if ($$.initBrush) { $$.initBrush(); } if ($$.initZoom) { $$.initZoom(); } - $$.selectChart = d3.select(config[__bindto]); + $$.selectChart = d3.select(config.bindto); if ($$.selectChart.empty()) { $$.selectChart = d3.select(document.createElement('div')).style('opacity', 0); $$.observeInserted($$.selectChart); @@ -145,18 +145,18 @@ c3_chart_internal_fn.initWithData = function (data) { $$.data.xs = {}; $$.data.targets = $$.convertDataToTargets(data); - if (config[__data_filter]) { - $$.data.targets = $$.data.targets.filter(config[__data_filter]); + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); } // Set targets to hide if needed - if (config[__data_hide]) { - $$.addHiddenTargetIds(config[__data_hide] === true ? $$.mapToIds($$.data.targets) : config[__data_hide]); + if (config.data_hide) { + $$.addHiddenTargetIds(config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide); } // when gauge, hide legend // TODO: fix if ($$.hasType('gauge')) { - config[__legend_show] = false; + config.legend_show = false; } // Init sizes and scales @@ -176,15 +176,15 @@ c3_chart_internal_fn.initWithData = function (data) { // Set initialized scales to brush and zoom if ($$.brush) { $$.brush.scale($$.subX); } - if (config[__zoom_enabled]) { $$.zoom.scale($$.x); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } /*-- Basic Elements --*/ // Define svgs $$.svg = $$.selectChart.append("svg") .style("overflow", "hidden") - .on('mouseenter', function () { return config[__onmouseover].call($$); }) - .on('mouseleave', function () { return config[__onmouseout].call($$); }); + .on('mouseenter', function () { return config.onmouseover.call($$); }) + .on('mouseleave', function () { return config.onmouseout.call($$); }); // Define defs $$.defs = $$.svg.append("defs"); @@ -237,7 +237,7 @@ c3_chart_internal_fn.initWithData = function (data) { // if zoom privileged, insert rect to forefront // TODO: is this needed? - main.insert('rect', config[__zoom_privileged] ? null : 'g.' + CLASS[_regions]) + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS[_regions]) .attr('class', CLASS[_zoomRect]) .attr('width', $$.width) .attr('height', $$.height) @@ -245,8 +245,8 @@ c3_chart_internal_fn.initWithData = function (data) { .on("dblclick.zoom", null); // Set default extent if defined - if (config[__axis_x_default]) { - $$.brush.extent(isFunction(config[__axis_x_default]) ? config[__axis_x_default]($$.getXDomain()) : config[__axis_x_default]); + if (config.axis_x_default) { + $$.brush.extent(isFunction(config.axis_x_default) ? config.axis_x_default($$.getXDomain()) : config.axis_x_default); } // Add Axis @@ -272,13 +272,13 @@ c3_chart_internal_fn.initWithData = function (data) { } if (window.onresize.add) { window.onresize.add(function () { - config[__onresize].call($$); + config.onresize.call($$); }); window.onresize.add(function () { $$.api.flush(); }); window.onresize.add(function () { - config[__onresized].call($$); + config.onresized.call($$); }); } @@ -312,14 +312,14 @@ c3_chart_internal_fn.updateSizes = function () { legendWidth = $$.legend ? $$.getLegendWidth() : 0, legendHeightForBottom = $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, hasArc = $$.hasArcType(), - xAxisHeight = config[__axis_rotated] || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), - subchartHeight = config[__subchart_show] && !hasArc ? (config[__subchart_size_height] + xAxisHeight) : 0; + xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), + subchartHeight = config.subchart_show && !hasArc ? (config.subchart_size_height + xAxisHeight) : 0; $$.currentWidth = $$.getCurrentWidth(); $$.currentHeight = $$.getCurrentHeight(); // for main - $$.margin = config[__axis_rotated] ? { + $$.margin = config.axis_rotated ? { top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), right: hasArc ? 0 : $$.getCurrentPaddingRight(), bottom: $$.getHorizontalAxisHeight('y') + legendHeightForBottom + $$.getCurrentPaddingBottom(), @@ -332,7 +332,7 @@ c3_chart_internal_fn.updateSizes = function () { }; // for subchart - $$.margin2 = config[__axis_rotated] ? { + $$.margin2 = config.axis_rotated ? { top: $$.margin.top, right: NaN, bottom: 20 + legendHeightForBottom, @@ -358,8 +358,8 @@ c3_chart_internal_fn.updateSizes = function () { if ($$.width < 0) { $$.width = 0; } if ($$.height < 0) { $$.height = 0; } - $$.width2 = config[__axis_rotated] ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; - $$.height2 = config[__axis_rotated] ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + $$.width2 = config.axis_rotated ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; + $$.height2 = config.axis_rotated ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; if ($$.width2 < 0) { $$.width2 = 0; } if ($$.height2 < 0) { $$.height2 = 0; } @@ -395,7 +395,7 @@ c3_chart_internal_fn.updateTargets = function (targets) { // Fade-in each chart $$.svg.selectAll('.' + CLASS[_target]).filter(function (d) { return $$.isTargetToShow(d.id); }) - .transition().duration(config[__transition_duration]) + .transition().duration(config.transition_duration) .style("opacity", 1); }; @@ -409,8 +409,8 @@ c3_chart_internal_fn.redraw = function (options, transitions) { var waitForDraw, flow; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling; var xv = $$.xv.bind($$), - cx = ($$.config[__axis_rotated] ? $$.circleY : $$.circleX).bind($$), - cy = ($$.config[__axis_rotated] ? $$.circleX : $$.circleY).bind($$); + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); options = options || {}; withY = getOption(options, "withY", true); @@ -423,14 +423,14 @@ c3_chart_internal_fn.redraw = function (options, transitions) { withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); - duration = withTransition ? config[__transition_duration] : 0; + duration = withTransition ? config.transition_duration : 0; durationForExit = withTransitionForExit ? duration : 0; durationForAxis = withTransitionForAxis ? duration : 0; transitions = transitions || $$.generateAxisTransitions(durationForAxis); // update legend and transform each g - if (withLegend && config[__legend_show]) { + if (withLegend && config.legend_show) { $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); } @@ -442,8 +442,8 @@ c3_chart_internal_fn.redraw = function (options, transitions) { if (targetsToShow.length) { $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain); // update axis tick values according to options - if (!config[__axis_x_tick_values] && (config[__axis_x_tick_fit] || config[__axis_x_tick_count])) { - tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config[__axis_x_tick_count]); + if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) { + tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count); $$.xAxis.tickValues(tickValues); $$.subXAxis.tickValues(tickValues); } @@ -463,9 +463,9 @@ c3_chart_internal_fn.redraw = function (options, transitions) { // show/hide if manual culling needed if (withUpdateXDomain && targetsToShow.length) { - if (config[__axis_x_tick_culling] && tickValues) { + if (config.axis_x_tick_culling && tickValues) { for (i = 1; i < tickValues.length; i++) { - if (tickValues.length / i < config[__axis_x_tick_culling_max]) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { intervalForCulling = i; break; } @@ -482,8 +482,8 @@ c3_chart_internal_fn.redraw = function (options, transitions) { } // rotate tick text if needed - if (!config[__axis_rotated] && config[__axis_x_tick_rotate]) { - $$.rotateTickText($$.axes.x, transitions.axisX, config[__axis_x_tick_rotate]); + if (!config.axis_rotated && config.axis_x_tick_rotate) { + $$.rotateTickText($$.axes.x, transitions.axisX, config.axis_x_tick_rotate); } // setup drawer - MEMO: these must be called after axis updated @@ -507,7 +507,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { main.select("text." + CLASS[_text] + '.' + CLASS[_empty]) .attr("x", $$.width / 2) .attr("y", $$.height / 2) - .text(config[__data_empty_label_text]) + .text(config.data_empty_label_text) .transition() .style('opacity', targetsToShow.length ? 0 : 1); @@ -523,7 +523,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { // lines, areas and cricles $$.redrawLine(durationForExit); $$.redrawArea(durationForExit); - if (config[__point_show]) { $$.redrawCircle(); } + if (config.point_show) { $$.redrawCircle(); } // text if ($$.hasDataLabel()) { @@ -545,7 +545,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { .remove(); // event rect - if (config[__interaction_enabled]) { + if (config.interaction_enabled) { $$.redrawEventRect(); } @@ -607,8 +607,8 @@ c3_chart_internal_fn.updateAndRedraw = function (options) { // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) $$.updateSizes(); // MEMO: called in updateLegend in redraw if withLegend - if (!(options.withLegend && config[__legend_show])) { - transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config[__transition_duration] : 0); + if (!(options.withLegend && config.legend_show)) { + transitions = $$.generateAxisTransitions(options.withTransitionForAxis ? config.transition_duration : 0); // Update scales $$.updateScales(); $$.updateSvgSize(); @@ -620,14 +620,14 @@ c3_chart_internal_fn.updateAndRedraw = function (options) { }; c3_chart_internal_fn.isTimeSeries = function () { - return this.config[__axis_x_type] === 'timeseries'; + return this.config.axis_x_type === 'timeseries'; }; c3_chart_internal_fn.isCategorized = function () { - return this.config[__axis_x_type].indexOf('categor') >= 0; + return this.config.axis_x_type.indexOf('categor') >= 0; }; c3_chart_internal_fn.isCustomX = function () { var $$ = this, config = $$.config; - return !$$.isTimeSeries() && (config[__data_x] || notEmpty(config[__data_xs])); + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); }; c3_chart_internal_fn.getTranslate = function (target) { @@ -643,16 +643,16 @@ c3_chart_internal_fn.getTranslate = function (target) { y = $$.margin3.top; } else if (target === 'x') { x = 0; - y = config[__axis_rotated] ? 0 : $$.height; + y = config.axis_rotated ? 0 : $$.height; } else if (target === 'y') { x = 0; - y = config[__axis_rotated] ? $$.height : 0; + y = config.axis_rotated ? $$.height : 0; } else if (target === 'y2') { - x = config[__axis_rotated] ? 0 : $$.width; - y = config[__axis_rotated] ? 1 : 0; + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; } else if (target === 'subx') { x = 0; - y = config[__axis_rotated] ? 0 : $$.height2; + y = config.axis_rotated ? 0 : $$.height2; } else if (target === 'arc') { x = $$.arcWidth / 2; y = $$.arcHeight / 2; @@ -715,7 +715,7 @@ c3_chart_internal_fn.transformMain = function (withTransition, transitions) { c3_chart_internal_fn.transformAll = function (withTransition, transitions) { var $$ = this; $$.transformMain(withTransition, transitions); - if ($$.config[__subchart_show]) { $$.transformContext(withTransition, transitions); } + if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } if ($$.legend) { $$.transformLegend(withTransition); } }; @@ -745,7 +745,7 @@ c3_chart_internal_fn.updateSvgSize = function () { c3_chart_internal_fn.updateDimension = function () { var $$ = this; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { $$.axes.x.call($$.xAxis); $$.axes.subx.call($$.subXAxis); } else { @@ -843,7 +843,7 @@ c3_chart_internal_fn.parseDate = function (date) { } else if (typeof date === 'number') { parsedDate = new Date(date); } else { - parsedDate = $$.dataTimeFormat($$.config[__data_xFormat]).parse(date); + parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date); } if (!parsedDate || isNaN(+parsedDate)) { window.console.error("Failed to parse x '" + date + "' to Date object"); diff --git a/src/data.convert.js b/src/data.convert.js index 7d7c5f7..5f319ec 100644 --- a/src/data.convert.js +++ b/src/data.convert.js @@ -29,7 +29,7 @@ c3_chart_internal_fn.convertJsonToData = function (json, keys) { targetKeys = keys.value; if (keys.x) { targetKeys.push(keys.x); - $$.config[__data_x] = keys.x; + $$.config.data_x = keys.x; } new_rows.push(targetKeys); json.forEach(function (o) { @@ -100,11 +100,11 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { ); } // if not included in input data, find from preloaded data of other id's x - else if (config[__data_x]) { + else if (config.data_x) { $$.data.xs[id] = $$.getOtherTargetXs(); } // if not included in input data, find from preloaded data - else if (notEmpty(config[__data_xs])) { + else if (notEmpty(config.data_xs)) { $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); } // MEMO: if no x included, use same x of current will be used @@ -123,7 +123,7 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { // convert to target targets = ids.map(function (id, index) { - var convertedId = config[__data_idConverter](id); + var convertedId = config.data_idConverter(id); return { id: convertedId, id_org: id, @@ -131,8 +131,8 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i); // use x as categories if custom x and categorized if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { - if (i === 0) { config[__axis_x_categories] = []; } - config[__axis_x_categories].push(rawX); + if (i === 0) { config.axis_x_categories = []; } + config.axis_x_categories.push(rawX); } // mark as x = undefined if value is undefined and filter to remove after mapped if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { @@ -164,8 +164,8 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { }); // set target types - if (config[__data_type]) { - $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config[__data_types]); }), config[__data_type]); + if (config.data_type) { + $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type); } // cache as original id keyed diff --git a/src/data.js b/src/data.js index 8313506..71ae99f 100644 --- a/src/data.js +++ b/src/data.js @@ -1,13 +1,13 @@ c3_chart_internal_fn.isX = function (key) { var $$ = this, config = $$.config; - return (config[__data_x] && key === config[__data_x]) || (notEmpty(config[__data_xs]) && hasValue(config[__data_xs], key)); + return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key)); }; c3_chart_internal_fn.isNotX = function (key) { return !this.isX(key); }; c3_chart_internal_fn.getXKey = function (id) { var $$ = this, config = $$.config; - return config[__data_x] ? config[__data_x] : notEmpty(config[__data_xs]) ? config[__data_xs][id] : null; + return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null; }; c3_chart_internal_fn.getXValuesOfXKey = function (key, targets) { var $$ = this, @@ -35,7 +35,7 @@ c3_chart_internal_fn.getOtherTargetX = function (index) { c3_chart_internal_fn.addXs = function (xs) { var $$ = this; Object.keys(xs).forEach(function (id) { - $$.config[__data_xs][id] = xs[id]; + $$.config.data_xs[id] = xs[id]; }); }; c3_chart_internal_fn.hasMultipleX = function (xs) { @@ -43,12 +43,12 @@ c3_chart_internal_fn.hasMultipleX = function (xs) { }; c3_chart_internal_fn.isMultipleX = function () { var $$ = this, config = $$.config; - return notEmpty(config[__data_xs]) && $$.hasMultipleX(config[__data_xs]); + return notEmpty(config.data_xs) && $$.hasMultipleX(config.data_xs); }; c3_chart_internal_fn.addName = function (data) { var $$ = this, name; if (data) { - name = $$.config[__data_names][data.id]; + name = $$.config.data_names[data.id]; data.name = name ? name : data.id; } return data; @@ -203,11 +203,11 @@ c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) { }; c3_chart_internal_fn.isOrderDesc = function () { var config = this.config; - return config[__data_order] && config[__data_order].toLowerCase() === 'desc'; + return config.data_order && config.data_order.toLowerCase() === 'desc'; }; c3_chart_internal_fn.isOrderAsc = function () { var config = this.config; - return config[__data_order] && config[__data_order].toLowerCase() === 'asc'; + return config.data_order && config.data_order.toLowerCase() === 'asc'; }; c3_chart_internal_fn.orderTargets = function (targets) { var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); @@ -218,8 +218,8 @@ c3_chart_internal_fn.orderTargets = function (targets) { t2Sum = t2.values.reduce(reducer, 0); return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum; }); - } else if (isFunction(config[__data_order])) { - targets.sort(config[__data_order]); + } else if (isFunction(config.data_order)) { + targets.sort(config.data_order); } // TODO: accept name array for order return targets; }; @@ -231,9 +231,9 @@ c3_chart_internal_fn.filterRemoveNull = function (data) { }; c3_chart_internal_fn.hasDataLabel = function () { var config = this.config; - if (typeof config[__data_labels] === 'boolean' && config[__data_labels]) { + if (typeof config.data_labels === 'boolean' && config.data_labels) { return true; - } else if (typeof config[__data_labels] === 'object' && notEmpty(config[__data_labels])) { + } else if (typeof config.data_labels === 'object' && notEmpty(config.data_labels)) { return true; } return false; @@ -276,7 +276,7 @@ c3_chart_internal_fn.findClosestOfValues = function (values, pos, _min, _max) { max = _max ? _max : values.length - 1, med = Math.floor((max - min) / 2) + min, value = values[med], - diff = $$.x(value.x) - pos[$$.config[__axis_rotated] ? 1 : 0], + diff = $$.x(value.x) - pos[$$.config.axis_rotated ? 1 : 0], candidates; // Update range for search @@ -325,7 +325,7 @@ c3_chart_internal_fn.findClosest = function (values, pos) { c3_chart_internal_fn.dist = function (data, pos) { var $$ = this, config = $$.config, yScale = $$.getAxisId(data.id) === 'y' ? $$.y : $$.y2, - xIndex = config[__axis_rotated] ? 1 : 0, - yIndex = config[__axis_rotated] ? 0 : 1; + xIndex = config.axis_rotated ? 1 : 0, + yIndex = config.axis_rotated ? 0 : 1; return Math.pow($$.x(data.x) - pos[xIndex], 2) + Math.pow(yScale(data.value) - pos[yIndex], 2); }; diff --git a/src/domain.js b/src/domain.js index 8fdf2bd..c33e077 100644 --- a/src/domain.js +++ b/src/domain.js @@ -2,11 +2,11 @@ c3_chart_internal_fn.getYDomainMin = function (targets) { var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasNegativeValue; - if (config[__data_groups].length > 0) { + if (config.data_groups.length > 0) { hasNegativeValue = $$.hasNegativeValueInTargets(targets); - for (j = 0; j < config[__data_groups].length; j++) { + for (j = 0; j < config.data_groups.length; j++) { // Determine baseId - idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; }); + idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider negative values @@ -33,11 +33,11 @@ c3_chart_internal_fn.getYDomainMax = function (targets) { var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasPositiveValue; - if (config[__data_groups].length > 0) { + if (config.data_groups.length > 0) { hasPositiveValue = $$.hasPositiveValueInTargets(targets); - for (j = 0; j < config[__data_groups].length; j++) { + for (j = 0; j < config.data_groups.length; j++) { // Determine baseId - idsInGroup = config[__data_groups][j].filter(function (id) { return ids.indexOf(id) >= 0; }); + idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider positive values @@ -63,16 +63,16 @@ c3_chart_internal_fn.getYDomainMax = function (targets) { c3_chart_internal_fn.getYDomain = function (targets, axisId) { var $$ = this, config = $$.config, yTargets = targets.filter(function (d) { return $$.getAxisId(d.id) === axisId; }), - yMin = axisId === 'y2' ? config[__axis_y2_min] : config[__axis_y_min], - yMax = axisId === 'y2' ? config[__axis_y2_max] : config[__axis_y_max], + yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, + yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, yDomainMin = isValue(yMin) ? yMin : $$.getYDomainMin(yTargets), yDomainMax = isValue(yMax) ? yMax : $$.getYDomainMax(yTargets), domainLength, padding, padding_top, padding_bottom, - center = axisId === 'y2' ? config[__axis_y2_center] : config[__axis_y_center], + center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, - isZeroBased = ($$.hasType('bar', yTargets) && config[__bar_zerobased]) || ($$.hasType('area', yTargets) && config[__area_zerobased]), - showHorizontalDataLabel = $$.hasDataLabel() && config[__axis_rotated], - showVerticalDataLabel = $$.hasDataLabel() && !config[__axis_rotated]; + isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || ($$.hasType('area', yTargets) && config.area_zerobased), + showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, + showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; if (yTargets.length === 0) { // use current domain if target of axisId is none return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); } @@ -108,13 +108,13 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) { padding_top += lengths[1]; padding_bottom += lengths[0]; } - if (axisId === 'y' && config[__axis_y_padding]) { - padding_top = $$.getAxisPadding(config[__axis_y_padding], 'top', padding, domainLength); - padding_bottom = $$.getAxisPadding(config[__axis_y_padding], 'bottom', padding, domainLength); + if (axisId === 'y' && config.axis_y_padding) { + padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength); + padding_bottom = $$.getAxisPadding(config.axis_y_padding, 'bottom', padding, domainLength); } - if (axisId === 'y2' && config[__axis_y2_padding]) { - padding_top = $$.getAxisPadding(config[__axis_y2_padding], 'top', padding, domainLength); - padding_bottom = $$.getAxisPadding(config[__axis_y2_padding], 'bottom', padding, domainLength); + if (axisId === 'y2' && config.axis_y2_padding) { + padding_top = $$.getAxisPadding(config.axis_y2_padding, 'top', padding, domainLength); + padding_bottom = $$.getAxisPadding(config.axis_y2_padding, 'bottom', padding, domainLength); } // Bar/Area chart should be 0-based if all positive|negative if (isZeroBased) { @@ -125,14 +125,14 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId) { }; c3_chart_internal_fn.getXDomainMin = function (targets) { var $$ = this, config = $$.config; - return config[__axis_x_min] ? - ($$.isTimeSeries() ? this.parseDate(config[__axis_x_min]) : config[__axis_x_min]) : + return config.axis_x_min ? + ($$.isTimeSeries() ? this.parseDate(config.axis_x_min) : config.axis_x_min) : $$.d3.min(targets, function (t) { return $$.d3.min(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainMax = function (targets) { var $$ = this, config = $$.config; - return config[__axis_x_max] ? - ($$.isTimeSeries() ? this.parseDate(config[__axis_x_max]) : config[__axis_x_max]) : + return config.axis_x_max ? + ($$.isTimeSeries() ? this.parseDate(config.axis_x_max) : config.axis_x_max) : $$.d3.max(targets, function (t) { return $$.d3.max(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainPadding = function (targets) { @@ -147,11 +147,11 @@ c3_chart_internal_fn.getXDomainPadding = function (targets) { } else { padding = diff * 0.01; } - if (typeof config[__axis_x_padding] === 'object' && notEmpty(config[__axis_x_padding])) { - paddingLeft = isValue(config[__axis_x_padding].left) ? config[__axis_x_padding].left : padding; - paddingRight = isValue(config[__axis_x_padding].right) ? config[__axis_x_padding].right : padding; - } else if (typeof config[__axis_x_padding] === 'number') { - paddingLeft = paddingRight = config[__axis_x_padding]; + if (typeof config.axis_x_padding === 'object' && notEmpty(config.axis_x_padding)) { + paddingLeft = isValue(config.axis_x_padding.left) ? config.axis_x_padding.left : padding; + paddingRight = isValue(config.axis_x_padding.right) ? config.axis_x_padding.right : padding; + } else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; } else { paddingLeft = paddingRight = padding; } @@ -181,13 +181,13 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU if (withUpdateOrgXDomain) { $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); $$.orgXDomain = $$.x.domain(); - if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); } + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } $$.subX.domain($$.x.domain()); if ($$.brush) { $$.brush.scale($$.subX); } } if (withUpdateXDomain) { $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); - if (config[__zoom_enabled]) { $$.zoom.scale($$.x).updateScaleExtent(); } + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } } return $$.x.domain(); }; diff --git a/src/drag.js b/src/drag.js index 7918fff..bd2446a 100644 --- a/src/drag.js +++ b/src/drag.js @@ -3,9 +3,9 @@ c3_chart_internal_fn.drag = function (mouse) { var sx, sy, mx, my, minX, maxX, minY, maxY; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable - if (config[__zoom_enabled] && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior - if (!config[__data_selection_multiple]) { return; } // skip when single selection because drag is used for multiple selection + if (! config.data_selection_enabled) { return; } // do nothing if not selectable + if (config.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior + if (!config.data_selection_multiple) { return; } // skip when single selection because drag is used for multiple selection sx = $$.dragStart[0]; sy = $$.dragStart[1]; @@ -13,8 +13,8 @@ c3_chart_internal_fn.drag = function (mouse) { my = mouse[1]; minX = Math.min(sx, mx); maxX = Math.max(sx, mx); - minY = (config[__data_selection_grouped]) ? $$.margin.top : Math.min(sy, my); - maxY = (config[__data_selection_grouped]) ? $$.height : Math.max(sy, my); + minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); + maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); main.select('.' + CLASS[_dragarea]) .attr('x', minX) @@ -23,7 +23,7 @@ c3_chart_internal_fn.drag = function (mouse) { .attr('height', maxY - minY); // TODO: binary search when multiple xs main.selectAll('.' + CLASS[_shapes]).selectAll('.' + CLASS[_shape]) - .filter(function (d) { return config[__data_selection_isselectable](d); }) + .filter(function (d) { return config.data_selection_isselectable(d); }) .each(function (d, i) { var shape = d3.select(this), isSelected = shape.classed(CLASS[_SELECTED]), @@ -59,19 +59,19 @@ c3_chart_internal_fn.drag = function (mouse) { c3_chart_internal_fn.dragstart = function (mouse) { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable + if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.dragStart = mouse; $$.main.select('.' + CLASS[_chart]).append('rect') .attr('class', CLASS[_dragarea]) .style('opacity', 0.1); $$.dragging = true; - $$.config[__data_ondragstart](); + $$.config.data_ondragstart(); }; c3_chart_internal_fn.dragend = function () { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } - if (! config[__data_selection_enabled]) { return; } // do nothing if not selectable + if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.main.select('.' + CLASS[_dragarea]) .transition().duration(100) .style('opacity', 0) @@ -79,6 +79,6 @@ c3_chart_internal_fn.dragend = function () { $$.main.selectAll('.' + CLASS[_shape]) .classed(CLASS[_INCLUDED], false); $$.dragging = false; - $$.config[__data_ondragend](); + $$.config.data_ondragend(); }; diff --git a/src/format.js b/src/format.js index 58c6b1f..91911fa 100644 --- a/src/format.js +++ b/src/format.js @@ -9,12 +9,12 @@ c3_chart_internal_fn.getYFormat = function (forArc) { }; c3_chart_internal_fn.yFormat = function (v) { var $$ = this, config = $$.config, - format = config[__axis_y_tick_format] ? config[__axis_y_tick_format] : $$.defaultValueFormat; + format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.y2Format = function (v) { var $$ = this, config = $$.config, - format = config[__axis_y2_tick_format] ? config[__axis_y2_tick_format] : $$.defaultValueFormat; + format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.defaultValueFormat = function (v) { @@ -24,7 +24,7 @@ c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) { return (ratio * 100).toFixed(1) + '%'; }; c3_chart_internal_fn.formatByAxisId = function (axisId) { - var $$ = this, data_labels = $$.config[__data_labels], + var $$ = this, data_labels = $$.config.data_labels, format = function (v) { return isValue(v) ? +v : ""; }; // find format according to axis id if (data_labels.format) { diff --git a/src/grid.js b/src/grid.js index 3dbdfa2..c76a8ac 100644 --- a/src/grid.js +++ b/src/grid.js @@ -3,15 +3,15 @@ c3_chart_internal_fn.initGrid = function () { $$.grid = $$.main.append('g') .attr("clip-path", $$.clipPath) .attr('class', CLASS[_grid]); - if (config[__grid_x_show]) { + if (config.grid_x_show) { $$.grid.append("g").attr("class", CLASS[_xgrids]); } - if (config[__grid_y_show]) { + if (config.grid_y_show) { $$.grid.append('g').attr('class', CLASS[_ygrids]); } $$.grid.append('g').attr("class", CLASS[_xgridLines]); $$.grid.append('g').attr('class', CLASS[_ygridLines]); - if (config[__grid_focus_show]) { + if (config.grid_focus_show) { $$.grid.append('g') .attr("class", CLASS[_xgridFocus]) .append('line') @@ -23,10 +23,10 @@ c3_chart_internal_fn.initGrid = function () { c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { var $$ = this, config = $$.config, CLASS = $$.CLASS, d3 = $$.d3, - xgridData = $$.generateGridData(config[__grid_x_type], $$.x), + xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; - $$.xgridAttr = config[__axis_rotated] ? { + $$.xgridAttr = config.axis_rotated ? { 'x1': 0, 'x2': $$.width, 'y1': function (d) { return $$.x(d) - tickOffset; }, @@ -43,7 +43,7 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { $$.xgrid.enter().append('line').attr("class", CLASS[_xgrid]); if (!withoutUpdate) { $$.xgrid.attr($$.xgridAttr) - .style("opacity", function () { return +d3.select(this).attr(config[__axis_rotated] ? 'y1' : 'x1') === (config[__axis_rotated] ? $$.height : 0) ? 0 : 1; }); + .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); } $$.xgrid.exit().remove(); }; @@ -51,13 +51,13 @@ c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { c3_chart_internal_fn.updateYGrid = function () { var $$ = this, config = $$.config, CLASS = $$.CLASS; $$.ygrid = $$.main.select('.' + CLASS[_ygrids]).selectAll('.' + CLASS[_ygrid]) - .data($$.y.ticks(config[__grid_y_ticks])); + .data($$.y.ticks(config.grid_y_ticks)); $$.ygrid.enter().append('line') .attr('class', CLASS[_ygrid]); - $$.ygrid.attr("x1", config[__axis_rotated] ? $$.y : 0) - .attr("x2", config[__axis_rotated] ? $$.y : $$.width) - .attr("y1", config[__axis_rotated] ? 0 : $$.y) - .attr("y2", config[__axis_rotated] ? $$.height : $$.y); + $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0) + .attr("x2", config.axis_rotated ? $$.y : $$.width) + .attr("y1", config.axis_rotated ? 0 : $$.y) + .attr("y2", config.axis_rotated ? $$.height : $$.y); $$.ygrid.exit().remove(); $$.smoothLines($$.ygrid, 'grid'); }; @@ -67,11 +67,11 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { var $$ = this, main = $$.main, config = $$.config, CLASS = $$.CLASS, xgridLine, ygridLine, yv; main.select('line.' + CLASS[_xgridFocus]).style("visibility", "hidden"); - if (config[__grid_x_show]) { + if (config.grid_x_show) { $$.updateXGrid(); } $$.xgridLines = main.select('.' + CLASS[_xgridLines]).selectAll('.' + CLASS[_xgridLine]) - .data(config[__grid_x_lines]); + .data(config.grid_x_lines); // enter xgridLine = $$.xgridLines.enter().append('g') .attr("class", function (d) { return CLASS[_xgridLine] + (d.class ? ' ' + d.class : ''); }); @@ -79,8 +79,8 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { .style("opacity", 0); xgridLine.append('text') .attr("text-anchor", "end") - .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") - .attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top) + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") + .attr('dx', config.axis_rotated ? 0 : -$$.margin.top) .attr('dy', -5) .style("opacity", 0); // udpate @@ -91,12 +91,12 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { .remove(); // Y-Grid - if (withY && config[__grid_y_show]) { + if (withY && config.grid_y_show) { $$.updateYGrid(); } if (withY) { $$.ygridLines = main.select('.' + CLASS[_ygridLines]).selectAll('.' + CLASS[_ygridLine]) - .data(config[__grid_y_lines]); + .data(config.grid_y_lines); // enter ygridLine = $$.ygridLines.enter().append('g') .attr("class", function (d) { return CLASS[_ygridLine] + (d.class ? ' ' + d.class : ''); }); @@ -104,22 +104,22 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { .style("opacity", 0); ygridLine.append('text') .attr("text-anchor", "end") - .attr("transform", config[__axis_rotated] ? "rotate(-90)" : "") - .attr('dx', config[__axis_rotated] ? 0 : -$$.margin.top) + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") + .attr('dx', config.axis_rotated ? 0 : -$$.margin.top) .attr('dy', -5) .style("opacity", 0); // update yv = $$.yv.bind($$); $$.ygridLines.select('line') .transition().duration(duration) - .attr("x1", config[__axis_rotated] ? yv : 0) - .attr("x2", config[__axis_rotated] ? yv : $$.width) - .attr("y1", config[__axis_rotated] ? 0 : yv) - .attr("y2", config[__axis_rotated] ? $$.height : yv) + .attr("x1", config.axis_rotated ? yv : 0) + .attr("x2", config.axis_rotated ? yv : $$.width) + .attr("y1", config.axis_rotated ? 0 : yv) + .attr("y2", config.axis_rotated ? $$.height : yv) .style("opacity", 1); $$.ygridLines.select('text') .transition().duration(duration) - .attr("x", config[__axis_rotated] ? 0 : $$.width) + .attr("x", config.axis_rotated ? 0 : $$.width) .attr("y", yv) .text(function (d) { return d.text; }) .style("opacity", 1); @@ -132,13 +132,13 @@ c3_chart_internal_fn.redrawGrid = function (duration, withY) { c3_chart_internal_fn.addTransitionForGrid = function (transitions) { var $$ = this, config = $$.config, xv = $$.xv.bind($$); transitions.push($$.xgridLines.select('line').transition() - .attr("x1", config[__axis_rotated] ? 0 : xv) - .attr("x2", config[__axis_rotated] ? $$.width : xv) - .attr("y1", config[__axis_rotated] ? xv : $$.margin.top) - .attr("y2", config[__axis_rotated] ? xv : $$.height) + .attr("x1", config.axis_rotated ? 0 : xv) + .attr("x2", config.axis_rotated ? $$.width : xv) + .attr("y1", config.axis_rotated ? xv : $$.margin.top) + .attr("y2", config.axis_rotated ? xv : $$.height) .style("opacity", 1)); transitions.push($$.xgridLines.select('text').transition() - .attr("x", config[__axis_rotated] ? $$.width : 0) + .attr("x", config.axis_rotated ? $$.width : 0) .attr("y", xv) .text(function (d) { return d.text; }) .style("opacity", 1)); @@ -148,14 +148,14 @@ c3_chart_internal_fn.showXGridFocus = function (selectedData) { dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), focusEl = $$.main.selectAll('line.' + CLASS[_xgridFocus]), xx = $$.xx.bind($$); - if (! config[__tooltip_show]) { return; } + if (! config.tooltip_show) { return; } // Hide when scatter plot exists if ($$.hasType('scatter') || $$.hasArcType()) { return; } focusEl .style("visibility", "visible") .data([dataToShow[0]]) - .attr(config[__axis_rotated] ? 'y1' : 'x1', xx) - .attr(config[__axis_rotated] ? 'y2' : 'x2', xx); + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); $$.smoothLines(focusEl, 'grid'); }; c3_chart_internal_fn.hideXGridFocus = function () { @@ -164,10 +164,10 @@ c3_chart_internal_fn.hideXGridFocus = function () { c3_chart_internal_fn.updateXgridFocus = function () { var $$ = this, config = $$.config; $$.main.select('line.' + CLASS[_xgridFocus]) - .attr("x1", config[__axis_rotated] ? 0 : -10) - .attr("x2", config[__axis_rotated] ? $$.width : -10) - .attr("y1", config[__axis_rotated] ? -10 : 0) - .attr("y2", config[__axis_rotated] ? -10 : $$.height); + .attr("x1", config.axis_rotated ? 0 : -10) + .attr("x2", config.axis_rotated ? $$.width : -10) + .attr("y1", config.axis_rotated ? -10 : 0) + .attr("y2", config.axis_rotated ? -10 : $$.height); }; c3_chart_internal_fn.generateGridData = function (type, scale) { var $$ = this, @@ -206,11 +206,11 @@ c3_chart_internal_fn.removeGridLines = function (params, forX) { classLines = forX ? CLASS[_xgridLines] : CLASS[_ygridLines], classLine = forX ? CLASS[_xgridLine] : CLASS.ygridLine; $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) - .transition().duration(config[__transition_duration]) + .transition().duration(config.transition_duration) .style('opacity', 0).remove(); if (forX) { - config[__grid_x_lines] = config[__grid_x_lines].filter(toShow); + config.grid_x_lines = config.grid_x_lines.filter(toShow); } else { - config[__grid_y_lines] = config[__grid_y_lines].filter(toShow); + config.grid_y_lines = config.grid_y_lines.filter(toShow); } }; diff --git a/src/interaction.js b/src/interaction.js index 6a8e321..15fec7c 100644 --- a/src/interaction.js +++ b/src/interaction.js @@ -11,7 +11,7 @@ c3_chart_internal_fn.redrawEventRect = function () { // rects for mouseover var eventRects = $$.main.select('.' + CLASS[_eventRects]) - .style('cursor', config[__zoom_enabled] ? config[__axis_rotated] ? 'ns-resize' : 'ew-resize' : null) + .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) .classed(CLASS[_eventRectsMultiple], isMultipleX) .classed(CLASS[_eventRectsSingle], !isMultipleX); @@ -74,10 +74,10 @@ c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { return $$.x(d.x) - (rectW / 2); }; } - x = config[__axis_rotated] ? 0 : rectX; - y = config[__axis_rotated] ? rectX : 0; - w = config[__axis_rotated] ? $$.width : rectW; - h = config[__axis_rotated] ? rectW : $$.height; + x = config.axis_rotated ? 0 : rectX; + y = config.axis_rotated ? rectX : 0; + w = config.axis_rotated ? $$.width : rectW; + h = config.axis_rotated ? rectW : $$.height; } eventRectUpdate @@ -91,7 +91,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { var $$ = this, d3 = $$.d3, config = $$.config; eventRectEnter.append("rect") .attr("class", $$.classEvent.bind($$)) - .style("cursor", config[__data_selection_enabled] && config[__data_selection_grouped] ? "pointer" : null) + .style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null) .on('mouseover', function (d) { var index = d.index, selectedData, newData; @@ -104,7 +104,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { // Sort selectedData as names order newData = []; - Object.keys(config[__data_names]).forEach(function (id) { + Object.keys(config.data_names).forEach(function (id) { for (var j = 0; j < selectedData.length; j++) { if (selectedData[j] && selectedData[j].id === id) { newData.push(selectedData[j]); @@ -116,12 +116,12 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { selectedData = newData.concat(selectedData); // Add remained // Expand shapes for selection - if (config[__point_focus_expand_enabled]) { $$.expandCircles(index); } + if (config.point_focus_expand_enabled) { $$.expandCircles(index); } $$.expandBars(index); // Call event handler $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { - config[__data_onmouseover].call(c3, d); + config.data_onmouseover.call($$, d); }); }) .on('mouseout', function (d) { @@ -134,7 +134,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { $$.unexpandBars(); // Call event handler $$.main.selectAll('.' + CLASS[_shape] + '-' + index).each(function (d) { - config[__data_onmouseout].call($$, d); + config.data_onmouseout.call($$, d); }); }) .on('mousemove', function (d) { @@ -149,25 +149,25 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { return $$.addName($$.getValueOnIndex(t.values, index)); }); - if (config[__tooltip_grouped]) { + if (config.tooltip_grouped) { $$.showTooltip(selectedData, d3.mouse(this)); $$.showXGridFocus(selectedData); } - if (config[__tooltip_grouped] && (!config[__data_selection_enabled] || config[__data_selection_grouped])) { + if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { return; } $$.main.selectAll('.' + CLASS[_shape] + '-' + index) .each(function () { d3.select(this).classed(CLASS[_EXPANDED], true); - if (config[__data_selection_enabled]) { - eventRect.style('cursor', config[__data_selection_grouped] ? 'pointer' : null); + if (config.data_selection_enabled) { + eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); } - if (!config[__tooltip_grouped]) { + if (!config.tooltip_grouped) { $$.hideXGridFocus(); $$.hideTooltip(); - if (!config[__data_selection_grouped]) { + if (!config.data_selection_grouped) { $$.unexpandCircles(index); $$.unexpandBars(); } @@ -182,13 +182,13 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { } }) .each(function (d) { - if (config[__data_selection_enabled] && (config[__data_selection_grouped] || config[__data_selection_isselectable](d))) { + if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { eventRect.style('cursor', 'pointer'); } - if (!config[__tooltip_grouped]) { + if (!config.tooltip_grouped) { $$.showTooltip([d], d3.mouse(this)); $$.showXGridFocus([d]); - if (config[__point_focus_expand_enabled]) { $$.expandCircles(index, d.id); } + if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id); } $$.expandBars(index, d.id); } }); @@ -252,7 +252,7 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) $$.showTooltip(selectedData, mouse); // expand points - if (config[__point_focus_expand_enabled]) { + if (config.point_focus_expand_enabled) { $$.unexpandCircles(); $$.expandCircles(closest.index, closest.id); } @@ -264,12 +264,12 @@ c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) if ($$.dist(closest, mouse) < 100) { $$.svg.select('.' + CLASS[_eventRect]).style('cursor', 'pointer'); if (!$$.mouseover) { - config[__data_onmouseover].call($$, closest); + config.data_onmouseover.call($$, closest); $$.mouseover = true; } } else if ($$.mouseover) { $$.svg.select('.' + CLASS[_eventRect]).style('cursor', null); - config[__data_onmouseout].call($$, closest); + config.data_onmouseout.call($$, closest); $$.mouseover = false; } }) diff --git a/src/legend.js b/src/legend.js index d7159e8..85f0288 100644 --- a/src/legend.js +++ b/src/legend.js @@ -1,7 +1,7 @@ c3_chart_internal_fn.initLegend = function () { var $$ = this; $$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend')); - if (!$$.config[__legend_show]) { + if (!$$.config.legend_show) { $$.legend.style('visibility', 'hidden'); $$.hiddenLegendIds = $$.mapToIds($$.data.targets); } @@ -11,8 +11,8 @@ c3_chart_internal_fn.initLegend = function () { }; c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) { var $$ = this, config = $$.config, insetLegendPosition = { - top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config[__legend_inset_y] + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config[__legend_inset_y], - left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config[__legend_inset_x] + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config[__legend_inset_x] + 0.5 + top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config.legend_inset_y, + left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config.legend_inset_x + 0.5 }; $$.margin3 = { top: $$.isLegendRight ? 0 : $$.isLegendInset ? insetLegendPosition.top : $$.currentHeight - legendHeight, @@ -36,15 +36,15 @@ c3_chart_internal_fn.updateLegendItemHeight = function (h) { }; c3_chart_internal_fn.getLegendWidth = function () { var $$ = this; - return $$.config[__legend_show] ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; + return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; }; c3_chart_internal_fn.getLegendHeight = function () { var $$ = this, config = $$.config, h = 0; - if (config[__legend_show]) { + if (config.legend_show) { if ($$.isLegendRight) { h = $$.currentHeight; } else if ($$.isLegendInset) { - h = config[__legend_inset_step] ? Math.max(20, $$.legendItemHeight) * (config[__legend_inset_step] + 1) : $$.height; + h = config.legend_inset_step ? Math.max(20, $$.legendItemHeight) * (config.legend_inset_step + 1) : $$.height; } else { h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); } @@ -80,8 +80,8 @@ c3_chart_internal_fn.revertLegend = function () { }; c3_chart_internal_fn.showLegend = function (targetIds) { var $$ = this, config = $$.config; - if (!config[__legend_show]) { - config[__legend_show] = true; + if (!config.legend_show) { + config.legend_show = true; $$.legend.style('visibility', 'visible'); } $$.removeHiddenLegendIds(targetIds); @@ -92,8 +92,8 @@ c3_chart_internal_fn.showLegend = function (targetIds) { }; c3_chart_internal_fn.hideLegend = function (targetIds) { var $$ = this, config = $$.config; - if (config[__legend_show] && isEmpty(targetIds)) { - config[__legend_show] = false; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; $$.legend.style('visibility', 'hidden'); } $$.addHiddenLegendIds(targetIds); @@ -145,7 +145,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { maxHeight = 0; } - if (config[__legend_show] && !$$.isLegendToShow(id)) { + if (config.legend_show && !$$.isLegendToShow(id)) { widths[id] = heights[id] = steps[id] = offsets[id] = 0; return; } @@ -157,7 +157,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; } maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; - if (config[__legend_equally]) { + if (config.legend_equally) { Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); margin = (areaLength - maxLength * targetIds.length) / 2; @@ -197,15 +197,15 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('cursor', 'pointer') .on('click', function (id) { - config[__legend_item_onclick] ? config[__legend_item_onclick].call($$, id) : $$.api.toggle(id); + config.legend_item_onclick ? config.legend_item_onclick.call($$, id) : $$.api.toggle(id); }) .on('mouseover', function (id) { $$.d3.select(this).classed(CLASS[_legendItemFocused], true); if (!$$.transiting) { $$.api.focus(id); } - if (config[__legend_item_onmouseover]) { - config[__legend_item_onmouseover].call($$, id); + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); } }) .on('mouseout', function (id) { @@ -213,12 +213,12 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { if (!$$.transiting) { $$.api.revert(); } - if (config[__legend_item_onmouseout]) { - config[__legend_item_onmouseout].call($$, id); + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); } }); l.append('text') - .text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; }) + .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) .each(function (id, i) { updatePositions(this, id, i === 0); }) .style("pointer-events", "none") .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) @@ -247,7 +247,7 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { texts = $$.legend.selectAll('text') .data(targetIds) - .text(function (id) { return isDefined(config[__data_names][id]) ? config[__data_names][id] : id; }) // MEMO: needed for update + .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) // MEMO: needed for update .each(function (id, i) { updatePositions(this, id, i === 0); }); (withTransition ? texts.transition() : texts) .attr('x', xForLegendText) diff --git a/src/region.js b/src/region.js index eec384a..f6a9601 100644 --- a/src/region.js +++ b/src/region.js @@ -7,7 +7,7 @@ c3_chart_internal_fn.initRegion = function () { c3_chart_internal_fn.redrawRegion = function (duration) { var $$ = this, config = $$.config, CLASS = $$.CLASS; $$.mainRegion = $$.main.select('.' + CLASS[_regions]).selectAll('.' + CLASS[_region]) - .data(config[__regions]); + .data(config.regions); $$.mainRegion.enter().append('g') .attr('class', $$.classRegion.bind($$)) .append('rect') @@ -33,9 +33,9 @@ c3_chart_internal_fn.regionX = function (d) { var $$ = this, config = $$.config, xPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - xPos = config[__axis_rotated] ? ('start' in d ? yScale(d.start) : 0) : 0; + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; } else { - xPos = config[__axis_rotated] ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0); + xPos = config.axis_rotated ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0); } return xPos; }; @@ -43,9 +43,9 @@ c3_chart_internal_fn.regionY = function (d) { var $$ = this, config = $$.config, yPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - yPos = config[__axis_rotated] ? 0 : ('end' in d ? yScale(d.end) : 0); + yPos = config.axis_rotated ? 0 : ('end' in d ? yScale(d.end) : 0); } else { - yPos = config[__axis_rotated] ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0; + yPos = config.axis_rotated ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0; } return yPos; }; @@ -53,9 +53,9 @@ c3_chart_internal_fn.regionWidth = function (d) { var $$ = this, config = $$.config, start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - end = config[__axis_rotated] ? ('end' in d ? yScale(d.end) : $$.width) : $$.width; + end = config.axis_rotated ? ('end' in d ? yScale(d.end) : $$.width) : $$.width; } else { - end = config[__axis_rotated] ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width); + end = config.axis_rotated ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width); } return end < start ? 0 : end - start; }; @@ -63,9 +63,9 @@ c3_chart_internal_fn.regionHeight = function (d) { var $$ = this, config = $$.config, start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { - end = config[__axis_rotated] ? $$.height : ('start' in d ? yScale(d.start) : $$.height); + end = config.axis_rotated ? $$.height : ('start' in d ? yScale(d.start) : $$.height); } else { - end = config[__axis_rotated] ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height; + end = config.axis_rotated ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height; } return end < start ? 0 : end - start; }; diff --git a/src/scale.js b/src/scale.js index deca515..49dbfac 100644 --- a/src/scale.js +++ b/src/scale.js @@ -53,14 +53,14 @@ c3_chart_internal_fn.updateScales = function () { var $$ = this, config = $$.config, forInit = !$$.x; // update edges - $$.xMin = config[__axis_rotated] ? 1 : 0; - $$.xMax = config[__axis_rotated] ? $$.height : $$.width; - $$.yMin = config[__axis_rotated] ? 0 : $$.height; - $$.yMax = config[__axis_rotated] ? $$.width : 1; + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; $$.subXMin = $$.xMin; $$.subXMax = $$.xMax; - $$.subYMin = config[__axis_rotated] ? 0 : $$.height2; - $$.subYMax = config[__axis_rotated] ? $$.width2 : 1; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; // update scales $$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { return $$.xAxis.tickOffset(); }); $$.y = $$.getY($$.yMin, $$.yMax, forInit ? undefined : $$.y.domain()); @@ -70,15 +70,15 @@ c3_chart_internal_fn.updateScales = function () { $$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? undefined : $$.subY2.domain()); // update axes $$.xAxisTickFormat = $$.getXAxisTickFormat(); - $$.xAxisTickValues = config[__axis_x_tick_values] ? config[__axis_x_tick_values] : (forInit ? undefined : $$.xAxis.tickValues()); + $$.xAxisTickValues = config.axis_x_tick_values ? config.axis_x_tick_values : (forInit ? undefined : $$.xAxis.tickValues()); $$.xAxis = $$.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues); $$.subXAxis = $$.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues); - $$.yAxis = $$.getYAxis($$.y, $$.yOrient, config[__axis_y_tick_format], config[__axis_y_ticks]); - $$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config[__axis_y2_tick_format], config[__axis_y2_ticks]); + $$.yAxis = $$.getYAxis($$.y, $$.yOrient, config.axis_y_tick_format, config.axis_y_ticks); + $$.y2Axis = $$.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, config.axis_y2_ticks); // Set initialized scales to brush and zoom if (!forInit) { if ($$.brush) { $$.brush.scale($$.subX); } - if (config[__zoom_enabled]) { $$.zoom.scale($$.x); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } } // update for arc if ($$.updateArc) { $$.updateArc(); } diff --git a/src/selection.js b/src/selection.js index 8ae1e48..6746087 100644 --- a/src/selection.js +++ b/src/selection.js @@ -1,9 +1,9 @@ c3_chart_internal_fn.selectPoint = function (target, d, i) { var $$ = this, config = $$.config, - cx = (config[__axis_rotated] ? $$.circleY : $$.circleX).bind($$), - cy = (config[__axis_rotated] ? $$.circleX : $$.circleY).bind($$), + cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), r = $$.pointSelectR.bind($$); - config[__data_onselected].call($$.api, d, target.node()); + config.data_onselected.call($$.api, d, target.node()); // add selected-circle on low layer g $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) .data([d]) @@ -18,7 +18,7 @@ c3_chart_internal_fn.selectPoint = function (target, d, i) { }; c3_chart_internal_fn.unselectPoint = function (target, d, i) { var $$ = this; - $$.config[__data_onunselected](d, target.node()); + $$.config.data_onunselected(d, target.node()); // remove selected-circle from low layer g $$.main.select('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[_selectedCircle] + '-' + i) .transition().duration(100).attr('r', 0) @@ -29,13 +29,13 @@ c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { }; c3_chart_internal_fn.selectBar = function (target, d) { var $$ = this; - $$.config[__data_onselected].call($$, d, target.node()); + $$.config.data_onselected.call($$, d, target.node()); target.transition().duration(100) .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); }; c3_chart_internal_fn.unselectBar = function (target, d) { var $$ = this; - $$.config[__data_onunselected].call($$, d, target.node()); + $$.config.data_onunselected.call($$, d, target.node()); target.transition().duration(100) .style("fill", function () { return $$.color(d); }); }; @@ -66,10 +66,10 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) { toggle = $$.toggleArc; } } - if (config[__data_selection_grouped] || isWithin) { - if (config[__data_selection_enabled] && config[__data_selection_isselectable](d)) { - if (!config[__data_selection_multiple]) { - $$.main.selectAll('.' + CLASS[_shapes] + (config[__data_selection_grouped] ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { + if (config.data_selection_grouped || isWithin) { + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main.selectAll('.' + CLASS[_shapes] + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[_shape]).each(function (d, i) { var shape = d3.select(this); if (shape.classed(CLASS[_SELECTED])) { toggle.call($$, false, shape.classed(CLASS[_SELECTED], false), d, i); } }); @@ -77,6 +77,6 @@ c3_chart_internal_fn.toggleShape = function (that, d, i) { shape.classed(CLASS[_SELECTED], !isSelected); toggle.call($$, !isSelected, shape, d, i); } - $$.config[__data_onclick].call($$.api, d, that); + $$.config.data_onclick.call($$.api, d, that); } }; diff --git a/src/shape.bar.js b/src/shape.bar.js index 0c82f38..195eeb2 100644 --- a/src/shape.bar.js +++ b/src/shape.bar.js @@ -18,7 +18,7 @@ c3_chart_internal_fn.updateTargetsForBar = function (targets) { // Bars for each data mainBarEnter.append('g') .attr("class", classBars) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }); + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); }; c3_chart_internal_fn.redrawBar = function (durationForExit) { @@ -48,8 +48,8 @@ c3_chart_internal_fn.addTransitionForBar = function (transitions, drawBar) { }; c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) { var $$ = this, config = $$.config, - w = typeof config[__bar_width] === 'number' ? config[__bar_width] : barTargetsNum ? (axis.tickOffset() * 2 * config[__bar_width_ratio]) / barTargetsNum : 0; - return config[__bar_width_max] && w > config[__bar_width_max] ? config[__bar_width_max] : w; + w = typeof config.bar_width === 'number' ? config.bar_width : barTargetsNum ? (axis.tickOffset() * 2 * config.bar_width_ratio) / barTargetsNum : 0; + return config.bar_width_max && w > config.bar_width_max ? config.bar_width_max : w; }; c3_chart_internal_fn.getBars = function (i) { var $$ = this; @@ -71,8 +71,8 @@ c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) { var points = getPoints(d, i); // switch points if axis is rotated, not applicable for sub chart - var indexX = config[__axis_rotated] ? 1 : 0; - var indexY = config[__axis_rotated] ? 0 : 1; + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' + 'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' + @@ -96,7 +96,7 @@ c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { offset = barOffset(d, i) || y0, // offset is for stacked bar chart posX = barX(d), posY = barY(d); // fix posY not to overflow opposite quadrant - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 4 points that make a bar diff --git a/src/shape.js b/src/shape.js index d6b7fd7..14fc156 100644 --- a/src/shape.js +++ b/src/shape.js @@ -2,11 +2,11 @@ c3_chart_internal_fn.getShapeIndices = function (typeFilter) { var $$ = this, config = $$.config, indices = {}, i = 0, j, k; $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) { - for (j = 0; j < config[__data_groups].length; j++) { - if (config[__data_groups][j].indexOf(d.id) < 0) { continue; } - for (k = 0; k < config[__data_groups][j].length; k++) { - if (config[__data_groups][j][k] in indices) { - indices[d.id] = indices[config[__data_groups][j][k]]; + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { continue; } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; break; } } diff --git a/src/shape.line.js b/src/shape.line.js index e487f20..7b55175 100644 --- a/src/shape.line.js +++ b/src/shape.line.js @@ -28,7 +28,7 @@ c3_chart_internal_fn.updateTargetsForLine = function (targets) { .attr("class", function (d) { return $$.generateClass(CLASS[_selectedCircles], d.id); }); mainLineEnter.append('g') .attr("class", classCircles) - .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }); + .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); // Update date for selected circles targets.forEach(function (t) { $$.main.selectAll('.' + CLASS[_selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[_selectedCircle]).each(function (d) { @@ -66,17 +66,17 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, yValue = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); + return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); }; - line = config[__axis_rotated] ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); - if (!config[__line_connect_null]) { line = line.defined(function (d) { return d.value != null; }); } + line = config.axis_rotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); + if (!config.line_connect_null) { line = line.defined(function (d) { return d.value != null; }); } return function (d) { - var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values, + var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values, x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; if ($$.isLineType(d)) { - if (config[__data_regions][d.id]) { - path = $$.lineWithRegions(data, x, y, config[__data_regions][d.id]); + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(data, x, y, config.data_regions[d.id]); } else { path = line.interpolate($$.getInterpolate(d))(data); } @@ -85,7 +85,7 @@ c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { x0 = x(data[0].x); y0 = y(data[0].value); } - path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; + path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; @@ -102,7 +102,7 @@ c3_chart_internal_fn.generateGetLinePoint = function (lineIndices, isSub) { // p offset = lineOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant - if (config[__axis_rotated]) { + if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the line position @@ -147,8 +147,8 @@ c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) { } // Set scales - xValue = config[__axis_rotated] ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; - yValue = config[__axis_rotated] ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; + xValue = config.axis_rotated ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; + yValue = config.axis_rotated ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; // Define svg generator function for region if ($$.isTimeSeries()) { @@ -220,19 +220,19 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, value0 = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0); + return config.data_groups.length > 0 ? getPoint(d, i)[0][1] : yScaleGetter.call($$, d.id)(0); }, value1 = function (d, i) { - return config[__data_groups].length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); + return config.data_groups.length > 0 ? getPoint(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); }; - area = config[__axis_rotated] ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1); - if (!config[__line_connect_null]) { + area = config.axis_rotated ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(value0).y1(value1); + if (!config.line_connect_null) { area = area.defined(function (d) { return d.value !== null; }); } return function (d) { - var data = config[__line_connect_null] ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; + var data = config.line_connect_null ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; if ($$.isAreaType(d)) { path = area.interpolate($$.getInterpolate(d))(data); } else { @@ -240,7 +240,7 @@ c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { x0 = $$.x(data[0].x); y0 = $$.getYScale(d.id)(data[0].value); } - path = config[__axis_rotated] ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; + path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; @@ -258,7 +258,7 @@ c3_chart_internal_fn.generateGetAreaPoint = function (areaIndices, isSub) { // p offset = areaOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant - if (config[__axis_rotated]) { + if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the area position @@ -299,7 +299,7 @@ c3_chart_internal_fn.circleX = function (d) { c3_chart_internal_fn.circleY = function (d, i) { var $$ = this, lineIndices = $$.getShapeIndices($$.isLineType), getPoint = $$.generateGetLinePoint(lineIndices); - return $$.config[__data_groups].length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value); + return $$.config.data_groups.length > 0 ? getPoint(d, i)[0][1] : $$.getYScale(d.id)(d.value); }; c3_chart_internal_fn.getCircles = function (i, id) { var $$ = this; @@ -322,15 +322,15 @@ c3_chart_internal_fn.unexpandCircles = function (i) { }; c3_chart_internal_fn.pointR = function (d) { var $$ = this, config = $$.config; - return config[__point_show] && !$$.isStepType(d) ? (isFunction(config[__point_r]) ? config[__point_r](d) : config[__point_r]) : 0; + return config.point_show && !$$.isStepType(d) ? (isFunction(config.point_r) ? config.point_r(d) : config.point_r) : 0; }; c3_chart_internal_fn.pointExpandedR = function (d) { var $$ = this, config = $$.config; - return config[__point_focus_expand_enabled] ? (config[__point_focus_expand_r] ? config[__point_focus_expand_r] : $$.pointR(d) * 1.75) : $$.pointR(d); + return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d); }; c3_chart_internal_fn.pointSelectR = function (d) { var $$ = this, config = $$.config; - return config[__point_select_r] ? config[__point_select_r] : $$.pointR(d) * 4; + return config.point_select_r ? config.point_select_r : $$.pointR(d) * 4; }; c3_chart_internal_fn.isWithinCircle = function (_this, _r) { var d3 = this.d3, diff --git a/src/size.js b/src/size.js index ad3b2cb..9c12c79 100644 --- a/src/size.js +++ b/src/size.js @@ -1,39 +1,39 @@ c3_chart_internal_fn.getCurrentWidth = function () { var $$ = this, config = $$.config; - return config[__size_width] ? config[__size_width] : $$.getParentWidth(); + return config.size_width ? config.size_width : $$.getParentWidth(); }; c3_chart_internal_fn.getCurrentHeight = function () { var $$ = this, config = $$.config, - h = config[__size_height] ? config[__size_height] : $$.getParentHeight(); + h = config.size_height ? config.size_height : $$.getParentHeight(); return h > 0 ? h : 320; }; c3_chart_internal_fn.getCurrentPaddingTop = function () { var config = this.config; - return isValue(config[__padding_top]) ? config[__padding_top] : 0; + return isValue(config.padding_top) ? config.padding_top : 0; }; c3_chart_internal_fn.getCurrentPaddingBottom = function () { var config = this.config; - return isValue(config[__padding_bottom]) ? config[__padding_bottom] : 0; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; }; c3_chart_internal_fn.getCurrentPaddingLeft = function () { var $$ = this, config = $$.config; - if (isValue(config[__padding_left])) { - return config[__padding_left]; - } else if (config[__axis_rotated]) { - return !config[__axis_x_show] ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40); + if (isValue(config.padding_left)) { + return config.padding_left; + } else if (config.axis_rotated) { + return !config.axis_x_show ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x')), 40); } else { - return !config[__axis_y_show] ? 1 : ceil10($$.getAxisWidthByAxisId('y')); + return !config.axis_y_show ? 1 : ceil10($$.getAxisWidthByAxisId('y')); } }; c3_chart_internal_fn.getCurrentPaddingRight = function () { var $$ = this, config = $$.config, defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; - if (isValue(config[__padding_right])) { - return config[__padding_right] + 1; // 1 is needed not to hide tick line - } else if (config[__axis_rotated]) { + if (isValue(config.padding_right)) { + return config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { return defaultPadding + legendWidthOnRight; } else { - return (!config[__axis_y2_show] ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight; + return (!config.axis_y2_show ? defaultPadding : ceil10($$.getAxisWidthByAxisId('y2'))) + legendWidthOnRight; } }; @@ -59,7 +59,7 @@ c3_chart_internal_fn.getParentHeight = function () { c3_chart_internal_fn.getSvgLeft = function () { var $$ = this, config = $$.config, - leftAxisClass = config[__axis_rotated] ? CLASS[_axisX] : CLASS[_axisY], + leftAxisClass = config.axis_rotated ? CLASS[_axisX] : CLASS[_axisY], leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, chartRect = $$.selectChart.node().getBoundingClientRect(), @@ -75,10 +75,10 @@ c3_chart_internal_fn.getAxisWidthByAxisId = function (id) { }; c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) { var $$ = this, config = $$.config; - if (axisId === 'x' && !config[__axis_x_show]) { return 0; } - if (axisId === 'x' && config[__axis_x_height]) { return config[__axis_x_height]; } - if (axisId === 'y' && !config[__axis_y_show]) { return config[__legend_show] && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } - if (axisId === 'y2' && !config[__axis_y2_show]) { return $$.rotated_padding_top; } + if (axisId === 'x' && !config.axis_x_show) { return 0; } + if (axisId === 'x' && config.axis_x_height) { return config.axis_x_height; } + if (axisId === 'y' && !config.axis_y_show) { return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } + if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } return ($$.getAxisLabelPositionById(axisId).isInner ? 30 : 40) + (axisId === 'y2' ? -10 : 0); }; @@ -92,7 +92,7 @@ c3_chart_internal_fn.getEventRectWidth = function () { firstData = target.values[0], lastData = target.values[target.values.length - 1]; base = $$.x(lastData.x) - $$.x(firstData.x); if (base === 0) { - return $$.config[__axis_rotated] ? $$.height : $$.width; + return $$.config.axis_rotated ? $$.height : $$.width; } maxDataCount = $$.getMaxDataCount(); ratio = ($$.hasType('bar') ? (maxDataCount - ($$.isCategorized() ? 0.25 : 1)) / maxDataCount : 1); diff --git a/src/subchart.js b/src/subchart.js index 3781136..da089de 100644 --- a/src/subchart.js +++ b/src/subchart.js @@ -6,14 +6,14 @@ c3_chart_internal_fn.initBrush = function () { return this; }; $$.brush.scale = function (scale) { - return $$.config[__axis_rotated] ? this.y(scale) : this.x(scale); + return $$.config.axis_rotated ? this.y(scale) : this.x(scale); }; }; c3_chart_internal_fn.initSubchart = function () { var $$ = this, config = $$.config, context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')); - if (!config[__subchart_show]) { + if (!config.subchart_show) { context.style('visibility', 'hidden'); } @@ -36,14 +36,14 @@ c3_chart_internal_fn.initSubchart = function () { .attr("class", CLASS[_brush]) .call($$.brush) .selectAll("rect") - .attr(config[__axis_rotated] ? "width" : "height", config[__axis_rotated] ? $$.width2 : $$.height2); + .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") .attr("class", CLASS[_axisX]) .attr("transform", $$.getTranslate('subx')) - .attr("clip-path", config[__axis_rotated] ? "" : $$.clipPathForXAxis); + .attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis); }; c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { var $$ = this, context = $$.context, config = $$.config, @@ -54,7 +54,7 @@ c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); - if (config[__subchart_show]) { + if (config.subchart_show) { contextBarUpdate = context.select('.' + CLASS[_chartBars]).selectAll('.' + CLASS[_chartBar]) .data(targets) .attr('class', classChartBar); @@ -91,7 +91,7 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat initialOpacity = $$.initialOpacity.bind($$); // subchart - if (config[__subchart_show]) { + if (config.subchart_show) { // reflect main chart to extent on subchart if zoomed if (d3.event && d3.event.type === 'zoom') { $$.brush.extent($$.x.orgDomain()).update(); @@ -100,8 +100,8 @@ c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, durat if (withSubchart) { // rotate tick text if needed - if (!config[__axis_rotated] && config[__axis_x_tick_rotate]) { - $$.rotateTickText($$.axes.subx, transitions.axisSubX, config[__axis_x_tick_rotate]); + if (!config.axis_rotated && config.axis_x_tick_rotate) { + $$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate); } // extent rect @@ -168,7 +168,7 @@ c3_chart_internal_fn.redrawForBrush = function () { withSubchart: false, withUpdateXDomain: true }); - $$.config[__subchart_onbrush].call($$.api, x.orgDomain()); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.transformContext = function (withTransition, transitions) { var $$ = this, subXAxis; diff --git a/src/text.js b/src/text.js index ad9ccc3..55a2615 100644 --- a/src/text.js +++ b/src/text.js @@ -26,7 +26,7 @@ c3_chart_internal_fn.redrawText = function (durationForExit) { .data(barOrLineData); $$.mainText.enter().append('text') .attr("class", classText) - .attr('text-anchor', function (d) { return config[__axis_rotated] ? (d.value < 0 ? 'end' : 'start') : 'middle'; }) + .attr('text-anchor', function (d) { return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; }) .style("stroke", 'none') .style("fill", function (d) { return $$.color(d); }) .style("fill-opacity", 0); @@ -68,7 +68,7 @@ c3_chart_internal_fn.generateXYForText = function (barIndices, forX) { c3_chart_internal_fn.getXForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), xPos, padding; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { padding = $$.isBarType(d) ? 4 : 6; xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); } else { @@ -79,7 +79,7 @@ c3_chart_internal_fn.getXForText = function (points, d, textElement) { c3_chart_internal_fn.getYForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), yPos; - if ($$.config[__axis_rotated]) { + if ($$.config.axis_rotated) { yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; } else { yPos = points[2][1] + (d.value < 0 ? box.height : $$.isBarType(d) ? -3 : -6); diff --git a/src/tooltip.js b/src/tooltip.js index 58a4364..c960f8b 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -8,27 +8,27 @@ c3_chart_internal_fn.initTooltip = function () { .style("z-index", "10") .style("display", "none"); // Show tooltip if needed - if (config[__tooltip_init_show]) { - if ($$.isTimeSeries() && isString(config[__tooltip_init_x])) { - config[__tooltip_init_x] = $$.parseDate(config[__tooltip_init_x]); + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); for (i = 0; i < $$.data.targets[0].values.length; i++) { - if (($$.data.targets[0].values[i].x - config[__tooltip_init_x]) === 0) { break; } + if (($$.data.targets[0].values[i].x - config.tooltip_init_x) === 0) { break; } } - config[__tooltip_init_x] = i; + config.tooltip_init_x = i; } - $$.tooltip.html(config[__tooltip_contents].call($$, $$.data.targets.map(function (d) { - return $$.addName(d.values[config[__tooltip_init_x]]); + $$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) { + return $$.addName(d.values[config.tooltip_init_x]); }), $$.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color)); - $$.tooltip.style("top", config[__tooltip_init_position].top) - .style("left", config[__tooltip_init_position].left) + $$.tooltip.style("top", config.tooltip_init_position.top) + .style("left", config.tooltip_init_position.left) .style("display", "block"); } }; c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) { var $$ = this, config = $$.config, - titleFormat = config[__tooltip_format_title] || defaultTitleFormat, - nameFormat = config[__tooltip_format_name] || function (name) { return name; }, - valueFormat = config[__tooltip_format_value] || defaultValueFormat, + titleFormat = config.tooltip_format_title || defaultTitleFormat, + nameFormat = config.tooltip_format_name || function (name) { return name; }, + valueFormat = 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; } @@ -54,10 +54,10 @@ c3_chart_internal_fn.showTooltip = function (selectedData, mouse) { var tWidth, tHeight, svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; var forArc = $$.hasArcType(), dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }); - if (dataToShow.length === 0 || !config[__tooltip_show]) { + if (dataToShow.length === 0 || !config.tooltip_show) { return; } - $$.tooltip.html(config[__tooltip_contents].call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); + $$.tooltip.html(config.tooltip_contents.call($$, selectedData, $$.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); // Get tooltip dimensions tWidth = $$.tooltip.property('offsetWidth'); @@ -67,7 +67,7 @@ c3_chart_internal_fn.showTooltip = function (selectedData, mouse) { tooltipLeft = ($$.width / 2) + mouse[0]; tooltipTop = ($$.height / 2) + mouse[1] + 20; } else { - if (config[__axis_rotated]) { + if (config.axis_rotated) { svgLeft = $$.getSvgLeft(); tooltipLeft = svgLeft + mouse[0] + 100; tooltipRight = tooltipLeft + tWidth; diff --git a/src/type.js b/src/type.js index bd7217a..e08b04d 100644 --- a/src/type.js +++ b/src/type.js @@ -1,15 +1,15 @@ c3_chart_internal_fn.setTargetType = function (targetIds, type) { var $$ = this, config = $$.config; $$.mapToTargetIds(targetIds).forEach(function (id) { - $$.withoutFadeIn[id] = (type === config[__data_types][id]); - config[__data_types][id] = type; + $$.withoutFadeIn[id] = (type === config.data_types[id]); + config.data_types[id] = type; }); if (!targetIds) { - config[__data_type] = type; + config.data_type = type; } }; c3_chart_internal_fn.hasType = function (type, targets) { - var $$ = this, types = $$.config[__data_types], has = false; + var $$ = this, types = $$.config.data_types, has = false; (targets || $$.data.targets).forEach(function (t) { if ((types[t.id] && types[t.id].indexOf(type) >= 0) || (!(t.id in types) && type === 'line')) { has = true; @@ -22,39 +22,39 @@ c3_chart_internal_fn.hasArcType = function (targets) { }; c3_chart_internal_fn.isLineType = function (d) { var config = this.config, id = isString(d) ? d : d.id; - return !config[__data_types][id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config[__data_types][id]) >= 0; + return !config.data_types[id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0; }; c3_chart_internal_fn.isStepType = function (d) { var id = isString(d) ? d : d.id; - return ['step', 'area-step'].indexOf(this.config[__data_types][id]) >= 0; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isSplineType = function (d) { var id = isString(d) ? d : d.id; - return ['spline', 'area-spline'].indexOf(this.config[__data_types][id]) >= 0; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isAreaType = function (d) { var id = isString(d) ? d : d.id; - return ['area', 'area-spline', 'area-step'].indexOf(this.config[__data_types][id]) >= 0; + return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isBarType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'bar'; + return this.config.data_types[id] === 'bar'; }; c3_chart_internal_fn.isScatterType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'scatter'; + return this.config.data_types[id] === 'scatter'; }; c3_chart_internal_fn.isPieType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'pie'; + return this.config.data_types[id] === 'pie'; }; c3_chart_internal_fn.isGaugeType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'gauge'; + return this.config.data_types[id] === 'gauge'; }; c3_chart_internal_fn.isDonutType = function (d) { var id = isString(d) ? d : d.id; - return this.config[__data_types][id] === 'donut'; + return this.config.data_types[id] === 'donut'; }; c3_chart_internal_fn.isArcType = function (d) { return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); diff --git a/src/zoom.js b/src/zoom.js index 0a4c236..43ef248 100644 --- a/src/zoom.js +++ b/src/zoom.js @@ -6,10 +6,10 @@ c3_chart_internal_fn.initZoom = function () { }) .on("zoom", function () { $$.redrawForZoom.call($$); }); $$.zoom.scale = function (scale) { - return config[__axis_rotated] ? this.y(scale) : this.x(scale); + return config.axis_rotated ? this.y(scale) : this.x(scale); }; $$.zoom.orgScaleExtent = function () { - var extent = config[__zoom_extent] ? config[__zoom_extent] : [1, 10]; + var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; }; $$.zoom.updateScaleExtent = function () { @@ -20,13 +20,13 @@ c3_chart_internal_fn.initZoom = function () { }; }; c3_chart_internal_fn.updateZoom = function () { - var $$ = this, z = $$.config[__zoom_enabled] ? $$.zoom : function () {}; + var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; $$.main.select('.' + $$.CLASS[_zoomRect]).call(z); $$.main.selectAll('.' + $$.CLASS[_eventRect]).call(z); }; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x, orgXDomain = $$.orgXDomain; - if (!config[__zoom_enabled]) { + if (!config.zoom_enabled) { return; } if ($$.filterTargetsToShow($$.data.targets).length === 0) { @@ -48,5 +48,5 @@ c3_chart_internal_fn.redrawForZoom = function () { if (d3.event.sourceEvent.type === 'mousemove') { $$.cancelClick = true; } - config[__zoom_onzoom].call($$.api, x.orgDomain()); + config.zoom_onzoom.call($$.api, x.orgDomain()); };