Browse Source

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

pull/116/merge
Masayuki Tanaka 11 years ago
parent
commit
c92c53db9e
  1. 11
      c3.js
  2. 4
      c3.min.js
  3. 70
      htdocs/samples/api_axis_label.html

11
c3.js

@ -782,6 +782,11 @@
});
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() {
var scale = d3.scale.linear(), orient = "bottom";
@ -2879,9 +2884,7 @@
yForText = generateXYForText(barIndices, false);
// Update axis label
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);
updateAxisLabels();
// Update sub domain
subY.domain(y.domain());
@ -3967,7 +3970,7 @@
Object.keys(labels).forEach(function (axisId) {
setAxisLabelText(axisId, labels[axisId]);
});
redraw({withY: false, withSubchart: false, withTransition: false});
updateAxisLabels();
}
// TODO: return some values?
};

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

70
htdocs/samples/api_axis_label.html

@ -0,0 +1,70 @@
<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>
Loading…
Cancel
Save