c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Bar Chart issues

Open CHR15- opened this issue 12 years ago • 15 comments

Putting several columns into a bar chart, the bars do not fit onto one timestamp and spread across others. Here is an example.

screen shot 2014-02-26 at 17 28 07

is there a possibility of taking the columns of data and dividing them to get the appropriate width?

The same data works fine for the line graph..

screen shot 2014-02-26 at 17 37 23

Do I have to change the x axis to categories for them to bunch correctly on the x-axis?

Furthermore, there seems to be an issue with the stacked bar chart:

screen shot 2014-02-26 at 17 39 22

As you can see, 'employers-national-insurance' is only 2154 but appears above 'salaries' which is 25188. 'Accounts-Recievable' is correct but 'employers-national-insurance' should be below 'salaries'

CHR15- avatar Feb 26 '14 17:02 CHR15-

Hi,

The first issue is a bug. I'll fix to have correct width and position. And the second is not a bug. Currently bars will be stacked according to the order of data, not of the values. However, I think the order should be configurable, so I'll add some option or api.

masayuki0812 avatar Feb 27 '14 07:02 masayuki0812

I fixed the first issue.

masayuki0812 avatar Feb 27 '14 10:02 masayuki0812

could you update the JSON file for the version?

CHR15- avatar Feb 27 '14 10:02 CHR15-

Yes, I updated.

masayuki0812 avatar Feb 27 '14 10:02 masayuki0812

first issue confirmed fix, great work!

CHR15- avatar Feb 27 '14 12:02 CHR15-

Hi,

I added data.order option. This option can be used to change the order of stacking of bars. I think you can do what you wrote above by setting this option 'desc'. If you set 'desc', bars will be stacked from one that has minimum sum of its values. Here is sample - http://c3js.org/samples/data_order.html

Could you try this?

masayuki0812 avatar Feb 28 '14 12:02 masayuki0812

Thats perfect,

Thanks Masayuki!

CHR15- avatar Feb 28 '14 14:02 CHR15-

Think I have discovered an issue with the same values?

screen shot 2014-02-28 at 14 39 26

As you can see, it adds it to the to if it is the same, making it an incorrect measurement against the Y axis

CHR15- avatar Feb 28 '14 14:02 CHR15-

screen shot 2014-02-28 at 14 45 12

Perhaps it may be a better to split the bars in two and place them next to each other if they have the same values in the stack?

CHR15- avatar Feb 28 '14 14:02 CHR15-

The image above also shows that two data sources have been assigned the same colour!

CHR15- avatar Feb 28 '14 14:02 CHR15-

Hi,

You mean the order in chart and the order in tooltip is different?

And I think It may be better not to split bars because height will not show the sum of values and so it's not natural as stacked bar chart I think.

About color, c3 gives 10 colors to each data as default (it's d3.scale.category10()). If the number of data is over 10 and same color should be avoided, color.patterns should be used, like: color.patterns = ['#333', #'999', ...]

masayuki0812 avatar Mar 01 '14 00:03 masayuki0812

awesome, thanks

CHR15- avatar Mar 04 '14 10:03 CHR15-

A colour example on c3 would be cool btw!

CHR15- avatar Mar 13 '14 11:03 CHR15-

Believe it may be:

color: { pattern: ['#111', '#222', '#333', '#D35400'...] },

CHR15- avatar Mar 13 '14 11:03 CHR15-

Hi, I added a sample for color.pattern option - http://c3js.org/samples/options_color.html Could you try this? Thank you.

masayuki0812 avatar Mar 13 '14 12:03 masayuki0812