Commit dceeaf28 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix y axis padding when data label shown - #799

parent bfac88c2
......@@ -1369,8 +1369,8 @@
padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1]));
} else if (showVerticalDataLabel) {
lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, axisId, 'height');
padding_top += lengths[1];
padding_bottom += lengths[0];
padding_top += domainLength * (lengths[1] / $$.height);
padding_bottom += domainLength * (lengths[0] / $$.height);
}
if (axisId === 'y' && notEmpty(config.axis_y_padding)) {
padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -22,16 +22,8 @@ describe('c3 chart data', function () {
};
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);
});
describe('function in data.order', function () {
......@@ -147,4 +139,27 @@ describe('c3 chart data', function () {
});
});
describe('data.label', function () {
it('should update args to show data label', function () {
args = {
data: {
columns: [
['data1', 0.03, 0.2, 0.1, 0.4, 0.15, 0.250]
],
labels: true
}
};
expect(true).toBeTruthy();
});
it('should have proper y domain', function () {
var domain = chart.internal.y.domain();
expect(domain[0]).toBeCloseTo(-0.02);
expect(domain[1]).toBeCloseTo(0.45);
});
});
});
......@@ -126,8 +126,8 @@ c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) {
padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1]));
} else if (showVerticalDataLabel) {
lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, axisId, 'height');
padding_top += lengths[1];
padding_bottom += lengths[0];
padding_top += domainLength * (lengths[1] / $$.height);
padding_bottom += domainLength * (lengths[0] / $$.height);
}
if (axisId === 'y' && notEmpty(config.axis_y_padding)) {
padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength);
......
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