最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Multi-LevelGrouping of Axis Labels Using d3 - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question asked May 28, 2012 at 1:51 juminozjuminoz 3,2187 gold badges37 silver badges57 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 21

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.

发布评论

评论列表(0)

  1. 暂无评论