c3分组条形图的数据结构?

时间:2015-07-07 17:08:28

标签: c3

我使用c3js并尝试渲染三个层中的每一个,并将每个月的流失条形分组在x轴层下。我的问题是数据结构应该是什么?

enter image description here

目前的数据是:

 [
  [
    "x",
    "Tier I",
    "Tier II",
    "Tier III"
  ],
  [
    [
      "Apr 2015",
      "6"
    ],
    [
      "May 2015",
      "3"
    ],
    [
      "Jun 2015",
      "61"
    ],
    [
      "Jul 2015",
      "4"
    ]
  ],
  [
    [
      "Apr 2015",
      "13"
    ],
    [
      "May 2015",
      "3"
    ],
    [
      "Jun 2015",
      "0"
    ],
    [
      "Jul 2015",
      "0"
    ]
  ],
  [
    [
      "Apr 2015",
      "4"
    ],
    [
      "May 2015",
      "5"
    ],
    [
      "Jun 2015",
      "4"
    ],
    [
      "Jul 2015",
      "8"
    ]
  ]

当前的c3电话是:

var chart = c3.generate({
            data: {
                x: 'x',
                columns: full,
                type: 'bar'
            },
            bar: {
                width: {
                    ratio: 0.8 // this makes bar width 50% of length between ticks
                }
            },
            axis: {
                x: {
                    type: 'categorized' // this is needed to load string x value
                }
            },
            bindto: '#chart'
        });

谢谢!

2 个答案:

答案 0 :(得分:4)

请注意,x轴类型为CABasicAnimation * pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"]; pathAnimation.fromValue = (__bridge id)[_startPath CGPath]; pathAnimation.duration = 3.0f; [myLineShapeLayer addAnimation:pathAnimation forKey:@"animationKey"]; 而非category

categorized

小提琴 - http://jsfiddle.net/6au5aLax/

enter image description here

答案 1 :(得分:0)

对Stacked X(2)Column和Y(3)Data Set

使用以下示例
{{1}}

2 Column by 3 Datasets C3 Bar Graph