简体   繁体   English

使用c3.js创建具有高值和低值的条形图

[英]Creating a bar chart with high and low value using c3.js

I have been looking into c3.js for a few days now. 我一直在研究c3.js几天了。 Its been able to produce graphs for most of my needs.The only thing I cant figure out to do with it is , how to display a bar chart when you have high and low values specified. 它能够生成满足我大多数需求的图形。我唯一想不出的是,如何在指定了高值和低值时显示条形图。

ex: my sample array will be something like this 例如:我的样本数组将是这样的

Categories : ['cat1', 'cat2' ,'cat3' ,'cat4']
Low : [0,0,50,40]
High : [90,80,40,60]

Basically each bar for each category will be based on these high and low values. 基本上,每个类别的每个条形都将基于这些高值和低值。

Thanks ! 谢谢 !

You can try this sample: 您可以尝试以下示例:

var chart = c3.generate({
    data: {
        columns: [
            ['Low', 0,0,50,40],
            ['High', 90,80,40,60]
        ]
    },
    axis: {
        x: {
            type: 'category',
            categories: ['cat1', 'cat2', 'cat3', 'cat4']
        }
    }
});

Result: 结果:

在此处输入图片说明

To know how to install c3.js, please read an official documentation 要了解如何安装c3.js,请阅读官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM