Browse Source

Fix point.show not to hide scatter plot - #732

pull/742/head
Masayuki Tanaka 10 years ago
parent
commit
eab6b04dbe
  1. 3
      c3.js
  2. 2
      c3.min.js
  3. 64
      spec/shape.line-spec.js
  4. 3
      src/core.js

3
c3.js

@ -724,7 +724,8 @@
return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0; return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0;
}; };
c3_chart_internal_fn.opacityForCircle = function (d) { c3_chart_internal_fn.opacityForCircle = function (d) {
return isValue(d.value) && this.config.point_show ? (this.isScatterType(d) ? 0.5 : 1) : 0; var opacity = this.config.point_show ? 1 : 0;
return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0;
}; };
c3_chart_internal_fn.opacityForText = function () { c3_chart_internal_fn.opacityForText = function () {
return this.hasDataLabel() ? 1 : 0; return this.hasDataLabel() ? 1 : 0;

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

64
spec/shape.line-spec.js

@ -3,8 +3,6 @@ var describe = window.describe,
it = window.it, it = window.it,
beforeEach = window.beforeEach; beforeEach = window.beforeEach;
var initDom = window.initDom;
describe('c3 chart shape line', function () { describe('c3 chart shape line', function () {
'use strict'; 'use strict';
@ -22,16 +20,8 @@ describe('c3 chart shape line', function () {
}; };
beforeEach(function (done) { beforeEach(function (done) {
if (typeof chart === 'undefined') { chart = window.initChart(chart, args, done);
initDom();
}
chart = window.c3.generate(args);
d3 = chart.internal.d3; d3 = chart.internal.d3;
chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none');
window.setTimeout(function () {
done();
}, 10);
}); });
describe('shape-rendering for line chart', function () { describe('shape-rendering for line chart', function () {
@ -57,4 +47,56 @@ describe('c3 chart shape line', function () {
}); });
describe('point.show option', function () {
it('should change args to include null data', function () {
args = {
data: {
columns: [
['data1', 30, null, 100, 400, -150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', -150, 120, 110, 140, 115, 125]
],
type: 'line'
}
};
expect(true).toBeTruthy();
});
it('should not show the circle for null', function (done) {
setTimeout(function () {
var target = chart.internal.main.select('.c3-chart-line.c3-target-data1');
expect(+target.select('.c3-circle-0').style('opacity')).toBe(1);
expect(+target.select('.c3-circle-1').style('opacity')).toBe(0);
expect(+target.select('.c3-circle-2').style('opacity')).toBe(1);
done();
}, 500);
});
it('should change args to include null data on scatter plot', function () {
args = {
data: {
columns: [
['data1', 30, null, 100, 400, -150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', -150, 120, 110, 140, 115, 125]
],
type: 'scatter'
}
};
expect(true).toBeTruthy();
});
it('should not show the circle for null', function (done) {
setTimeout(function () {
var target = chart.internal.main.select('.c3-chart-line.c3-target-data1');
expect(+target.select('.c3-circle-0').style('opacity')).toBe(0.5);
expect(+target.select('.c3-circle-1').style('opacity')).toBe(0);
expect(+target.select('.c3-circle-2').style('opacity')).toBe(0.5);
done();
}, 500);
});
});
}); });

3
src/core.js

@ -719,7 +719,8 @@ c3_chart_internal_fn.initialOpacityForCircle = function (d) {
return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0; return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0;
}; };
c3_chart_internal_fn.opacityForCircle = function (d) { c3_chart_internal_fn.opacityForCircle = function (d) {
return isValue(d.value) && this.config.point_show ? (this.isScatterType(d) ? 0.5 : 1) : 0; var opacity = this.config.point_show ? 1 : 0;
return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0;
}; };
c3_chart_internal_fn.opacityForText = function () { c3_chart_internal_fn.opacityForText = function () {
return this.hasDataLabel() ? 1 : 0; return this.hasDataLabel() ? 1 : 0;

Loading…
Cancel
Save