Commit 63edd6d0 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Ref CLASS key

parent f9b46bb4
...@@ -395,14 +395,14 @@ ...@@ -395,14 +395,14 @@
if (! text) { if (! text) {
title = titleFormat ? titleFormat(d[i].x) : d[i].x; title = titleFormat ? titleFormat(d[i].x) : d[i].x;
text = "<table class='" + CLASS.tooltip + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : ""); text = "<table class='" + CLASS[tooltip] + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : "");
} }
name = nameFormat(d[i].name); name = nameFormat(d[i].name);
value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index);
bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id);
text += "<tr class='" + CLASS.tooltipName + "-" + d[i].id + "'>"; text += "<tr class='" + CLASS[tooltipName] + "-" + d[i].id + "'>";
text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>"; text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>";
text += "<td class='value'>" + value + "</td>"; text += "<td class='value'>" + value + "</td>";
text += "</tr>"; text += "</tr>";
...@@ -660,51 +660,51 @@ ...@@ -660,51 +660,51 @@
// text when empty // text when empty
main.append("text") main.append("text")
.attr("class", CLASS.text + ' ' + CLASS.empty) .attr("class", CLASS[text] + ' ' + CLASS[empty])
.attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers. .attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers.
.attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE. .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE.
// Regions // Regions
main.append('g') main.append('g')
.attr("clip-path", $$.clipPath) .attr("clip-path", $$.clipPath)
.attr("class", CLASS.regions); .attr("class", CLASS[regions]);
// Grids // Grids
$$.grid = main.append('g') $$.grid = main.append('g')
.attr("clip-path", $$.clipPath) .attr("clip-path", $$.clipPath)
.attr('class', CLASS.grid); .attr('class', CLASS[grid]);
if (config[__grid_x_show]) { if (config[__grid_x_show]) {
$$.grid.append("g").attr("class", CLASS.xgrids); $$.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[ygrids]);
} }
$$.grid.append('g').attr("class", CLASS.xgridLines); $$.grid.append('g').attr("class", CLASS[xgridLines]);
$$.grid.append('g').attr('class', CLASS.ygridLines); $$.grid.append('g').attr('class', CLASS[ygridLines]);
if (config[__grid_focus_show]) { if (config[__grid_focus_show]) {
$$.grid.append('g') $$.grid.append('g')
.attr("class", CLASS.xgridFocus) .attr("class", CLASS[xgridFocus])
.append('line') .append('line')
.attr('class', CLASS.xgridFocus); .attr('class', CLASS[xgridFocus]);
} }
// Define g for chart area // Define g for chart area
main.append('g') main.append('g')
.attr("clip-path", $$.clipPath) .attr("clip-path", $$.clipPath)
.attr('class', CLASS.chart); .attr('class', CLASS[chart]);
// Cover whole with rects for events // Cover whole with rects for events
eventRect = main.select('.' + CLASS.chart).append("g") eventRect = main.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.eventRects) .attr("class", CLASS[eventRects])
.style('fill-opacity', 0); .style('fill-opacity', 0);
// Define g for bar chart area // Define g for bar chart area
main.select('.' + CLASS.chart).append("g") main.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartBars); .attr("class", CLASS[chartBars]);
// Define g for line chart area // Define g for line chart area
main.select('.' + CLASS.chart).append("g") main.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartLines); .attr("class", CLASS[chartLines]);
// Define g for arc chart area // Define g for arc chart area
if (isFunction($$.initArc)) { if (isFunction($$.initArc)) {
...@@ -714,12 +714,12 @@ ...@@ -714,12 +714,12 @@
$$.initGauge(); $$.initGauge();
} }
main.select('.' + CLASS.chart).append("g") main.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartTexts); .attr("class", CLASS[chartTexts]);
// if zoom privileged, insert rect to forefront // if zoom privileged, insert rect to forefront
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('class', CLASS[zoomRect])
.attr('width', $$.width) .attr('width', $$.width)
.attr('height', $$.height) .attr('height', $$.height)
.style('opacity', 0) .style('opacity', 0)
...@@ -732,32 +732,32 @@ ...@@ -732,32 +732,32 @@
// Add Axis // Add Axis
$$.axes.x = main.append("g") $$.axes.x = main.append("g")
.attr("class", CLASS.axis + ' ' + CLASS.axisX) .attr("class", CLASS[axis] + ' ' + CLASS[axisX])
.attr("clip-path", $$.clipPathForXAxis) .attr("clip-path", $$.clipPathForXAxis)
.attr("transform", $$.translate.x) .attr("transform", $$.translate.x)
.style("visibility", config[__axis_x_show] ? 'visible' : 'hidden'); .style("visibility", config[__axis_x_show] ? 'visible' : 'hidden');
$$.axes.x.append("text") $$.axes.x.append("text")
.attr("class", CLASS.axisXLabel) .attr("class", CLASS[axisXLabel])
.attr("transform", config[__axis_rotated] ? "rotate(-90)" : "") .attr("transform", config[__axis_rotated] ? "rotate(-90)" : "")
.style("text-anchor", generateCall($$.textAnchorForXAxisLabel, $$)); .style("text-anchor", generateCall($$.textAnchorForXAxisLabel, $$));
$$.axes.y = main.append("g") $$.axes.y = main.append("g")
.attr("class", CLASS.axis + ' ' + CLASS.axisY) .attr("class", CLASS[axis] + ' ' + CLASS[axisY])
.attr("clip-path", $$.clipPathForYAxis) .attr("clip-path", $$.clipPathForYAxis)
.attr("transform", $$.translate.y) .attr("transform", $$.translate.y)
.style("visibility", config[__axis_y_show] ? 'visible' : 'hidden'); .style("visibility", config[__axis_y_show] ? 'visible' : 'hidden');
$$.axes.y.append("text") $$.axes.y.append("text")
.attr("class", CLASS.axisYLabel) .attr("class", CLASS[axisYLabel])
.attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)")
.style("text-anchor", generateCall($$.textAnchorForYAxisLabel, $$)); .style("text-anchor", generateCall($$.textAnchorForYAxisLabel, $$));
$$.axes.y2 = main.append("g") $$.axes.y2 = main.append("g")
.attr("class", CLASS.axis + ' ' + CLASS.axisY2) .attr("class", CLASS[axis] + ' ' + CLASS[axisY2])
// clip-path? // clip-path?
.attr("transform", $$.translate.y2) .attr("transform", $$.translate.y2)
.style("visibility", config[__axis_y2_show] ? 'visible' : 'hidden'); .style("visibility", config[__axis_y2_show] ? 'visible' : 'hidden');
$$.axes.y2.append("text") $$.axes.y2.append("text")
.attr("class", CLASS.axisY2Label) .attr("class", CLASS[axisY2Label])
.attr("transform", config[__axis_rotated] ? "" : "rotate(-90)") .attr("transform", config[__axis_rotated] ? "" : "rotate(-90)")
.style("text-anchor", generateCall($$.textAnchorForY2AxisLabel, $$)); .style("text-anchor", generateCall($$.textAnchorForY2AxisLabel, $$));
...@@ -913,7 +913,7 @@ ...@@ -913,7 +913,7 @@
/*-- Main --*/ /*-- Main --*/
//-- Text --// //-- Text --//
mainTextUpdate = main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) mainTextUpdate = main.select('.' + CLASS[chartTexts]).selectAll('.' + CLASS[chartText])
.data(targets) .data(targets)
.attr('class', generateCall($$.classChartText, $$)); .attr('class', generateCall($$.classChartText, $$));
mainTextEnter = mainTextUpdate.enter().append('g') mainTextEnter = mainTextUpdate.enter().append('g')
...@@ -924,7 +924,7 @@ ...@@ -924,7 +924,7 @@
.attr('class', generateCall($$.classTexts, $$)); .attr('class', generateCall($$.classTexts, $$));
//-- Bar --// //-- Bar --//
mainBarUpdate = main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) mainBarUpdate = main.select('.' + CLASS[chartBars]).selectAll('.' + CLASS[chartBar])
.data(targets) .data(targets)
.attr('class', generateCall($$.classChartBar, $$)); .attr('class', generateCall($$.classChartBar, $$));
mainBarEnter = mainBarUpdate.enter().append('g') mainBarEnter = mainBarUpdate.enter().append('g')
...@@ -937,7 +937,7 @@ ...@@ -937,7 +937,7 @@
.style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; }); .style("cursor", function (d) { return config[__data_selection_isselectable](d) ? "pointer" : null; });
//-- Line --// //-- Line --//
mainLineUpdate = main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) mainLineUpdate = main.select('.' + CLASS[chartLines]).selectAll('.' + CLASS[chartLine])
.data(targets) .data(targets)
.attr('class', generateCall($$.classChartLine, $$)); .attr('class', generateCall($$.classChartLine, $$));
mainLineEnter = mainLineUpdate.enter().append('g') mainLineEnter = mainLineUpdate.enter().append('g')
...@@ -952,13 +952,13 @@ ...@@ -952,13 +952,13 @@
.attr('class', generateCall($$.classAreas, $$)); .attr('class', generateCall($$.classAreas, $$));
// Circles for each data point on lines // Circles for each data point on lines
mainLineEnter.append('g') mainLineEnter.append('g')
.attr("class", function (d) { return $$.generateClass(CLASS.selectedCircles, d.id); }); .attr("class", function (d) { return $$.generateClass(CLASS[selectedCircles], d.id); });
mainLineEnter.append('g') mainLineEnter.append('g')
.attr("class", generateCall($$.classCircles, $$)) .attr("class", generateCall($$.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 // Update date for selected circles
targets.forEach(function (t) { targets.forEach(function (t) {
main.selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS.selectedCircle).each(function (d) { main.selectAll('.' + CLASS[selectedCircles] + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS[selectedCircle]).each(function (d) {
d.value = t.values[d.index].value; d.value = t.values[d.index].value;
}); });
}); });
...@@ -975,7 +975,7 @@ ...@@ -975,7 +975,7 @@
/*-- Show --*/ /*-- Show --*/
// Fade-in each chart // Fade-in each chart
$$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) $$.svg.selectAll('.' + CLASS[target]).filter(function (d) { return $$.isTargetToShow(d.id); })
.transition().duration(config[__transition_duration]) .transition().duration(config[__transition_duration])
.style("opacity", 1); .style("opacity", 1);
}; };
...@@ -1059,14 +1059,14 @@ ...@@ -1059,14 +1059,14 @@
break; break;
} }
} }
$$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { $$.svg.selectAll('.' + CLASS[axisX] + ' .tick text').each(function (e) {
var index = tickValues.indexOf(e); var index = tickValues.indexOf(e);
if (index >= 0) { if (index >= 0) {
d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block');
} }
}); });
} else { } else {
$$.svg.selectAll('.' + CLASS.axisX + ' .tick text').style('display', 'block'); $$.svg.selectAll('.' + CLASS[axisX] + ' .tick text').style('display', 'block');
} }
} }
...@@ -1093,7 +1093,7 @@ ...@@ -1093,7 +1093,7 @@
$$.updateXgridFocus(); $$.updateXgridFocus();
// Data empty label positioning and text. // Data empty label positioning and text.
main.select("text." + CLASS.text + '.' + CLASS.empty) main.select("text." + CLASS[text] + '.' + CLASS[empty])
.attr("x", $$.width / 2) .attr("x", $$.width / 2)
.attr("y", $$.height / 2) .attr("y", $$.height / 2)
.text(config[__data_empty_label_text]) .text(config[__data_empty_label_text])
...@@ -1101,7 +1101,7 @@ ...@@ -1101,7 +1101,7 @@
.style('opacity', targetsToShow.length ? 0 : 1); .style('opacity', targetsToShow.length ? 0 : 1);
// grid // grid
main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); main.select('line.' + CLASS[xgridFocus]).style("visibility", "hidden");
if (config[__grid_x_show]) { if (config[__grid_x_show]) {
xgridAttr = config[__axis_rotated] ? { xgridAttr = config[__axis_rotated] ? {
'x1': 0, 'x1': 0,
...@@ -1118,9 +1118,9 @@ ...@@ -1118,9 +1118,9 @@
flushXGrid = function (withoutUpdate) { flushXGrid = function (withoutUpdate) {
xgridData = $$.generateGridData(config[__grid_x_type], $$.x); xgridData = $$.generateGridData(config[__grid_x_type], $$.x);
tickOffset = $$.isCategorized ? $$.xAxis.tickOffset() : 0; tickOffset = $$.isCategorized ? $$.xAxis.tickOffset() : 0;
xgrid = main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) xgrid = main.select('.' + CLASS[xgrids]).selectAll('.' + CLASS[xgrid])
.data(xgridData); .data(xgridData);
xgrid.enter().append('line').attr("class", CLASS.xgrid); xgrid.enter().append('line').attr("class", CLASS[xgrid]);
if (!withoutUpdate) { if (!withoutUpdate) {
xgrid.attr(xgridAttr) 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; });
...@@ -1129,11 +1129,11 @@ ...@@ -1129,11 +1129,11 @@
}; };
flushXGrid(); flushXGrid();
} }
xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) xgridLines = main.select('.' + CLASS[xgridLines]).selectAll('.' + CLASS[xgridLine])
.data(config[__grid_x_lines]); .data(config[__grid_x_lines]);
// enter // enter
xgridLine = xgridLines.enter().append('g') xgridLine = xgridLines.enter().append('g')
.attr("class", function (d) { return CLASS.xgridLine + (d.class ? ' ' + d.class : ''); }); .attr("class", function (d) { return CLASS[xgridLine] + (d.class ? ' ' + d.class : ''); });
xgridLine.append('line') xgridLine.append('line')
.style("opacity", 0); .style("opacity", 0);
xgridLine.append('text') xgridLine.append('text')
...@@ -1150,10 +1150,10 @@ ...@@ -1150,10 +1150,10 @@
.remove(); .remove();
// Y-Grid // Y-Grid
if (withY && config[__grid_y_show]) { if (withY && config[__grid_y_show]) {
ygrid = main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) 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') ygrid.enter().append('line')
.attr('class', CLASS.ygrid); .attr('class', CLASS[ygrid]);
ygrid.attr("x1", config[__axis_rotated] ? $$.y : 0) ygrid.attr("x1", config[__axis_rotated] ? $$.y : 0)
.attr("x2", config[__axis_rotated] ? $$.y : $$.width) .attr("x2", config[__axis_rotated] ? $$.y : $$.width)
.attr("y1", config[__axis_rotated] ? 0 : $$.y) .attr("y1", config[__axis_rotated] ? 0 : $$.y)
...@@ -1162,11 +1162,11 @@ ...@@ -1162,11 +1162,11 @@
$$.smoothLines(ygrid, 'grid'); $$.smoothLines(ygrid, 'grid');
} }
if (withY) { if (withY) {
ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) ygridLines = main.select('.' + CLASS[ygridLines]).selectAll('.' + CLASS[ygridLine])
.data(config[__grid_y_lines]); .data(config[__grid_y_lines]);
// enter // enter
ygridLine = ygridLines.enter().append('g') ygridLine = ygridLines.enter().append('g')
.attr("class", function (d) { return CLASS.ygridLine + (d.class ? ' ' + d.class : ''); }); .attr("class", function (d) { return CLASS[ygridLine] + (d.class ? ' ' + d.class : ''); });
ygridLine.append('line') ygridLine.append('line')
.style("opacity", 0); .style("opacity", 0);
ygridLine.append('text') ygridLine.append('text')
...@@ -1197,7 +1197,7 @@ ...@@ -1197,7 +1197,7 @@
} }
// rect for regions // rect for regions
mainRegion = main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) mainRegion = main.select('.' + CLASS[regions]).selectAll('.' + CLASS[region])
.data(config[__regions]); .data(config[__regions]);
mainRegion.enter().append('g') mainRegion.enter().append('g')
.attr('class', generateCall($$.classRegion, $$)) .attr('class', generateCall($$.classRegion, $$))
...@@ -1208,7 +1208,7 @@ ...@@ -1208,7 +1208,7 @@
.remove(); .remove();
// bars // bars
mainBar = main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) mainBar = main.selectAll('.' + CLASS[bars]).selectAll('.' + CLASS[bar])
.data(generateCall($$.barData, $$)); .data(generateCall($$.barData, $$));
mainBar.enter().append('path') mainBar.enter().append('path')
.attr("class", generateCall($$.classBar, $$)) .attr("class", generateCall($$.classBar, $$))
...@@ -1221,7 +1221,7 @@ ...@@ -1221,7 +1221,7 @@
.remove(); .remove();
// lines, areas and cricles // lines, areas and cricles
mainLine = main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) mainLine = main.selectAll('.' + CLASS[lines]).selectAll('.' + CLASS[line])
.data(generateCall($$.lineData, $$)); .data(generateCall($$.lineData, $$));
mainLine.enter().append('path') mainLine.enter().append('path')
.attr('class', generateCall($$.classLine, $$)) .attr('class', generateCall($$.classLine, $$))
...@@ -1233,7 +1233,7 @@ ...@@ -1233,7 +1233,7 @@
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
mainArea = main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) mainArea = main.selectAll('.' + CLASS[areas]).selectAll('.' + CLASS[area])
.data(generateCall($$.lineData, $$)); .data(generateCall($$.lineData, $$));
mainArea.enter().append('path') mainArea.enter().append('path')
.attr("class", generateCall($$.classArea, $$)) .attr("class", generateCall($$.classArea, $$))
...@@ -1246,7 +1246,7 @@ ...@@ -1246,7 +1246,7 @@
.remove(); .remove();
if (config[__point_show]) { if (config[__point_show]) {
mainCircle = main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) mainCircle = main.selectAll('.' + CLASS[circles]).selectAll('.' + CLASS[circle])
.data(generateCall($$.lineOrScatterData, $$)); .data(generateCall($$.lineOrScatterData, $$));
mainCircle.enter().append("circle") mainCircle.enter().append("circle")
.attr("class", generateCall($$.classCircle, $$)) .attr("class", generateCall($$.classCircle, $$))
...@@ -1258,7 +1258,7 @@ ...@@ -1258,7 +1258,7 @@
} }
if ($$.hasDataLabel()) { if ($$.hasDataLabel()) {
mainText = main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) mainText = main.selectAll('.' + CLASS[texts]).selectAll('.' + CLASS[text])
.data(generateCall($$.barOrLineData, $$)); .data(generateCall($$.barOrLineData, $$));
mainText.enter().append('text') mainText.enter().append('text')
.attr("class", generateCall($$.classText, $$)) .attr("class", generateCall($$.classText, $$))
...@@ -1285,23 +1285,23 @@ ...@@ -1285,23 +1285,23 @@
} }
// circles for select // circles for select
main.selectAll('.' + CLASS.selectedCircles) main.selectAll('.' + CLASS[selectedCircles])
.filter(generateCall($$.isBarType, $$)) .filter(generateCall($$.isBarType, $$))
.selectAll('circle') .selectAll('circle')
.remove(); .remove();
if (config[__interaction_enabled]) { if (config[__interaction_enabled]) {
// rect for mouseover // rect for mouseover
eventRect = main.select('.' + CLASS.eventRects) eventRect = 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);
if (notEmpty(config[__data_xs]) && !$$.isSingleX(config[__data_xs])) { if (notEmpty(config[__data_xs]) && !$$.isSingleX(config[__data_xs])) {
if (!eventRect.classed(CLASS.eventRectsMultiple)) { if (!eventRect.classed(CLASS[eventRectsMultiple])) {
eventRect.classed(CLASS.eventRectsMultiple, true).classed(CLASS.eventRectsSingle, false) eventRect.classed(CLASS[eventRectsMultiple], true).classed(CLASS[eventRectsSingle], false)
.selectAll('.' + CLASS.eventRect).remove(); .selectAll('.' + CLASS[eventRect]).remove();
} }
eventRectUpdate = main.select('.' + CLASS.eventRects).selectAll('.' + CLASS.eventRect) eventRectUpdate = main.select('.' + CLASS[eventRects]).selectAll('.' + CLASS[eventRect])
.data([0]); .data([0]);
// enter : only one rect will be added // enter : only one rect will be added
$$.generateEventRectsForMultipleXs(eventRectUpdate.enter()); $$.generateEventRectsForMultipleXs(eventRectUpdate.enter());
...@@ -1314,9 +1314,9 @@ ...@@ -1314,9 +1314,9 @@
// exit : not needed because always only one rect exists // exit : not needed because always only one rect exists
} else { } else {
if (!eventRect.classed(CLASS.eventRectsSingle)) { if (!eventRect.classed(CLASS[eventRectsSingle])) {
eventRect.classed(CLASS.eventRectsMultiple, false).classed(CLASS.eventRectsSingle, true) eventRect.classed(CLASS[eventRectsMultiple], false).classed(CLASS[eventRectsSingle], true)
.selectAll('.' + CLASS.eventRect).remove(); .selectAll('.' + CLASS[eventRect]).remove();
} }
if (($$.isCustomX() || $$.isTimeSeries) && !$$.isCategorized) { if (($$.isCustomX() || $$.isTimeSeries) && !$$.isCategorized) {
...@@ -1337,10 +1337,10 @@ ...@@ -1337,10 +1337,10 @@
} }
// Set data // Set data
maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets);
main.select('.' + CLASS.eventRects) main.select('.' + CLASS[eventRects])
.datum(maxDataCountTarget ? maxDataCountTarget.values : []); .datum(maxDataCountTarget ? maxDataCountTarget.values : []);
// Update rects // Update rects
eventRectUpdate = main.select('.' + CLASS.eventRects).selectAll('.' + CLASS.eventRect) eventRectUpdate = main.select('.' + CLASS[eventRects]).selectAll('.' + CLASS[eventRect])
.data(function (d) { return d; }); .data(function (d) { return d; });
// enter // enter
$$.generateEventRectsForSingleX(eventRectUpdate.enter()); $$.generateEventRectsForSingleX(eventRectUpdate.enter());
...@@ -1381,7 +1381,7 @@ ...@@ -1381,7 +1381,7 @@
.style("fill", $$.color) .style("fill", $$.color)
.attr("cx", cx) .attr("cx", cx)
.attr("cy", cy)); .attr("cy", cy));
transitions.push(main.selectAll('.' + CLASS.selectedCircle).transition() transitions.push(main.selectAll('.' + CLASS[selectedCircle]).transition()
.attr("cx", cx) .attr("cx", cx)
.attr("cy", cy)); .attr("cy", cy));
transitions.push(mainText.transition() transitions.push(mainText.transition()
...@@ -1477,14 +1477,14 @@ ...@@ -1477,14 +1477,14 @@
// remove flowed elements // remove flowed elements
if (flowLength) { if (flowLength) {
for (i = 0; i < flowLength; i++) { for (i = 0; i < flowLength; i++) {
shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); shapes.push('.' + CLASS[shape] + '-' + (flowIndex + i));
texts.push('.' + CLASS.text + '-' + (flowIndex + i)); texts.push('.' + CLASS[text] + '-' + (flowIndex + i));
eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); eventRects.push('.' + CLASS[eventRect] + '-' + (flowIndex + i));
} }
$$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); $$.svg.selectAll('.' + CLASS[shapes]).selectAll(shapes).remove();
$$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); $$.svg.selectAll('.' + CLASS[texts]).selectAll(texts).remove();
$$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); $$.svg.selectAll('.' + CLASS[eventRects]).selectAll(eventRects).remove();
$$.svg.select('.' + CLASS.xgrid).remove(); $$.svg.select('.' + CLASS[xgrid]).remove();
} }
// draw again for removing flowed elements and reverting attr // draw again for removing flowed elements and reverting attr
...@@ -1626,7 +1626,7 @@ ...@@ -1626,7 +1626,7 @@
$$.expandBars(index); $$.expandBars(index);
// Call event handler // Call event handler
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.main.selectAll('.' + CLASS[shape] + '-' + index).each(function (d) {
config[__data_onmouseover].call(c3, d); config[__data_onmouseover].call(c3, d);
}); });
}) })
...@@ -1639,13 +1639,13 @@ ...@@ -1639,13 +1639,13 @@
$$.unexpandCircles(index); $$.unexpandCircles(index);
$$.unexpandBars(); $$.unexpandBars();
// Call event handler // Call event handler
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.main.selectAll('.' + CLASS[shape] + '-' + index).each(function (d) {
config[__data_onmouseout].call($$, d); config[__data_onmouseout].call($$, d);
}); });
}) })
.on('mousemove', function (d) { .on('mousemove', function (d) {
var selectedData, index = d.index, var selectedData, index = d.index,
eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); eventRect = $$.svg.select('.' + CLASS[eventRect] + '-' + index);
if ($$.dragging) { return; } // do nothing when dragging if ($$.dragging) { return; } // do nothing when dragging
if ($$.hasArcType($$.data.targets)) { return; } if ($$.hasArcType($$.data.targets)) { return; }
...@@ -1664,9 +1664,9 @@ ...@@ -1664,9 +1664,9 @@
return; return;
} }
$$.main.selectAll('.' + CLASS.shape + '-' + index) $$.main.selectAll('.' + CLASS[shape] + '-' + index)
.each(function () { .each(function () {
d3.select(this).classed(CLASS.EXPANDED, true); d3.select(this).classed(CLASS[EXPANDED], true);
if (config[__data_selection_enabled]) { if (config[__data_selection_enabled]) {
eventRect.style('cursor', config[__data_selection_grouped] ? 'pointer' : null); eventRect.style('cursor', config[__data_selection_grouped] ? 'pointer' : null);
} }
...@@ -1706,7 +1706,7 @@ ...@@ -1706,7 +1706,7 @@
$$.cancelClick = false; $$.cancelClick = false;
return; return;
} }
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.toggleShape(this, d, index); }); $$.main.selectAll('.' + CLASS[shape] + '-' + index).each(function (d) { $$.toggleShape(this, d, index); });
}) })
.call( .call(
d3.behavior.drag().origin(Object) d3.behavior.drag().origin(Object)
...@@ -1724,7 +1724,7 @@ ...@@ -1724,7 +1724,7 @@
.attr('y', 0) .attr('y', 0)
.attr('width', $$.width) .attr('width', $$.width)
.attr('height', $$.height) .attr('height', $$.height)
.attr('class', CLASS.eventRect) .attr('class', CLASS[eventRect])
.on('mouseout', function () { .on('mouseout', function () {
if ($$.hasArcType($$.data.targets)) { return; } if ($$.hasArcType($$.data.targets)) { return; }
$$.hideXGridFocus(); $$.hideXGridFocus();
...@@ -1766,13 +1766,13 @@ ...@@ -1766,13 +1766,13 @@
// Show cursor as pointer if point is close to mouse position // Show cursor as pointer if point is close to mouse position
if ($$.dist(closest, mouse) < 100) { if ($$.dist(closest, mouse) < 100) {
$$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); $$.svg.select('.' + CLASS[eventRect]).style('cursor', 'pointer');
if (!$$.mouseover) { if (!$$.mouseover) {
config[__data_onmouseover].call($$, closest); config[__data_onmouseover].call($$, closest);
$$.mouseover = true; $$.mouseover = true;
} }
} else if ($$.mouseover) { } else if ($$.mouseover) {
$$.svg.select('.' + CLASS.eventRect).style('cursor', null); $$.svg.select('.' + CLASS[eventRect]).style('cursor', null);
config[__data_onmouseout].call($$, closest); config[__data_onmouseout].call($$, closest);
$$.mouseover = false; $$.mouseover = false;
} }
...@@ -1790,7 +1790,7 @@ ...@@ -1790,7 +1790,7 @@
// select if selection enabled // select if selection enabled
if ($$.dist(closest, mouse) < 100) { if ($$.dist(closest, mouse) < 100) {
$$.main.select('.' + CLASS.circles + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS.circle + '-' + closest.index).each(function () { $$.main.select('.' + CLASS[circles] + $$.getTargetSelectorSuffix(closest.id)).select('.' + CLASS[circle] + '-' + closest.index).each(function () {
$$.toggleShape(this, closest, closest.index); $$.toggleShape(this, closest, closest.index);
}); });
} }
...@@ -1845,26 +1845,26 @@ ...@@ -1845,26 +1845,26 @@
if (transitions && transitions.axisX) { if (transitions && transitions.axisX) {
xAxis = transitions.axisX; xAxis = transitions.axisX;
} else { } else {
xAxis = $$.main.select('.' + CLASS.axisX); xAxis = $$.main.select('.' + CLASS[axisX]);
if (withTransition) { xAxis = xAxis.transition(); } if (withTransition) { xAxis = xAxis.transition(); }
} }
if (transitions && transitions.axisY) { if (transitions && transitions.axisY) {
yAxis = transitions.axisY; yAxis = transitions.axisY;
} else { } else {
yAxis = $$.main.select('.' + CLASS.axisY); yAxis = $$.main.select('.' + CLASS[axisY]);
if (withTransition) { yAxis = yAxis.transition(); } if (withTransition) { yAxis = yAxis.transition(); }
} }
if (transitions && transitions.axisY2) { if (transitions && transitions.axisY2) {
y2Axis = transitions.axisY2; y2Axis = transitions.axisY2;
} else { } else {
y2Axis = $$.main.select('.' + CLASS.axisY2); y2Axis = $$.main.select('.' + CLASS[axisY2]);
if (withTransition) { y2Axis = y2Axis.transition(); } if (withTransition) { y2Axis = y2Axis.transition(); }
} }
(withTransition ? $$.main.transition() : $$.main).attr("transform", $$.translate.main); (withTransition ? $$.main.transition() : $$.main).attr("transform", $$.translate.main);
xAxis.attr("transform", $$.translate.x); xAxis.attr("transform", $$.translate.x);
yAxis.attr("transform", $$.translate.y); yAxis.attr("transform", $$.translate.y);
y2Axis.attr("transform", $$.translate.y2); y2Axis.attr("transform", $$.translate.y2);
$$.main.select('.' + CLASS.chartArcs).attr("transform", $$.translate.arc); $$.main.select('.' + CLASS[chartArcs]).attr("transform", $$.translate.arc);
}; };
c3_chart_internal_fn.transformLegend = function (withTransition) { c3_chart_internal_fn.transformLegend = function (withTransition) {
var $$ = this; var $$ = this;
...@@ -1894,7 +1894,7 @@ ...@@ -1894,7 +1894,7 @@
.attr('y', function () { return $$.getYAxisClipY(); }) .attr('y', function () { return $$.getYAxisClipY(); })
.attr('width', function () { return $$.getYAxisClipWidth(); }) .attr('width', function () { return $$.getYAxisClipWidth(); })
.attr('height', function () { return $$.getYAxisClipHeight(); }); .attr('height', function () { return $$.getYAxisClipHeight(); });
$$.svg.select('.' + CLASS.zoomRect) $$.svg.select('.' + CLASS[zoomRect])
.attr('width', $$.width) .attr('width', $$.width)
.attr('height', $$.height); .attr('height', $$.height);
// MEMO: parent div's height will be bigger than svg when <!DOCTYPE html> // MEMO: parent div's height will be bigger than svg when <!DOCTYPE html>
...@@ -2022,7 +2022,7 @@ ...@@ -2022,7 +2022,7 @@
c3_chart_internal_fn.getSvgLeft = function () { c3_chart_internal_fn.getSvgLeft = function () {
var $$ = this, config = $$.config, 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(), leftAxis = $$.main.select('.' + leftAxisClass).node(),
svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0},
chartRect = $$.selectChart.node().getBoundingClientRect(), chartRect = $$.selectChart.node().getBoundingClientRect(),
...@@ -2124,7 +2124,7 @@ ...@@ -2124,7 +2124,7 @@
if (! config[__tooltip_show]) { return; } if (! config[__tooltip_show]) { return; }
// Hide when scatter plot exists // Hide when scatter plot exists
if ($$.hasScatterType($$.data.targets) || $$.hasArcType($$.data.targets)) { return; } if ($$.hasScatterType($$.data.targets) || $$.hasArcType($$.data.targets)) { return; }
var focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus); var focusEl = $$.main.selectAll('line.' + CLASS[xgridFocus]);
focusEl focusEl
.style("visibility", "visible") .style("visibility", "visible")
.data([dataToShow[0]]) .data([dataToShow[0]])
...@@ -2133,11 +2133,11 @@ ...@@ -2133,11 +2133,11 @@
$$.smoothLines(focusEl, 'grid'); $$.smoothLines(focusEl, 'grid');
}; };
c3_chart_internal_fn.hideXGridFocus = function () { c3_chart_internal_fn.hideXGridFocus = function () {
this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); this.main.select('line.' + CLASS[xgridFocus]).style("visibility", "hidden");
}; };
c3_chart_internal_fn.updateXgridFocus = function () { c3_chart_internal_fn.updateXgridFocus = function () {
var $$ = this, config = $$.config; var $$ = this, config = $$.config;
$$.main.select('line.' + CLASS.xgridFocus) $$.main.select('line.' + CLASS[xgridFocus])
.attr("x1", config[__axis_rotated] ? 0 : -10) .attr("x1", config[__axis_rotated] ? 0 : -10)
.attr("x2", config[__axis_rotated] ? $$.width : -10) .attr("x2", config[__axis_rotated] ? $$.width : -10)
.attr("y1", config[__axis_rotated] ? -10 : 0) .attr("y1", config[__axis_rotated] ? -10 : 0)
...@@ -2146,7 +2146,7 @@ ...@@ -2146,7 +2146,7 @@
c3_chart_internal_fn.generateGridData = function (type, scale) { c3_chart_internal_fn.generateGridData = function (type, scale) {
var $$ = this, var $$ = this,
gridData = [], xDomain, firstYear, lastYear, i, gridData = [], xDomain, firstYear, lastYear, i,
tickNum = $$.main.select("." + CLASS.axisX).selectAll('.tick').size(); tickNum = $$.main.select("." + CLASS[axisX]).selectAll('.tick').size();
if (type === 'year') { if (type === 'year') {
xDomain = $$.getXDomain(); xDomain = $$.getXDomain();
firstYear = xDomain[0].getFullYear(); firstYear = xDomain[0].getFullYear();
...@@ -2177,8 +2177,8 @@ ...@@ -2177,8 +2177,8 @@
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
toRemove = $$.getGridFilterToRemove(params), toRemove = $$.getGridFilterToRemove(params),
toShow = function (line) { return !toRemove(line); }, toShow = function (line) { return !toRemove(line); },
classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, classLines = forX ? CLASS[xgridLines] : CLASS[ygridLines],
classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; classLine = forX ? CLASS[xgridLine] : CLASS.ygridLine;
$$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove)
.transition().duration(config[__transition_duration]) .transition().duration(config[__transition_duration])
.style('opacity', 0).remove(); .style('opacity', 0).remove();
...@@ -2221,15 +2221,15 @@ ...@@ -2221,15 +2221,15 @@
}; };
c3_chart_internal_fn.opacityForLegend = function (legendItem) { c3_chart_internal_fn.opacityForLegend = function (legendItem) {
var $$ = this; var $$ = this;
return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 1; return legendItem.classed(CLASS[legendItemHidden]) ? $$.legendOpacityForHidden : 1;
}; };
c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) {
var $$ = this; var $$ = this;
return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 0.3; return legendItem.classed(CLASS[legendItemHidden]) ? $$.legendOpacityForHidden : 0.3;
}; };
c3_chart_internal_fn.toggleFocusLegend = function (id, focus) { c3_chart_internal_fn.toggleFocusLegend = function (id, focus) {
var $$ = this; var $$ = this;
$$.legend.selectAll('.' + CLASS.legendItem) $$.legend.selectAll('.' + CLASS[legendItem])
.transition().duration(100) .transition().duration(100)
.style('opacity', function (_id) { .style('opacity', function (_id) {
var This = $$.d3.select(this); var This = $$.d3.select(this);
...@@ -2242,7 +2242,7 @@ ...@@ -2242,7 +2242,7 @@
}; };
c3_chart_internal_fn.revertLegend = function () { c3_chart_internal_fn.revertLegend = function () {
var $$ = this, d3 = $$.d3; var $$ = this, d3 = $$.d3;
$$.legend.selectAll('.' + CLASS.legendItem) $$.legend.selectAll('.' + CLASS[legendItem])
.transition().duration(100) .transition().duration(100)
.style('opacity', function () { return $$.opacityForLegend(d3.select(this)); }); .style('opacity', function () { return $$.opacityForLegend(d3.select(this)); });
}; };
...@@ -2275,7 +2275,7 @@ ...@@ -2275,7 +2275,7 @@
var paddingTop = 4, paddingRight = 36, maxWidth = 0, maxHeight = 0, posMin = 10; var paddingTop = 4, paddingRight = 36, maxWidth = 0, maxHeight = 0, posMin = 10;
var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0;
var withTransition, withTransitionForTransform; var withTransition, withTransitionForTransform;
var hasFocused = $$.legend.selectAll('.' + CLASS.legendItemFocused).size(); var hasFocused = $$.legend.selectAll('.' + CLASS[legendItemFocused]).size();
var texts, rects, tiles; var texts, rects, tiles;
options = options || {}; options = options || {};
...@@ -2283,7 +2283,7 @@ ...@@ -2283,7 +2283,7 @@
withTransitionForTransform = getOption(options, "withTransitionForTransform", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true);
function updatePositions(textElement, id, reset) { function updatePositions(textElement, id, reset) {
var box = $$.getTextRect(textElement.textContent, CLASS.legendItem), var box = $$.getTextRect(textElement.textContent, CLASS[legendItem]),
itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10, itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10,
itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10, itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10,
itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth,
...@@ -2358,17 +2358,17 @@ ...@@ -2358,17 +2358,17 @@
yForLegendRect = function (id, i) { return yForLegend(id, i) - 7; }; yForLegendRect = function (id, i) { return yForLegend(id, i) - 7; };
// Define g for legend area // Define g for legend area
l = $$.legend.selectAll('.' + CLASS.legendItem) l = $$.legend.selectAll('.' + CLASS[legendItem])
.data(targetIds) .data(targetIds)
.enter().append('g') .enter().append('g')
.attr('class', function (id) { return $$.generateClass(CLASS.legendItem, id); }) .attr('class', function (id) { return $$.generateClass(CLASS[legendItem], id); })
.style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; })
.style('cursor', 'pointer') .style('cursor', 'pointer')
.on('click', function (id) { .on('click', function (id) {
isFunction(config[__legend_item_onclick]) ? config[__legend_item_onclick].call(c3, id) : $$.api.toggle(id); isFunction(config[__legend_item_onclick]) ? config[__legend_item_onclick].call(c3, id) : $$.api.toggle(id);
}) })
.on('mouseover', function (id) { .on('mouseover', function (id) {
$$.d3.select(this).classed(CLASS.legendItemFocused, true); $$.d3.select(this).classed(CLASS[legendItemFocused], true);
if (!$$.transiting) { if (!$$.transiting) {
$$.api.focus(id); $$.api.focus(id);
} }
...@@ -2377,7 +2377,7 @@ ...@@ -2377,7 +2377,7 @@
} }
}) })
.on('mouseout', function (id) { .on('mouseout', function (id) {
$$.d3.select(this).classed(CLASS.legendItemFocused, false); $$.d3.select(this).classed(CLASS[legendItemFocused], false);
if (!$$.transiting) { if (!$$.transiting) {
$$.api.revert(); $$.api.revert();
} }
...@@ -2392,12 +2392,12 @@ ...@@ -2392,12 +2392,12 @@
.attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200)
.attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText);
l.append('rect') l.append('rect')
.attr("class", CLASS.legendItemEvent) .attr("class", CLASS[legendItemEvent])
.style('fill-opacity', 0) .style('fill-opacity', 0)
.attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200)
.attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect);
l.append('rect') l.append('rect')
.attr("class", CLASS.legendItemTile) .attr("class", CLASS[legendItemTile])
.style("pointer-events", "none") .style("pointer-events", "none")
.style('fill', $$.color) .style('fill', $$.color)
.attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200)
...@@ -2406,8 +2406,8 @@ ...@@ -2406,8 +2406,8 @@
.attr('height', 10); .attr('height', 10);
// Set background for inset legend // Set background for inset legend
if ($$.isLegendInset && maxWidth !== 0) { if ($$.isLegendInset && maxWidth !== 0) {
$$.legend.insert('g', '.' + CLASS.legendItem) $$.legend.insert('g', '.' + CLASS[legendItem])
.attr("class", CLASS.legendBackground) .attr("class", CLASS[legendBackground])
.append('rect') .append('rect')
.attr('height', $$.getLegendHeight() - 10) .attr('height', $$.getLegendHeight() - 10)
.attr('width', maxWidth * (step + 1) + 10); .attr('width', maxWidth * (step + 1) + 10);
...@@ -2421,7 +2421,7 @@ ...@@ -2421,7 +2421,7 @@
.attr('x', xForLegendText) .attr('x', xForLegendText)
.attr('y', yForLegendText); .attr('y', yForLegendText);
rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent) rects = $$.legend.selectAll('rect.' + CLASS[legendItemEvent])
.data(targetIds); .data(targetIds);
(withTransition ? rects.transition() : rects) (withTransition ? rects.transition() : rects)
.attr('width', function (id) { return widths[id]; }) .attr('width', function (id) { return widths[id]; })
...@@ -2429,7 +2429,7 @@ ...@@ -2429,7 +2429,7 @@
.attr('x', xForLegendRect) .attr('x', xForLegendRect)
.attr('y', yForLegendRect); .attr('y', yForLegendRect);
tiles = $$.legend.selectAll('rect.' + CLASS.legendItemTile) tiles = $$.legend.selectAll('rect.' + CLASS[legendItemTile])
.data(targetIds); .data(targetIds);
(withTransition ? tiles.transition() : tiles) (withTransition ? tiles.transition() : tiles)
.style('fill', $$.color) .style('fill', $$.color)
...@@ -2437,13 +2437,13 @@ ...@@ -2437,13 +2437,13 @@
.attr('y', yForLegend); .attr('y', yForLegend);
// toggle legend state // toggle legend state
$$.legend.selectAll('.' + CLASS.legendItem) $$.legend.selectAll('.' + CLASS[legendItem])
.classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }) .classed(CLASS[legendItemHidden], function (id) { return !$$.isTargetToShow(id); })
.transition() .transition()
.style('opacity', function (id) { .style('opacity', function (id) {
var This = $$.d3.select(this); var This = $$.d3.select(this);
if ($$.isTargetToShow(id)) { if ($$.isTargetToShow(id)) {
return !hasFocused || This.classed(CLASS.legendItemFocused) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This); return !hasFocused || This.classed(CLASS[legendItemFocused]) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This);
} else { } else {
return $$.legendOpacityForHidden; return $$.legendOpacityForHidden;
} }
...@@ -3041,7 +3041,7 @@ ...@@ -3041,7 +3041,7 @@
// Reset fadein for future load // Reset fadein for future load
$$.withoutFadeIn[id] = false; $$.withoutFadeIn[id] = false;
// Remove target's elements // Remove target's elements
$$.legend.selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)).remove(); $$.legend.selectAll('.' + CLASS[legendItem] + $$.getTargetSelectorSuffix(id)).remove();
// Remove target // Remove target
$$.data.targets = $$.data.targets.filter(function (t) { $$.data.targets = $$.data.targets.filter(function (t) {
return t.id !== id; return t.id !== id;
...@@ -3127,19 +3127,19 @@ ...@@ -3127,19 +3127,19 @@
}; };
c3_chart_internal_fn.getCircles = function (i, id) { c3_chart_internal_fn.getCircles = function (i, id) {
var $$ = this; var $$ = this;
return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); return (id ? $$.main.selectAll('.' + CLASS[circles] + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS[circle] + (isValue(i) ? '-' + i : ''));
}; };
c3_chart_internal_fn.expandCircles = function (i, id) { c3_chart_internal_fn.expandCircles = function (i, id) {
var $$ = this; var $$ = this;
$$.getCircles(i, id) $$.getCircles(i, id)
.classed(CLASS.EXPANDED, true) .classed(CLASS[EXPANDED], true)
.attr('r', generateCall($$.pointExpandedR, $$)); .attr('r', generateCall($$.pointExpandedR, $$));
}; };
c3_chart_internal_fn.unexpandCircles = function (i) { c3_chart_internal_fn.unexpandCircles = function (i) {
var $$ = this; var $$ = this;
$$.getCircles(i) $$.getCircles(i)
.filter(function () { return $$.d3.select(this).classed(CLASS.EXPANDED); }) .filter(function () { return $$.d3.select(this).classed(CLASS[EXPANDED]); })
.classed(CLASS.EXPANDED, false) .classed(CLASS[EXPANDED], false)
.attr('r', generateCall($$.pointR, $$)); .attr('r', generateCall($$.pointR, $$));
}; };
c3_chart_internal_fn.pointR = function (d) { c3_chart_internal_fn.pointR = function (d) {
...@@ -3164,15 +3164,15 @@ ...@@ -3164,15 +3164,15 @@
}; };
c3_chart_internal_fn.getBars = function (i) { c3_chart_internal_fn.getBars = function (i) {
var $$ = this; var $$ = this;
return $$.main.selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); return $$.main.selectAll('.' + CLASS[bar] + (isValue(i) ? '-' + i : ''));
}; };
c3_chart_internal_fn.expandBars = function (i) { c3_chart_internal_fn.expandBars = function (i) {
var $$ = this; var $$ = this;
$$.getBars(i).classed(CLASS.EXPANDED, true); $$.getBars(i).classed(CLASS[EXPANDED], true);
}; };
c3_chart_internal_fn.unexpandBars = function (i) { c3_chart_internal_fn.unexpandBars = function (i) {
var $$ = this; var $$ = this;
$$.getBars(i).classed(CLASS.EXPANDED, false); $$.getBars(i).classed(CLASS[EXPANDED], false);
}; };
c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) { c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) {
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
...@@ -4221,9 +4221,9 @@ ...@@ -4221,9 +4221,9 @@
c3_chart_internal_fn.updateAxisLabels = function (withTransition) { c3_chart_internal_fn.updateAxisLabels = function (withTransition) {
var $$ = this; var $$ = this;
var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), var axisXLabel = $$.main.select('.' + CLASS[axisX] + ' .' + CLASS[axisXLabel]),
axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), axisYLabel = $$.main.select('.' + CLASS[axisY] + ' .' + CLASS[axisYLabel]),
axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); axisY2Label = $$.main.select('.' + CLASS[axisY2] + ' .' + CLASS[axisY2Label]);
(withTransition ? axisXLabel.transition() : axisXLabel) (withTransition ? axisXLabel.transition() : axisXLabel)
.attr("x", generateCall($$.xForXAxisLabel, $$)) .attr("x", generateCall($$.xForXAxisLabel, $$))
.attr("dx", generateCall($$.dxForXAxisLabel, $$)) .attr("dx", generateCall($$.dxForXAxisLabel, $$))
...@@ -4449,8 +4449,8 @@ ...@@ -4449,8 +4449,8 @@
c3_chart_internal_fn.expandArc = function (id, withoutFadeOut) { c3_chart_internal_fn.expandArc = function (id, withoutFadeOut) {
var $$ = this, var $$ = this,
target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)), target = $$.svg.selectAll('.' + CLASS[chartArc] + $$.selectorTarget(id)),
noneTargets = $$.svg.selectAll('.' + CLASS.arc).filter(function (data) { return data.data.id !== id; }); noneTargets = $$.svg.selectAll('.' + CLASS[arc]).filter(function (data) { return data.data.id !== id; });
if ($$.shouldExpand(id)) { if ($$.shouldExpand(id)) {
target.selectAll('path') target.selectAll('path')
...@@ -4471,11 +4471,11 @@ ...@@ -4471,11 +4471,11 @@
c3_chart_internal_fn.unexpandArc = function (id) { c3_chart_internal_fn.unexpandArc = function (id) {
var $$ = this, var $$ = this,
target = $$.svg.selectAll('.' + CLASS.chartArc + $$.selectorTarget(id)); target = $$.svg.selectAll('.' + CLASS[chartArc] + $$.selectorTarget(id));
target.selectAll('path.' + CLASS.arc) target.selectAll('path.' + CLASS[arc])
.transition().duration(50) .transition().duration(50)
.attr("d", $$.svgArc); .attr("d", $$.svgArc);
$$.svg.selectAll('.' + CLASS.arc) $$.svg.selectAll('.' + CLASS[arc])
.style("opacity", 1); .style("opacity", 1);
}; };
...@@ -4523,7 +4523,7 @@ ...@@ -4523,7 +4523,7 @@
c3_chart_internal_fn.updateTargetsForArc = function (targets) { c3_chart_internal_fn.updateTargetsForArc = function (targets) {
var $$ = this, main = $$.main, mainPieUpdate, mainPieEnter; var $$ = this, main = $$.main, mainPieUpdate, mainPieEnter;
mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) mainPieUpdate = main.select('.' + CLASS[chartArcs]).selectAll('.' + CLASS[chartArc])
.data($$.pie(targets)) .data($$.pie(targets))
.attr("class", generateCall($$.classChartArc, $$)); .attr("class", generateCall($$.classChartArc, $$));
mainPieEnter = mainPieUpdate.enter().append("g") mainPieEnter = mainPieUpdate.enter().append("g")
...@@ -4541,11 +4541,11 @@ ...@@ -4541,11 +4541,11 @@
c3_chart_internal_fn.initArc = function () { c3_chart_internal_fn.initArc = function () {
var $$ = this, arcs; var $$ = this, arcs;
arcs = $$.main.select('.' + CLASS.chart).append("g") arcs = $$.main.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartArcs) .attr("class", CLASS[chartArcs])
.attr("transform", $$.translate.arc); .attr("transform", $$.translate.arc);
arcs.append('text') arcs.append('text')
.attr('class', CLASS.chartArcsTitle) .attr('class', CLASS[chartArcsTitle])
.style("text-anchor", "middle") .style("text-anchor", "middle")
.text($$.getArcTitle()); .text($$.getArcTitle());
}; };
...@@ -4553,7 +4553,7 @@ ...@@ -4553,7 +4553,7 @@
c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) {
var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main,
mainArc; mainArc;
mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) mainArc = main.selectAll('.' + CLASS[arcs]).selectAll('.' + CLASS[arc])
.data(generateCall($$.arcData, $$)); .data(generateCall($$.arcData, $$));
mainArc.enter().append('path') mainArc.enter().append('path')
.attr("class", generateCall($$.classArc, $$)) .attr("class", generateCall($$.classArc, $$))
...@@ -4636,14 +4636,14 @@ ...@@ -4636,14 +4636,14 @@
mainArc.exit().transition().duration(durationForExit) mainArc.exit().transition().duration(durationForExit)
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
main.selectAll('.' + CLASS.chartArc).select('text') main.selectAll('.' + CLASS[chartArc]).select('text')
.style("opacity", 0) .style("opacity", 0)
.attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; }) .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS[gaugeValue] : ''; })
.text(generateCall($$.textForArcLabel, $$)) .text(generateCall($$.textForArcLabel, $$))
.attr("transform", generateCall($$.transformForArcLabel, $$)) .attr("transform", generateCall($$.transformForArcLabel, $$))
.transition().duration(duration) .transition().duration(duration)
.style("opacity", function (d) { return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; }); .style("opacity", function (d) { return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; });
main.select('.' + CLASS.chartArcsTitle) main.select('.' + CLASS[chartArcsTitle])
.style("opacity", $$.hasDonutType($$.data.targets) || $$.hasGaugeType($$.data.targets) ? 1 : 0); .style("opacity", $$.hasDonutType($$.data.targets) || $$.hasGaugeType($$.data.targets) ? 1 : 0);
}; };
...@@ -4654,7 +4654,7 @@ ...@@ -4654,7 +4654,7 @@
var $$ = this, config = $$.config, arcs; var $$ = this, config = $$.config, arcs;
if ($$.hasGaugeType($$.data.targets)) { if ($$.hasGaugeType($$.data.targets)) {
arcs.append('path') arcs.append('path')
.attr("class", CLASS.chartArcsBackground) .attr("class", CLASS[chartArcsBackground])
.attr("d", function () { .attr("d", function () {
var d = { var d = {
data: [{value: config[__gauge_max]}], data: [{value: config[__gauge_max]}],
...@@ -4665,21 +4665,21 @@ ...@@ -4665,21 +4665,21 @@
}); });
arcs.append("text") arcs.append("text")
.attr("dy", ".75em") .attr("dy", ".75em")
.attr("class", CLASS.chartArcsGaugeUnit) .attr("class", CLASS[chartArcsGaugeUnit])
.style("text-anchor", "middle") .style("text-anchor", "middle")
.style("pointer-events", "none") .style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_units] : ''); .text(config[__gauge_label_show] ? config[__gauge_units] : '');
arcs.append("text") arcs.append("text")
.attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px") .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / 2)) + "px")
.attr("dy", "1.2em") .attr("dy", "1.2em")
.attr("class", CLASS.chartArcsGaugeMin) .attr("class", CLASS[chartArcsGaugeMin])
.style("text-anchor", "middle") .style("text-anchor", "middle")
.style("pointer-events", "none") .style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_min] : ''); .text(config[__gauge_label_show] ? config[__gauge_min] : '');
arcs.append("text") arcs.append("text")
.attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px")
.attr("dy", "1.2em") .attr("dy", "1.2em")
.attr("class", CLASS.chartArcsGaugeMax) .attr("class", CLASS[chartArcsGaugeMax])
.style("text-anchor", "middle") .style("text-anchor", "middle")
.style("pointer-events", "none") .style("pointer-events", "none")
.text(config[__gauge_label_show] ? config[__gauge_max] : ''); .text(config[__gauge_label_show] ? config[__gauge_max] : '');
...@@ -4713,7 +4713,7 @@ ...@@ -4713,7 +4713,7 @@
var $$ = this, d3 = $$.d3; var $$ = this, d3 = $$.d3;
$$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); });
$$.brush.update = function () { $$.brush.update = function () {
if ($$.context) { $$.context.select('.' + $$.CLASS.brush).call(this); } if ($$.context) { $$.context.select('.' + $$.CLASS[brush]).call(this); }
return this; return this;
}; };
$$.brush.scale = function (scale) { $$.brush.scale = function (scale) {
...@@ -4731,20 +4731,20 @@ ...@@ -4731,20 +4731,20 @@
// Define g for chart area // Define g for chart area
context.append('g') context.append('g')
.attr("clip-path", $$.clipPath) .attr("clip-path", $$.clipPath)
.attr('class', CLASS.chart); .attr('class', CLASS[chart]);
// Define g for bar chart area // Define g for bar chart area
context.select('.' + CLASS.chart).append("g") context.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartBars); .attr("class", CLASS[chartBars]);
// Define g for line chart area // Define g for line chart area
context.select('.' + CLASS.chart).append("g") context.select('.' + CLASS[chart]).append("g")
.attr("class", CLASS.chartLines); .attr("class", CLASS[chartLines]);
// Add extent rect for Brush // Add extent rect for Brush
context.append("g") context.append("g")
.attr("clip-path", $$.clipPath) .attr("clip-path", $$.clipPath)
.attr("class", CLASS.brush) .attr("class", CLASS[brush])
.call($$.brush) .call($$.brush)
.selectAll("rect") .selectAll("rect")
.attr(config[__axis_rotated] ? "width" : "height", config[__axis_rotated] ? $$.width2 : $$.height2); .attr(config[__axis_rotated] ? "width" : "height", config[__axis_rotated] ? $$.width2 : $$.height2);
...@@ -4752,7 +4752,7 @@ ...@@ -4752,7 +4752,7 @@
// ATTENTION: This must be called AFTER chart added // ATTENTION: This must be called AFTER chart added
// Add Axis // Add Axis
$$.axes.subx = context.append("g") $$.axes.subx = context.append("g")
.attr("class", CLASS.axisX) .attr("class", CLASS[axisX])
.attr("transform", $$.translate.subx) .attr("transform", $$.translate.subx)
.attr("clip-path", config[__axis_rotated] ? "" : $$.clipPathForXAxis); .attr("clip-path", config[__axis_rotated] ? "" : $$.clipPathForXAxis);
}; };
...@@ -4762,7 +4762,7 @@ ...@@ -4762,7 +4762,7 @@
if (config[__subchart_show]) { if (config[__subchart_show]) {
contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) contextBarUpdate = context.select('.' + CLASS[chartBars]).selectAll('.' + CLASS[chartBar])
.data(targets) .data(targets)
.attr('class', generateCall($$.classChartBar, $$)); .attr('class', generateCall($$.classChartBar, $$));
contextBarEnter = contextBarUpdate.enter().append('g') contextBarEnter = contextBarUpdate.enter().append('g')
...@@ -4773,7 +4773,7 @@ ...@@ -4773,7 +4773,7 @@
.attr("class", generateCall($$.classBars, $$)); .attr("class", generateCall($$.classBars, $$));
//-- Line --// //-- Line --//
contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) contextLineUpdate = context.select('.' + CLASS[chartLines]).selectAll('.' + CLASS[chartLine])
.data(targets) .data(targets)
.attr('class', generateCall($$.classChartLine, $$)); .attr('class', generateCall($$.classChartLine, $$));
contextLineEnter = contextLineUpdate.enter().append('g') contextLineEnter = contextLineUpdate.enter().append('g')
...@@ -4814,7 +4814,7 @@ ...@@ -4814,7 +4814,7 @@
drawBarOnSub = $$.generateDrawBar(barIndices, true); drawBarOnSub = $$.generateDrawBar(barIndices, true);
drawLineOnSub = $$.generateDrawLine(lineIndices, true); drawLineOnSub = $$.generateDrawLine(lineIndices, true);
// bars // bars
contextBar = context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) contextBar = context.selectAll('.' + CLASS[bars]).selectAll('.' + CLASS[bar])
.data(generateCall($$.barData, $$)); .data(generateCall($$.barData, $$));
contextBar.enter().append('path') contextBar.enter().append('path')
.attr("class", generateCall($$.classBar, $$)) .attr("class", generateCall($$.classBar, $$))
...@@ -4829,7 +4829,7 @@ ...@@ -4829,7 +4829,7 @@
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
// lines // lines
contextLine = context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) contextLine = context.selectAll('.' + CLASS[lines]).selectAll('.' + CLASS[line])
.data(generateCall($$.lineData, $$)); .data(generateCall($$.lineData, $$));
contextLine.enter().append('path') contextLine.enter().append('path')
.attr('class', generateCall($$.classLine, $$)) .attr('class', generateCall($$.classLine, $$))
...@@ -4843,7 +4843,7 @@ ...@@ -4843,7 +4843,7 @@
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
// area // area
contextArea = context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) contextArea = context.selectAll('.' + CLASS[areas]).selectAll('.' + CLASS[area])
.data(generateCall($$.lineData, $$)); .data(generateCall($$.lineData, $$));
contextArea.enter().append('path') contextArea.enter().append('path')
.attr("class", generateCall($$.classArea, $$)) .attr("class", generateCall($$.classArea, $$))
...@@ -4876,7 +4876,7 @@ ...@@ -4876,7 +4876,7 @@
if (transitions && transitions.axisSubX) { if (transitions && transitions.axisSubX) {
subXAxis = transitions.axisSubX; subXAxis = transitions.axisSubX;
} else { } else {
subXAxis = $$.context.select('.' + CLASS.axisX); subXAxis = $$.context.select('.' + CLASS[axisX]);
if (withTransition) { subXAxis = subXAxis.transition(); } if (withTransition) { subXAxis = subXAxis.transition(); }
} }
$$.context.attr("transform", $$.translate.context); $$.context.attr("transform", $$.translate.context);
...@@ -4889,8 +4889,8 @@ ...@@ -4889,8 +4889,8 @@
*/ */
c3_chart_internal_fn.updateZoom = 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.select('.' + $$.CLASS[zoomRect]).call(z);
$$.main.selectAll('.' + $$.CLASS.eventRect).call(z); $$.main.selectAll('.' + $$.CLASS[eventRect]).call(z);
}; };
...@@ -4969,10 +4969,10 @@ ...@@ -4969,10 +4969,10 @@
var $$ = this, config = $$.config; var $$ = this, config = $$.config;
config[__data_onselected](d, target.node()); config[__data_onselected](d, target.node());
// add selected-circle on low layer g // add selected-circle on low layer g
$$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) $$.main.select('.' + CLASS[selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[selectedCircle] + '-' + i)
.data([d]) .data([d])
.enter().append('circle') .enter().append('circle')
.attr("class", function () { return $$.generateClass(CLASS.selectedCircle, i); }) .attr("class", function () { return $$.generateClass(CLASS[selectedCircle], i); })
.attr("cx", config[__axis_rotated] ? $$.circleY : $$.circleX) .attr("cx", config[__axis_rotated] ? $$.circleY : $$.circleX)
.attr("cy", config[__axis_rotated] ? $$.circleX : $$.circleY) .attr("cy", config[__axis_rotated] ? $$.circleX : $$.circleY)
.attr("stroke", function () { return $$.color(d); }) .attr("stroke", function () { return $$.color(d); })
...@@ -4984,7 +4984,7 @@ ...@@ -4984,7 +4984,7 @@
var $$ = this; var $$ = this;
$$.config[__data_onunselected](d, target.node()); $$.config[__data_onunselected](d, target.node());
// remove selected-circle from low layer g // remove selected-circle from low layer g
$$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) $$.main.select('.' + CLASS[selectedCircles] + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS[selectedCircle] + '-' + i)
.transition().duration(100).attr('r', 0) .transition().duration(100).attr('r', 0)
.remove(); .remove();
}; };
...@@ -5012,17 +5012,17 @@ ...@@ -5012,17 +5012,17 @@
c3_chart_internal_fn.getToggle = function (that) { c3_chart_internal_fn.getToggle = function (that) {
var $$ = this; var $$ = this;
// path selection not supported yet // path selection not supported yet
return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS.bar) ? $$.toggleBar : $$.toggleArc); return that.nodeName === 'circle' ? $$.togglePoint : ($$.d3.select(that).classed(CLASS[bar]) ? $$.toggleBar : $$.toggleArc);
}; };
c3_chart_internal_fn.toggleShape = function (that, d, i) { c3_chart_internal_fn.toggleShape = function (that, d, i) {
var $$ = this, d3 = $$.d3, config = $$.config, var $$ = this, d3 = $$.d3, config = $$.config,
shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), isWithin, toggle; shape = d3.select(that), isSelected = shape.classed(CLASS[SELECTED]), isWithin, toggle;
if (that.nodeName === 'circle') { if (that.nodeName === 'circle') {
isWithin = $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); isWithin = $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5);
toggle = $$.togglePoint; toggle = $$.togglePoint;
} }
else if (that.nodeName === 'path') { else if (that.nodeName === 'path') {
if (shape.classed(CLASS.bar)) { if (shape.classed(CLASS[bar])) {
isWithin = $$.isWithinBar(that); isWithin = $$.isWithinBar(that);
toggle = $$.toggleBar; toggle = $$.toggleBar;
} else { // would be arc } else { // would be arc
...@@ -5033,12 +5033,12 @@ ...@@ -5033,12 +5033,12 @@
if (config[__data_selection_grouped] || isWithin) { if (config[__data_selection_grouped] || isWithin) {
if (config[__data_selection_enabled] && config[__data_selection_isselectable](d)) { if (config[__data_selection_enabled] && config[__data_selection_isselectable](d)) {
if (!config[__data_selection_multiple]) { if (!config[__data_selection_multiple]) {
$$.main.selectAll('.' + CLASS.shapes + (config[__data_selection_grouped] ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS.shape).each(function (d, i) { $$.main.selectAll('.' + CLASS[shapes] + (config[__data_selection_grouped] ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS[shape]).each(function (d, i) {
var shape = d3.select(this); var shape = d3.select(this);
if (shape.classed(CLASS.SELECTED)) { toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } if (shape.classed(CLASS[SELECTED])) { toggle(false, shape.classed(CLASS[SELECTED], false), d, i); }
}); });
} }
shape.classed(CLASS.SELECTED, !isSelected); shape.classed(CLASS[SELECTED], !isSelected);
toggle(!isSelected, shape, d, i); toggle(!isSelected, shape, d, i);
} }
$$.config[__data_onclick](d, that); $$.config[__data_onclick](d, that);
...@@ -5112,162 +5112,234 @@ ...@@ -5112,162 +5112,234 @@
/** /**
* c3.class.js * c3.class.js
*/ */
var CLASS = c3_chart_internal_fn.CLASS = { var target = 'target',
target: 'c3-target', chart = 'chart ',
chart : 'c3-chart', chartLine = 'chartLine',
chartLine: 'c3-chart-line', chartLines = 'chartLines',
chartLines: 'c3-chart-lines', chartBar = 'chartBar',
chartBar: 'c3-chart-bar', chartBars = 'chartBars',
chartBars: 'c3-chart-bars', chartText = 'chartText',
chartText: 'c3-chart-text', chartTexts = 'chartTexts',
chartTexts: 'c3-chart-texts', chartArc = 'chartArc',
chartArc: 'c3-chart-arc', chartArcs = 'chartArcs',
chartArcs: 'c3-chart-arcs', chartArcsTitle = 'chartArcsTitle',
chartArcsTitle: 'c3-chart-arcs-title', chartArcsBackground = 'chartArcsBackground',
chartArcsBackground: 'c3-chart-arcs-background', chartArcsGaugeUnit = 'chartArcsGaugeUnit',
chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', chartArcsGaugeMax = 'chartArcsGaugeMax',
chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', chartArcsGaugeMin = 'chartArcsGaugeMin',
chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', selectedCircle = 'selectedCircle',
selectedCircle: 'c3-selected-circle', selectedCircles = 'selectedCircles',
selectedCircles: 'c3-selected-circles', eventRect = 'eventRect',
eventRect: 'c3-event-rect', eventRects = 'eventRects',
eventRects: 'c3-event-rects', eventRectsSingle = 'eventRectsSingle',
eventRectsSingle: 'c3-event-rects-single', eventRectsMultiple = 'eventRectsMultiple',
eventRectsMultiple: 'c3-event-rects-multiple', zoomRect = 'zoomRect',
zoomRect: 'c3-zoom-rect', brush = 'brush',
brush: 'c3-brush', focused = 'focused',
focused: 'c3-focused', region = 'region',
region: 'c3-region', regions = 'regions',
regions: 'c3-regions', tooltip = 'tooltip',
tooltip: 'c3-tooltip', tooltipName = 'tooltipName',
tooltipName: 'c3-tooltip-name', shape = 'shape',
shape: 'c3-shape', shapes = 'shapes',
shapes: 'c3-shapes', line = 'line',
line: 'c3-line', lines = 'lines',
lines: 'c3-lines', bar = 'bar',
bar: 'c3-bar', bars = 'bars',
bars: 'c3-bars', circle = 'circle',
circle: 'c3-circle', circles = 'circles',
circles: 'c3-circles', arc = 'arc',
arc: 'c3-arc', arcs = 'arcs',
arcs: 'c3-arcs', area = 'area',
area: 'c3-area', areas = 'areas',
areas: 'c3-areas', empty = 'empty',
empty: 'c3-empty', text = 'text',
text: 'c3-text', texts = 'texts',
texts: 'c3-texts', gaugeValue = 'gaugeValue',
gaugeValue: 'c3-gauge-value', grid = 'grid',
grid: 'c3-grid', xgrid = 'xgrid',
xgrid: 'c3-xgrid', xgrids = 'xgrids',
xgrids: 'c3-xgrids', xgridLine = 'xgridLine',
xgridLine: 'c3-xgrid-line', xgridLines = 'xgridLines',
xgridLines: 'c3-xgrid-lines', xgridFocus = 'xgridFocus',
xgridFocus: 'c3-xgrid-focus', ygrid = 'ygrid',
ygrid: 'c3-ygrid', ygrids = 'ygrids',
ygrids: 'c3-ygrids', ygridLine = 'ygridLine',
ygridLine: 'c3-ygrid-line', ygridLines = 'ygridLines',
ygridLines: 'c3-ygrid-lines', axis = 'axis',
axis: 'c3-axis', axisX = 'axisX',
axisX: 'c3-axis-x', axisXLabel = 'axisXLabel',
axisXLabel: 'c3-axis-x-label', axisY = 'axisY',
axisY: 'c3-axis-y', axisYLabel = 'axisYLabel',
axisYLabel: 'c3-axis-y-label', axisY2 = 'axisY2',
axisY2: 'c3-axis-y2', axisY2Label = 'axisY2Label',
axisY2Label: 'c3-axis-y2-label', legendBackground = 'legendBackground',
legendBackground: 'c3-legend-background', legendItem = 'legendItem',
legendItem: 'c3-legend-item', legendItemEvent = 'legendItemEvent',
legendItemEvent: 'c3-legend-item-event', legendItemTile = 'legendItemTile',
legendItemTile: 'c3-legend-item-tile', legendItemHidden = 'legendItemHidden',
legendItemHidden: 'c3-legend-item-hidden', legendItemFocused = 'legendItemFocused',
legendItemFocused: 'c3-legend-item-focused', dragarea = 'dragarea',
dragarea: 'c3-dragarea', EXPANDED = 'EXPANDED',
EXPANDED: '_expanded_', SELECTED = 'SELECTED',
SELECTED: '_selected_', INCLUDED = 'INCLUDED';
INCLUDED: '_included_'
}; var CLASS = c3_chart_internal_fn.CLASS = {};
CLASS[target] = 'c3-target';
CLASS[chart] = 'c3-chart';
CLASS[chartLine] = 'c3-chart-line';
CLASS[chartLines] = 'c3-chart-lines';
CLASS[chartBar] = 'c3-chart-bar';
CLASS[chartBars] = 'c3-chart-bars';
CLASS[chartText] = 'c3-chart-text';
CLASS[chartTexts] = 'c3-chart-texts';
CLASS[chartArc] = 'c3-chart-arc';
CLASS[chartArcs] = 'c3-chart-arcs';
CLASS[chartArcsTitle] = 'c3-chart-arcs-title';
CLASS[chartArcsBackground] = 'c3-chart-arcs-background';
CLASS[chartArcsGaugeUnit] = 'c3-chart-arcs-gauge-unit';
CLASS[chartArcsGaugeMax] = 'c3-chart-arcs-gauge-max';
CLASS[chartArcsGaugeMin] = 'c3-chart-arcs-gauge-min';
CLASS[selectedCircle] = 'c3-selected-circle';
CLASS[selectedCircles] = 'c3-selected-circles';
CLASS[eventRect] = 'c3-event-rect';
CLASS[eventRects] = 'c3-event-rects';
CLASS[eventRectsSingle] = 'c3-event-rects-single';
CLASS[eventRectsMultiple] = 'c3-event-rects-multiple';
CLASS[zoomRect] = 'c3-zoom-rect';
CLASS[brush] = 'c3-brush';
CLASS[focused] = 'c3-focused';
CLASS[region] = 'c3-region';
CLASS[regions] = 'c3-regions';
CLASS[tooltip] = 'c3-tooltip';
CLASS[tooltipName] = 'c3-tooltip-name';
CLASS[shape] = 'c3-shape';
CLASS[shapes] = 'c3-shapes';
CLASS[line] = 'c3-line';
CLASS[lines] = 'c3-lines';
CLASS[bar] = 'c3-bar';
CLASS[bars] = 'c3-bars';
CLASS[circle] = 'c3-circle';
CLASS[circles] = 'c3-circles';
CLASS[arc] = 'c3-arc';
CLASS[arcs] = 'c3-arcs';
CLASS[area] = 'c3-area';
CLASS[areas] = 'c3-areas';
CLASS[empty] = 'c3-empty';
CLASS[text] = 'c3-text';
CLASS[texts] = 'c3-texts';
CLASS[gaugeValue] = 'c3-gauge-value';
CLASS[grid] = 'c3-grid';
CLASS[xgrid] = 'c3-xgrid';
CLASS[xgrids] = 'c3-xgrids';
CLASS[xgridLine] = 'c3-xgrid-line';
CLASS[xgridLines] = 'c3-xgrid-lines';
CLASS[xgridFocus] = 'c3-xgrid-focus';
CLASS[ygrid] = 'c3-ygrid';
CLASS[ygrids] = 'c3-ygrids';
CLASS[ygridLine] = 'c3-ygrid-line';
CLASS[ygridLines] = 'c3-ygrid-lines';
CLASS[axis] = 'c3-axis';
CLASS[axisX] = 'c3-axis-x';
CLASS[axisXLabel] = 'c3-axis-x-label';
CLASS[axisY] = 'c3-axis-y';
CLASS[axisYLabel] = 'c3-axis-y-label';
CLASS[axisY2] = 'c3-axis-y2';
CLASS[axisY2Label] = 'c3-axis-y2-label';
CLASS[legendBackground] = 'c3-legend-background';
CLASS[legendItem] = 'c3-legend-item';
CLASS[legendItemEvent] = 'c3-legend-item-event';
CLASS[legendItemTile] = 'c3-legend-item-tile';
CLASS[legendItemHidden] = 'c3-legend-item-hidden';
CLASS[legendItemFocused] = 'c3-legend-item-focused';
CLASS[dragarea] = 'c3-dragarea';
CLASS[EXPANDED] = '_expanded_';
CLASS[SELECTED] = '_selected_';
CLASS[INCLUDED] = '_included_';
c3_chart_internal_fn.generateClass = function (prefix, targetId) { c3_chart_internal_fn.generateClass = function (prefix, targetId) {
return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId);
}; };
c3_chart_internal_fn.classText = function (d) { c3_chart_internal_fn.classText = function (d) {
return this.generateClass(CLASS.text, d.index); return this.generateClass(CLASS[text], d.index);
}; };
c3_chart_internal_fn.classTexts = function (d) { c3_chart_internal_fn.classTexts = function (d) {
return this.generateClass(CLASS.texts, d.id); return this.generateClass(CLASS[texts], d.id);
}; };
c3_chart_internal_fn.classShape = function (d) { c3_chart_internal_fn.classShape = function (d) {
return this.generateClass(CLASS.shape, d.index); return this.generateClass(CLASS[shape], d.index);
}; };
c3_chart_internal_fn.classShapes = function (d) { c3_chart_internal_fn.classShapes = function (d) {
return this.generateClass(CLASS.shapes, d.id); return this.generateClass(CLASS[shapes], d.id);
}; };
c3_chart_internal_fn.classLine = function (d) { c3_chart_internal_fn.classLine = function (d) {
return this.classShape(d) + this.generateClass(CLASS.line, d.id); return this.classShape(d) + this.generateClass(CLASS[line], d.id);
}; };
c3_chart_internal_fn.classLines = function (d) { c3_chart_internal_fn.classLines = function (d) {
return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); return this.classShapes(d) + this.generateClass(CLASS[lines], d.id);
}; };
c3_chart_internal_fn.classCircle = function (d) { c3_chart_internal_fn.classCircle = function (d) {
return this.classShape(d) + this.generateClass(CLASS.circle, d.index); return this.classShape(d) + this.generateClass(CLASS[circle], d.index);
}; };
c3_chart_internal_fn.classCircles = function (d) { c3_chart_internal_fn.classCircles = function (d) {
return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); return this.classShapes(d) + this.generateClass(CLASS[circles], d.id);
}; };
c3_chart_internal_fn.classBar = function (d) { c3_chart_internal_fn.classBar = function (d) {
return this.classShape(d) + this.generateClass(CLASS.bar, d.index); return this.classShape(d) + this.generateClass(CLASS[bar], d.index);
}; };
c3_chart_internal_fn.classBars = function (d) { c3_chart_internal_fn.classBars = function (d) {
return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); return this.classShapes(d) + this.generateClass(CLASS[bars], d.id);
}; };
c3_chart_internal_fn.classArc = function (d) { c3_chart_internal_fn.classArc = function (d) {
return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); return this.classShape(d.data) + this.generateClass(CLASS[arc], d.data.id);
}; };
c3_chart_internal_fn.classArcs = function (d) { c3_chart_internal_fn.classArcs = function (d) {
return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); return this.classShapes(d.data) + this.generateClass(CLASS[arcs], d.data.id);
}; };
c3_chart_internal_fn.classArea = function (d) { c3_chart_internal_fn.classArea = function (d) {
return this.classShape(d) + this.generateClass(CLASS.area, d.id); return this.classShape(d) + this.generateClass(CLASS[area], d.id);
}; };
c3_chart_internal_fn.classAreas = function (d) { c3_chart_internal_fn.classAreas = function (d) {
return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); return this.classShapes(d) + this.generateClass(CLASS[areas], d.id);
}; };
c3_chart_internal_fn.classRegion = function (d, i) { c3_chart_internal_fn.classRegion = function (d, i) {
return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d.class : ''); return this.generateClass(CLASS[region], i) + ' ' + ('class' in d ? d.class : '');
}; };
c3_chart_internal_fn.classEvent = function (d) { c3_chart_internal_fn.classEvent = function (d) {
return this.generateClass(CLASS.eventRect, d.index); return this.generateClass(CLASS[eventRect], d.index);
}; };
c3_chart_internal_fn.classTarget = function (id) { c3_chart_internal_fn.classTarget = function (id) {
var $$ = this; var $$ = this;
var additionalClassSuffix = $$.config[__data_classes][id], additionalClass = ''; var additionalClassSuffix = $$.config[__data_classes][id], additionalClass = '';
if (additionalClassSuffix) { if (additionalClassSuffix) {
additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; additionalClass = ' ' + CLASS[target] + '-' + additionalClassSuffix;
} }
return $$.generateClass(CLASS.target, id) + additionalClass; return $$.generateClass(CLASS[target], id) + additionalClass;
}; };
c3_chart_internal_fn.classChartText = function (d) { c3_chart_internal_fn.classChartText = function (d) {
return CLASS.chartText + this.classTarget(d.id); return CLASS[chartText] + this.classTarget(d.id);
}; };
c3_chart_internal_fn.classChartLine = function (d) { c3_chart_internal_fn.classChartLine = function (d) {
return CLASS.chartLine + this.classTarget(d.id); return CLASS[chartLine] + this.classTarget(d.id);
}; };
c3_chart_internal_fn.classChartBar = function (d) { c3_chart_internal_fn.classChartBar = function (d) {
return CLASS.chartBar + this.classTarget(d.id); return CLASS[chartBar] + this.classTarget(d.id);
}; };
c3_chart_internal_fn.classChartArc = function (d) { c3_chart_internal_fn.classChartArc = function (d) {
return CLASS.chartArc + this.classTarget(d.data.id); return CLASS[chartArc] + this.classTarget(d.data.id);
}; };
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
return targetId || targetId === 0 ? '-' + (targetId.replace ? targetId.replace(/([^a-zA-Z0-9-_])/g, '-') : targetId) : ''; return targetId || targetId === 0 ? '-' + (targetId.replace ? targetId.replace(/([^a-zA-Z0-9-_])/g, '-') : targetId) : '';
}; };
c3_chart_internal_fn.selectorTarget = function (id) { c3_chart_internal_fn.selectorTarget = function (id) {
return '.' + CLASS.target + this.getTargetSelectorSuffix(id); return '.' + CLASS[target] + this.getTargetSelectorSuffix(id);
}; };
c3_chart_internal_fn.selectorTargets = function (ids) { c3_chart_internal_fn.selectorTargets = function (ids) {
var $$ = this; var $$ = this;
return ids.length ? ids.map(function (id) { return $$.selectorTarget(id); }) : null; return ids.length ? ids.map(function (id) { return $$.selectorTarget(id); }) : null;
}; };
c3_chart_internal_fn.selectorLegend = function (id) { c3_chart_internal_fn.selectorLegend = function (id) {
return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); return '.' + CLASS[legendItem] + this.getTargetSelectorSuffix(id);
}; };
c3_chart_internal_fn.selectorLegends = function (ids) { c3_chart_internal_fn.selectorLegends = function (ids) {
var $$ = this; var $$ = this;
...@@ -5341,26 +5413,26 @@ ...@@ -5341,26 +5413,26 @@
minY = (config[__data_selection_grouped]) ? $$.margin.top : Math.min(sy, my); minY = (config[__data_selection_grouped]) ? $$.margin.top : Math.min(sy, my);
maxY = (config[__data_selection_grouped]) ? $$.height : Math.max(sy, my); maxY = (config[__data_selection_grouped]) ? $$.height : Math.max(sy, my);
main.select('.' + CLASS.dragarea) main.select('.' + CLASS[dragarea])
.attr('x', minX) .attr('x', minX)
.attr('y', minY) .attr('y', minY)
.attr('width', maxX - minX) .attr('width', maxX - minX)
.attr('height', maxY - minY); .attr('height', maxY - minY);
// TODO: binary search when multiple xs // TODO: binary search when multiple xs
main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape) 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) { .each(function (d, i) {
var shape = d3.select(this), var shape = d3.select(this),
isSelected = shape.classed(CLASS.SELECTED), isSelected = shape.classed(CLASS[SELECTED]),
isIncluded = shape.classed(CLASS.INCLUDED), isIncluded = shape.classed(CLASS[INCLUDED]),
_x, _y, _w, _h, toggle, isWithin = false, box; _x, _y, _w, _h, toggle, isWithin = false, box;
if (shape.classed(CLASS.circle)) { if (shape.classed(CLASS[circle])) {
_x = shape.attr("cx") * 1; _x = shape.attr("cx") * 1;
_y = shape.attr("cy") * 1; _y = shape.attr("cy") * 1;
toggle = $$.togglePoint; toggle = $$.togglePoint;
isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY;
} }
else if (shape.classed(CLASS.bar)) { else if (shape.classed(CLASS[bar])) {
box = getPathBox(this); box = getPathBox(this);
_x = box.x; _x = box.x;
_y = box.y; _y = box.y;
...@@ -5373,9 +5445,9 @@ ...@@ -5373,9 +5445,9 @@
return; return;
} }
if (isWithin ^ isIncluded) { if (isWithin ^ isIncluded) {
shape.classed(CLASS.INCLUDED, !isIncluded); shape.classed(CLASS[INCLUDED], !isIncluded);
// TODO: included/unincluded callback here // TODO: included/unincluded callback here
shape.classed(CLASS.SELECTED, !isSelected); shape.classed(CLASS[SELECTED], !isSelected);
$$.toggle(!isSelected, shape, d, i); $$.toggle(!isSelected, shape, d, i);
} }
}); });
...@@ -5386,8 +5458,8 @@ ...@@ -5386,8 +5458,8 @@
if ($$.hasArcType($$.data.targets)) { return; } if ($$.hasArcType($$.data.targets)) { 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; $$.dragStart = mouse;
$$.main.select('.' + CLASS.chart).append('rect') $$.main.select('.' + CLASS[chart]).append('rect')
.attr('class', CLASS.dragarea) .attr('class', CLASS[dragarea])
.style('opacity', 0.1); .style('opacity', 0.1);
$$.dragging = true; $$.dragging = true;
$$.config[__data_ondragstart](); $$.config[__data_ondragstart]();
...@@ -5397,12 +5469,12 @@ ...@@ -5397,12 +5469,12 @@
var $$ = this, config = $$.config; var $$ = this, config = $$.config;
if ($$.hasArcType($$.data.targets)) { return; } if ($$.hasArcType($$.data.targets)) { 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) $$.main.select('.' + CLASS[dragarea])
.transition().duration(100) .transition().duration(100)
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
$$.main.selectAll('.' + CLASS.shape) $$.main.selectAll('.' + CLASS[shape])
.classed(CLASS.INCLUDED, false); .classed(CLASS[INCLUDED], false);
$$.dragging = false; $$.dragging = false;
$$.config[__data_ondragend](); $$.config[__data_ondragend]();
}; };
...@@ -5424,7 +5496,7 @@ ...@@ -5424,7 +5496,7 @@
} }
this.revert(); this.revert();
this.defocus(); this.defocus();
focus(candidatesForNoneArc.classed(CLASS.focused, true)); focus(candidatesForNoneArc.classed(CLASS[focused], true));
focus(candidatesForArc); focus(candidatesForArc);
if ($$.hasArcType($$.data.targets)) { if ($$.hasArcType($$.data.targets)) {
$$.expandArc(targetId, true); $$.expandArc(targetId, true);
...@@ -5441,7 +5513,7 @@ ...@@ -5441,7 +5513,7 @@
$$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 0.3); $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 0.3);
} }
this.revert(); this.revert();
defocus(candidatesForNoneArc.classed(CLASS.focused, false)); defocus(candidatesForNoneArc.classed(CLASS[focused], false));
defocus(candidatesForArc); defocus(candidatesForArc);
if ($$.hasArcType($$.data.targets)) { if ($$.hasArcType($$.data.targets)) {
$$.unexpandArc(targetId); $$.unexpandArc(targetId);
...@@ -5457,7 +5529,7 @@ ...@@ -5457,7 +5529,7 @@
function revert(targets) { function revert(targets) {
$$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 1); $$.filterTargetsToShow(targets).transition().duration(100).style('opacity', 1);
} }
revert(candidatesForNoneArc.classed(CLASS.focused, false)); revert(candidatesForNoneArc.classed(CLASS[focused], false));
revert(candidatesForArc); revert(candidatesForArc);
if ($$.hasArcType($$.data.targets)) { if ($$.hasArcType($$.data.targets)) {
$$.unexpandArc(targetId); $$.unexpandArc(targetId);
...@@ -5704,30 +5776,30 @@ ...@@ -5704,30 +5776,30 @@
c3_chart_fn.selected = function (targetId) { c3_chart_fn.selected = function (targetId) {
var $$ = this.internal, d3 = $$.d3; var $$ = this.internal, d3 = $$.d3;
return d3.merge( return d3.merge(
$$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) $$.main.selectAll('.' + CLASS[shapes] + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS[shape])
.filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) .filter(function () { return d3.select(this).classed(CLASS[SELECTED]); })
.map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); })
); );
}; };
c3_chart_fn.select = function (ids, indices, resetOther) { c3_chart_fn.select = function (ids, indices, resetOther) {
var $$ = this.internal, d3 = $$.d3, config = $$.config; 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) { $$.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), 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, isTargetIndex = !indices || indices.indexOf(i) >= 0,
isSelected = shape.classed(CLASS.SELECTED); isSelected = shape.classed(CLASS[SELECTED]);
// line/area selection not supported yet // line/area selection not supported yet
if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { if (shape.classed(CLASS[line]) || shape.classed(CLASS[area])) {
return; return;
} }
if (isTargetId && isTargetIndex) { 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); toggle(true, shape.classed(CLASS[SELECTED], true), d, i);
} }
} else if (isDefined(resetOther) && resetOther) { } else if (isDefined(resetOther) && resetOther) {
if (isSelected) { if (isSelected) {
toggle(false, shape.classed(CLASS.SELECTED, false), d, i); toggle(false, shape.classed(CLASS[SELECTED], false), d, i);
} }
} }
}); });
...@@ -5735,19 +5807,19 @@ ...@@ -5735,19 +5807,19 @@
c3_chart_fn.unselect = function (ids, indices) { c3_chart_fn.unselect = function (ids, indices) {
var $$ = this.internal, d3 = $$.d3, config = $$.config; 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) { $$.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), 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, isTargetIndex = !indices || indices.indexOf(i) >= 0,
isSelected = shape.classed(CLASS.SELECTED); isSelected = shape.classed(CLASS[SELECTED]);
// line/area selection not supported yet // line/area selection not supported yet
if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { if (shape.classed(CLASS[line]) || shape.classed(CLASS[area])) {
return; return;
} }
if (isTargetId && isTargetIndex) { if (isTargetId && isTargetIndex) {
if (config[__data_selection_isselectable](d)) { if (config[__data_selection_isselectable](d)) {
if (isSelected) { if (isSelected) {
toggle(false, shape.classed(CLASS.SELECTED, false), d, i); toggle(false, shape.classed(CLASS[SELECTED], false), d, i);
} }
} }
} }
...@@ -5820,9 +5892,9 @@ ...@@ -5820,9 +5892,9 @@
options = options || {}; options = options || {};
duration = $$.getOption(options, "duration", config[__transition_duration]); duration = $$.getOption(options, "duration", config[__transition_duration]);
classes = $$.getOption(options, "classes", [CLASS.region]); classes = $$.getOption(options, "classes", [CLASS[region]]);
regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; })); regions = $$.main.select('.' + CLASS[regions]).selectAll(classes.map(function (c) { return '.' + c; }));
(duration ? regions.transition().duration(duration) : regions) (duration ? regions.transition().duration(duration) : regions)
.style('opacity', 0) .style('opacity', 0)
.remove(); .remove();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment