Comparing version 0.4.4 to 0.4.5
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"homepage": "https://github.com/masayuki0812/c3", | ||
@@ -10,0 +10,0 @@ "authors": [ |
@@ -5,3 +5,3 @@ { | ||
"description": "A D3-based reusable chart library", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"keywords": [], | ||
@@ -8,0 +8,0 @@ "dependencies": { |
{ | ||
"name": "c3", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "D3-based reusable chart library", | ||
@@ -5,0 +5,0 @@ "main": "c3.js", |
@@ -154,2 +154,34 @@ var describe = window.describe, | ||
describe('legend.show', function () { | ||
it('should update args', function () { | ||
args = { | ||
data: { | ||
columns: [ | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['data2', 130, 100, 200, 100, 250, 150] | ||
] | ||
}, | ||
legend: { | ||
show: false | ||
} | ||
}; | ||
expect(true).toBeTruthy(); | ||
}); | ||
it('should not initially have rendered any legend items', function () { | ||
expect(d3.selectAll('.c3-legend-item').empty()).toBe(true); | ||
}); | ||
it('allows us to show the legend on showLegend call', function () { | ||
chart.legend.show(); | ||
d3.selectAll('.c3-legend-item').each(function () { | ||
expect(d3.select(this).style('visibility')).toBe('visible'); | ||
// This selects all the children, but we expect it to be empty | ||
expect(d3.select(this).selectAll("*").length).not.toEqual(0); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -23,12 +23,4 @@ var describe = window.describe, | ||
beforeEach(function (done) { | ||
if (typeof chart === 'undefined') { | ||
window.initDom(); | ||
} | ||
chart = window.c3.generate(args); | ||
chart = window.initChart(chart, args, done); | ||
d3 = chart.internal.d3; | ||
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none'); | ||
window.setTimeout(function () { | ||
done(); | ||
}, 10); | ||
}); | ||
@@ -38,13 +30,44 @@ | ||
it('should return true', function () { | ||
expect(chart.internal.hasArcType()).toBeTruthy(); | ||
}); | ||
describe('with data', function () { | ||
it('should change chart type to "bar" successfully', function () { | ||
args.data.type = 'bar'; | ||
expect(true).toBeTruthy(); | ||
it('should return true', function () { | ||
expect(chart.internal.hasArcType()).toBeTruthy(); | ||
}); | ||
it('should change chart type to "bar"', function () { | ||
args.data.type = 'bar'; | ||
expect(true).toBeTruthy(); | ||
}); | ||
it('should return false', function () { | ||
expect(chart.internal.hasArcType()).toBeFalsy(); | ||
}); | ||
}); | ||
it('should return false', function () { | ||
expect(chart.internal.hasArcType()).toBeFalsy(); | ||
describe('with empty data', function () { | ||
it('should update args to have empty data', function () { | ||
args = { | ||
data: { | ||
columns: [], | ||
type: 'pie' | ||
} | ||
}; | ||
expect(true).toBeTruthy(); | ||
}); | ||
it('should return true', function () { | ||
expect(chart.internal.hasArcType()).toBeTruthy(); | ||
}); | ||
it('should change chart type to "bar"', function () { | ||
args.data.type = 'bar'; | ||
expect(true).toBeTruthy(); | ||
}); | ||
it('should return false', function () { | ||
expect(chart.internal.hasArcType()).toBeFalsy(); | ||
}); | ||
}); | ||
@@ -56,4 +79,13 @@ | ||
it('should change chart type to "pie" successfully', function () { | ||
args.data.type = 'pie'; | ||
it('should update args', function () { | ||
args = { | ||
data: { | ||
columns: [ | ||
['data1', 30, 200, 100, 400, 150, 250], | ||
['data2', 50, 20, 10, 40, 15, 25], | ||
['data3', 150, 120, 110, 140, 115, 125] | ||
], | ||
type: 'pie' | ||
} | ||
}; | ||
expect(true).toBeTruthy(); | ||
@@ -60,0 +92,0 @@ }); |
@@ -19,2 +19,3 @@ c3_chart_fn.data = function (targetIds) { | ||
c3_chart_fn.data.names = function (names) { | ||
this.internal.clearLegendItemTextBoxCache(); | ||
return this.internal.updateDataAttributes('names', names); | ||
@@ -21,0 +22,0 @@ }; |
@@ -139,3 +139,4 @@ c3_chart_fn.flow = function (args) { | ||
withTransition: orgDataCount > 1, | ||
withTrimXDomain: false | ||
withTrimXDomain: false, | ||
withUpdateXAxis: true, | ||
}); | ||
@@ -142,0 +143,0 @@ }; |
@@ -45,5 +45,7 @@ c3_chart_fn.show = function (targetIds, options) { | ||
c3_chart_fn.toggle = function (targetId) { | ||
var $$ = this.internal; | ||
$$.isTargetToShow(targetId) ? this.hide(targetId) : this.show(targetId); | ||
c3_chart_fn.toggle = function (targetIds) { | ||
var that = this, $$ = this.internal; | ||
$$.mapToTargetIds(targetIds).forEach(function (targetId) { | ||
$$.isTargetToShow(targetId) ? that.hide(targetId) : that.show(targetId); | ||
}); | ||
}; |
@@ -170,5 +170,6 @@ // Features: | ||
}); | ||
}) | ||
.enter().append('tspan') | ||
.text(function (d) { return d.splitted; }); | ||
}); | ||
tspan.enter().append('tspan'); | ||
tspan.exit().remove(); | ||
tspan.text(function (d) { return d.splitted; }); | ||
@@ -175,0 +176,0 @@ switch (orient) { |
@@ -1,2 +0,2 @@ | ||
var c3 = { version: "0.4.4" }; | ||
var c3 = { version: "0.4.5" }; | ||
@@ -122,3 +122,2 @@ var c3_chart_fn, c3_chart_internal_fn; | ||
$$.legendItemHeight = 0; | ||
$$.legendOpacityForHidden = 0.15; | ||
@@ -427,3 +426,5 @@ $$.currentMaxTickWidths = { | ||
var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); | ||
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension; | ||
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, | ||
withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, | ||
withEventRect, withDimension, withUpdateXAxis; | ||
var hideAxis = $$.hasArcType(); | ||
@@ -444,2 +445,3 @@ var drawArea, drawBar, drawLine, xForText, yForText; | ||
withTrimXDomain = getOption(options, "withTrimXDomain", true); | ||
withUpdateXAxis = getOption(options, "withUpdateXAxis", withUpdateXDomain); | ||
withLegend = getOption(options, "withLegend", false); | ||
@@ -508,3 +510,3 @@ withEventRect = getOption(options, "withEventRect", true); | ||
// show/hide if manual culling needed | ||
if (withUpdateXDomain && targetsToShow.length) { | ||
if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { | ||
if (config.axis_x_tick_culling && tickValues) { | ||
@@ -511,0 +513,0 @@ for (i = 1; i < tickValues.length; i++) { |
@@ -312,4 +312,4 @@ c3_chart_internal_fn.isX = function (key) { | ||
values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) { | ||
var shape = $$.d3.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); | ||
if ($$.isWithinBar(shape)) { | ||
var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); | ||
if (!closest && $$.isWithinBar(shape)) { | ||
closest = v; | ||
@@ -316,0 +316,0 @@ } |
c3_chart_internal_fn.initLegend = function () { | ||
var $$ = this; | ||
$$.legendHasRendered = false; | ||
$$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend')); | ||
@@ -7,5 +8,10 @@ if (!$$.config.legend_show) { | ||
$$.hiddenLegendIds = $$.mapToIds($$.data.targets); | ||
return; | ||
} | ||
// MEMO: call here to update legend box and tranlate for all | ||
// MEMO: translate will be upated by this, so transform not needed in updateLegend() | ||
$$.updateLegendWithDefaults(); | ||
}; | ||
c3_chart_internal_fn.updateLegendWithDefaults = function () { | ||
var $$ = this; | ||
$$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false}); | ||
@@ -55,8 +61,6 @@ }; | ||
c3_chart_internal_fn.opacityForLegend = function (legendItem) { | ||
var $$ = this; | ||
return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 1; | ||
return legendItem.classed(CLASS.legendItemHidden) ? null : 1; | ||
}; | ||
c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { | ||
var $$ = this; | ||
return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 0.3; | ||
return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; | ||
}; | ||
@@ -88,2 +92,5 @@ c3_chart_internal_fn.toggleFocusLegend = function (targetIds, focus) { | ||
$$.legend.style('visibility', 'visible'); | ||
if (!$$.legendHasRendered) { | ||
$$.updateLegendWithDefaults(); | ||
} | ||
} | ||
@@ -108,2 +115,5 @@ $$.removeHiddenLegendIds(targetIds); | ||
var legendItemTextBox = {}; | ||
c3_chart_internal_fn.clearLegendItemTextBoxCache = function () { | ||
legendItemTextBox = {}; | ||
}; | ||
c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { | ||
@@ -312,3 +322,3 @@ var $$ = this, config = $$.config; | ||
} else { | ||
return $$.legendOpacityForHidden; | ||
return null; // c3-legend-item-hidden will be applied | ||
} | ||
@@ -327,2 +337,3 @@ }); | ||
$$.transformAll(withTransitionForTransform, transitions); | ||
$$.legendHasRendered = true; | ||
}; |
@@ -21,6 +21,8 @@ c3_chart_internal_fn.setTargetType = function (targetIds, type) { | ||
}); | ||
} else { | ||
} else if (Object.keys(types).length) { | ||
Object.keys(types).forEach(function (id) { | ||
if (types[id] === type) { has = true; } | ||
}); | ||
} else { | ||
has = $$.config.data_type === type; | ||
} | ||
@@ -27,0 +29,0 @@ return has; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1874866
222
29407