dimple.js How can I change the labels of a chart axis without changing the data?

痞子三分冷 提交于 2020-01-01 16:47:53

问题


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?


回答1:


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";



回答2:


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/



来源:https://stackoverflow.com/questions/23291200/dimple-js-how-can-i-change-the-labels-of-a-chart-axis-without-changing-the-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!