dimple.js How can I change the labels of a chart a

2020-07-22 09:34发布

Say we have the bar chart of the example http://dimplejs.org/examples_viewer.html?id=bars_vertical and I want to change the x axis label from "Months" to "Meses". How can I do that?

2条回答
Evening l夕情丶
2楼-- · 2020-07-22 10:11

After drawing you can access the title object and set it's text as follows:

chart = new dimple.chart(svg, data);
x = chart.addCategoryAxis("x", ["Fruit", "Year"]);
chart.addMeasureAxis("y", "Value");
chart.addSeries(["Volume", "Year"], dimple.plot.bar);
chart.draw();
x.titleShape.text("My New Title");

Here it is working: http://jsfiddle.net/y3BVN/

查看更多
手持菜刀,她持情操
3楼-- · 2020-07-22 10:17

Instead of changing the titleShape after drawing, you can also change the title directly before drawing.

To do so, simply assign the title property:

var chart = new dimple.chart(svg, data);
var x = chart.addCategoryAxis("x", ["Fruit", "Year"]);
x.title = "My New Title";
查看更多
登录 后发表回答