如何动态更改图表属性,例如标题?

时间:2016-05-11 20:33:13

标签: d3.js dc.js

我真正需要的是从下拉菜单中更改维度属性和xUnits属性,即从图表的数月到数周。我可以通过硬编码值来静态地执行此操作:

dimT = data.dimension(function (d) {
   return d3.time.month/week(timeFormat.parse(d.invDt]));});
chart1 = dc.barChart(chrt_div)
    .dimension(dimT)
    .xUnits(d3.time.months/weeks)

从drop.change我尝试过:

dimT = data.dimension(function (d) {
    return d3.time.week(timeFormat.parse(d.invDt));});
chart1.dimension(dimT);
chart1.xUnits(d3.time.weeks);
dc.renderAll(); // just to be safe

它不起作用。退后一步,我试过了:

chart1.title("TitleChanged");
dc.renderAll(); //title does not change

我是否可以像这样进行动态更改?我所有的推荐都很好。

0 个答案:

没有答案