Multi-Level/Grouping of Axis Labels Using d3

谁说我不能喝 提交于 2019-12-20 10:39:55

问题


I was wondering if there is an easy way to add multi-level/hierarchical/grouping of axis label in d3. For example, if I have a line chart with month name for x-axis spanning across multiple years, I would want to also have year as label below the month names so it looks something like this.

Oct   Nov   Dec   Jan   Feb   Mar   Apr
|_____________|   |___________________|
     2011                 2012

I understand that you can do anything in SVG to make it works, but I want to use d3 as much as possible so that it's much easier to update the chart dynamically.

Thanks, Jack


回答1:


You can add and format several axes however you like. For instance - display one axis showing months, and another showing years. A basic example: http://jsfiddle.net/Ea4mT/1/

You might have to mess with it a little bit afterwards to get it in a more preferable format, but it seems like the core of what you are trying to accomplish.



来源:https://stackoverflow.com/questions/10778573/multi-level-grouping-of-axis-labels-using-d3

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