Commit c92c53db authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix axis.label API not to stop transition - #107

parent 17478d6d
...@@ -782,6 +782,11 @@ ...@@ -782,6 +782,11 @@
}); });
return maxWidth < 20 ? 20 : maxWidth; return maxWidth < 20 ? 20 : maxWidth;
} }
function updateAxisLabels() {
main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel).attr("x", xForXAxisLabel).text(textForXAxisLabel);
main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel).attr("x", xForYAxisLabel).attr("dy", dyForYAxisLabel).text(textForYAxisLabel);
main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label).attr("x", xForY2AxisLabel).attr("dy", dyForY2AxisLabel).text(textForY2AxisLabel);
}
function categoryAxis() { function categoryAxis() {
var scale = d3.scale.linear(), orient = "bottom"; var scale = d3.scale.linear(), orient = "bottom";
...@@ -2879,9 +2884,7 @@ ...@@ -2879,9 +2884,7 @@
yForText = generateXYForText(barIndices, false); yForText = generateXYForText(barIndices, false);
// Update axis label // Update axis label
main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel).attr("x", xForXAxisLabel).text(textForXAxisLabel); updateAxisLabels();
main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel).attr("x", xForYAxisLabel).attr("dy", dyForYAxisLabel).text(textForYAxisLabel);
main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label).attr("x", xForY2AxisLabel).attr("dy", dyForY2AxisLabel).text(textForY2AxisLabel);
// Update sub domain // Update sub domain
subY.domain(y.domain()); subY.domain(y.domain());
...@@ -3967,7 +3970,7 @@ ...@@ -3967,7 +3970,7 @@
Object.keys(labels).forEach(function (axisId) { Object.keys(labels).forEach(function (axisId) {
setAxisLabelText(axisId, labels[axisId]); setAxisLabelText(axisId, labels[axisId]);
}); });
redraw({withY: false, withSubchart: false, withTransition: false}); updateAxisLabels();
} }
// TODO: return some values? // TODO: return some values?
}; };
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<html>
<head>
<link href="/css/c3.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script>
<script>
var chart = c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25]
],
axes: {
data1: 'y',
data2: 'y2',
}
},
axis: {
x: {
label: 'X Label'
},
y: {
label: {
text: 'Y Axis Label',
position: 'outer-middle'
}
},
y2: {
show: true,
label: {
text: 'Y2 Axis Label',
position: 'outer-middle'
}
}
},
tooltip: {
// enabled: false
},
zoom: {
// enabled: true
},
subchart: {
// show: true
}
});
setTimeout(function () {
chart.axis.labels({
x: 'New X Axis Label',
y: 'New Y Axis Label',
y2: 'New Y2 Axis Label',
});
}, 1000);
setTimeout(function () {
chart.load({
columns: [
['data1', 100, 300, 600, 200, 400, 500]
]
});
chart.axis.labels({y: 'New Y Axis Label Again'});
}, 2000);
</script>
</body>
</html>
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