Browse Source

Merge branch 'master' of https://github.com/joshpurvis/c3 into joshpurvis-master

pull/155/head
Masayuki Tanaka 11 years ago
parent
commit
0008bae737
  1. 35
      c3.js

35
c3.js

@ -1925,9 +1925,14 @@
colors = _colors, colors = _colors,
pattern = notEmpty(_pattern) ? _pattern : ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']; //same as d3.scale.category10() pattern = notEmpty(_pattern) ? _pattern : ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']; //same as d3.scale.category10()
return function (id) { return function (d) {
var id = d.id || d;
// if callback function is provided
if (colors[id] instanceof Function) { return colors[id](d); }
// if specified, choose that color // if specified, choose that color
if (id in colors) { return _colors[id]; } if (id in colors) { return colors[id]; }
// if not specified, choose from pattern // if not specified, choose from pattern
if (ids.indexOf(id) === -1) { if (ids.indexOf(id) === -1) {
@ -2008,7 +2013,7 @@
.attr("class", function () { return generateClass(CLASS.selectedCircle, i); }) .attr("class", function () { return generateClass(CLASS.selectedCircle, i); })
.attr("cx", __axis_rotated ? circleY : circleX) .attr("cx", __axis_rotated ? circleY : circleX)
.attr("cy", __axis_rotated ? circleX : circleY) .attr("cy", __axis_rotated ? circleX : circleY)
.attr("stroke", function () { return color(d.id); }) .attr("stroke", function () { return color(d); })
.attr("r", __point_select_r * 1.4) .attr("r", __point_select_r * 1.4)
.transition().duration(100) .transition().duration(100)
.attr("r", __point_select_r); .attr("r", __point_select_r);
@ -2026,11 +2031,11 @@
function selectBar(target, d) { function selectBar(target, d) {
__data_onselected(d, target.node()); __data_onselected(d, target.node());
target.transition().duration(100).style("fill", function () { return d3.rgb(color(d.id)).darker(1); }); target.transition().duration(100).style("fill", function () { return d3.rgb(color(d)).darker(1); });
} }
function unselectBar(target, d) { function unselectBar(target, d) {
__data_onunselected(d, target.node()); __data_onunselected(d, target.node());
target.transition().duration(100).style("fill", function () { return color(d.id); }); target.transition().duration(100).style("fill", function () { return color(d); });
} }
function toggleBar(selected, target, d, i) { function toggleBar(selected, target, d, i) {
selected ? selectBar(target, d, i) : unselectBar(target, d, i); selected ? selectBar(target, d, i) : unselectBar(target, d, i);
@ -3072,7 +3077,7 @@
.attr('d', drawBar) .attr('d', drawBar)
.style("stroke", 'none') .style("stroke", 'none')
.style("opacity", 0) .style("opacity", 0)
.style("fill", function (d) { return color(d.id); }) .style("fill", function (d) { return color(d); })
.attr("class", classBar); .attr("class", classBar);
mainBar mainBar
.style("opacity", initialOpacity) .style("opacity", initialOpacity)
@ -3182,7 +3187,7 @@
contextBar.enter().append('path') contextBar.enter().append('path')
.attr('d', drawBarOnSub) .attr('d', drawBarOnSub)
.style("stroke", 'none') .style("stroke", 'none')
.style("fill", function (d) { return color(d.id); }) .style("fill", function (d) { return color(d); })
.attr("class", classBar); .attr("class", classBar);
contextBar contextBar
.style("opacity", initialOpacity) .style("opacity", initialOpacity)
@ -3363,7 +3368,7 @@
.style("pointer-events", "none"); .style("pointer-events", "none");
mainTextEnter.append('g') mainTextEnter.append('g')
.attr('class', classTexts) .attr('class', classTexts)
.style("fill", function (d) { return color(d.id); }); .style("fill", function (d) { return color(d); });
//-- Bar --// //-- Bar --//
mainBarUpdate = main.select('.' + CLASS.chartBars) mainBarUpdate = main.select('.' + CLASS.chartBars)
@ -3375,7 +3380,7 @@
// Bars for each data // Bars for each data
mainBarEnter.append('g') mainBarEnter.append('g')
.attr("class", classBars) .attr("class", classBars)
.style("fill", function (d) { return color(d.id); }) .style("fill", function (d) { return color(d); })
.style("stroke", "none") .style("stroke", "none")
.style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; }); .style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; });
@ -3390,18 +3395,18 @@
mainLineEnter.append("path") mainLineEnter.append("path")
.attr("class", classLine) .attr("class", classLine)
.style("opacity", 0) .style("opacity", 0)
.style("stroke", function (d) { return color(d.id); }); .style("stroke", function (d) { return color(d); });
// Areas // Areas
mainLineEnter.append("path") mainLineEnter.append("path")
.attr("class", classArea) .attr("class", classArea)
.style("opacity", function () { orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }) .style("opacity", function () { orgAreaOpacity = +d3.select(this).style('opacity'); return 0; })
.style("fill", function (d) { return color(d.id); }); .style("fill", function (d) { return color(d); });
// 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", classCircles) .attr("class", classCircles)
.style("fill", function (d) { return color(d.id); }) .style("fill", function (d) { return color(d); })
.style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; }); .style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; });
// Update date for selected circles // Update date for selected circles
targets.forEach(function (t) { targets.forEach(function (t) {
@ -3421,7 +3426,7 @@
mainPieEnter.append("path") mainPieEnter.append("path")
.attr("class", classArc) .attr("class", classArc)
.style("opacity", 0) .style("opacity", 0)
.style("fill", function (d) { return color(d.data.id); }) .style("fill", function (d) { return color(d.data); })
.style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; }) .style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; })
.each(function (d) { this._current = d; }) .each(function (d) { this._current = d; })
.on('mouseover', function (d, i) { .on('mouseover', function (d, i) {
@ -3465,7 +3470,7 @@
// Bars for each data // Bars for each data
contextBarEnter.append('g') contextBarEnter.append('g')
.attr("class", classBars) .attr("class", classBars)
.style("fill", function (d) { return color(d.id); }); .style("fill", function (d) { return color(d); });
//-- Line --// //-- Line --//
contextLineUpdate = context.select('.' + CLASS.chartLines) contextLineUpdate = context.select('.' + CLASS.chartLines)
@ -3477,7 +3482,7 @@
contextLineEnter.append("path") contextLineEnter.append("path")
.attr("class", classLine) .attr("class", classLine)
.style("opacity", 0) .style("opacity", 0)
.style("stroke", function (d) { return color(d.id); }); .style("stroke", function (d) { return color(d); });
} }
/*-- Show --*/ /*-- Show --*/

Loading…
Cancel
Save