所有数据点都不会显示在堆积条形图中

时间:2017-03-18 14:29:36

标签: javascript c3.js

大家好我将数据传递到c3堆积条形图。

["x","Mar 2017","Apr 2017","May 2017","Jun 2017","Jul 2017","Aug 2017","Sep 2017","Oct 2017","Nov 2017","Dec 2017","Jan 2018","Feb 2018"],
["product0","4","-4","12","-20","44","-84","172","-340","684","-1364","2732","-5460"],
["product1","10","15","20","25","30","40","40","70","50","160","65","475"],
["product2","6","10","14","18","22","26","30","34","38","42","46","50"]

如您所见,数字范围从-5460到2732。 对于上面的数据,我没有获得数字较小的列的工具提示中的所有数据点。例如,第一列分别包含product0,product1和product2的值4,10,6。当我在工具提示中将第一列悬停在图表上时,只有10和6出现但不是4。

我的工具提示设置如下所示

 tooltip: {             
            grouped: false,
            format: d3.format('.2f')
        },

如果设置分组:true则一切正常。但我不想分组,因为如果有大量数据,它看起来不太好。我需要启用哪些设置来解决此问题?这是你试用http://jsfiddle.net/z7muypnh/2/

的小提琴

1 个答案:

答案 0 :(得分:1)

数据太小而无法看到。您想要将范围(-5500,3000)中的条形绘制到条形图中,其高度默认为400px。如果要查看小数据,可以更改轴y高度或工具提示中的组数据。我选择最后一个。查看jsfiddle

 tooltip: {             
    grouped: true,
    format: d3.format('.2f')
 }

如果您不想将工具提示设置为分组,则只能在下方设置轴y高度,请参阅jsfiddle

 size:{
    height:(3000- -5000)
 }