Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time series graph, overlapping bars #1386

Open
vishal-kony opened this issue Sep 18, 2015 · 14 comments
Open

Time series graph, overlapping bars #1386

vishal-kony opened this issue Sep 18, 2015 · 14 comments
Labels
C-bug Category: This is a bug

Comments

@vishal-kony
Copy link

Why the bars of my timeseries graph are overlapping?

2015-09-18_1208

here's my code..

var chart = c3.generate({
bindto: '#chart',
data: {
x: 'date',
xFormat: '%m/%d/%y %I:%M %p',
json: final_data,
keys: {
x: 'date',
value: values
},
type: 'bar',
groups: val
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%b %d',
centered: true,
fit: true
}
}
},
zoom: {
enabled: true
},
color: {
pattern: colors
}
});

@panthony
Copy link
Contributor

Very likely a duplicate of #1329

@Codewolf
Copy link

Sorry to resurrect a dead (albeit open) ticket, but is there any update on this as is still an issue on the latest stable version (c3 0.4.15)
image

@panthony
Copy link
Contributor

@Codewolf I don't think so, a work around is to fill the gaps with null values.

@Codewolf
Copy link

so, to clarify: i would need to programmatically (either client or server side) identify the bounds (datetime upper and lower) and manually fill in any date gaps with a 'null' or '0' value?

Surely that would then display the dates with a value of 0 which isn't correct as nothing (value wise) actually happened on those dates?

@panthony
Copy link
Contributor

panthony commented Jul 28, 2017

Yes, find the bounds and fill the gaps with either null or 0 depending on what you are displaying, 0 does not always means null.

Before:
https://jsfiddle.net/mcd6ucge/31/

After:
https://jsfiddle.net/mcd6ucge/306/

Note that if you fill with 'null', yes the date is displayed on X axis, but no, they are not displayed with a value of 0, there is nothing on hover for this date.

@Codewolf
Copy link

I see, the main issue with this is if a large date range is created (for example 1 year) and only a few of those dates have values i would end up with a (mostly) empty graph and unreadable dates on the X axis coupled with very thin (~1 or 2 px depending on graph width) bars.

@panthony
Copy link
Contributor

Regardless of this bug, the date seems to be evenly distributed on the X axis so it would not be any different. You would still have large empty space between each bars.

With a lot of date, not all ticks have a date displayed, I'm using this workaround and here is an exemple:

capture d ecran 2017-07-28 a 11 13 29

If you do not care about an evenly distributed serie, maybe you could simply use a "category" x axis instead of a timeseries.

@Codewolf
Copy link

Do we know roughly around what line or function the 'timeseries' type calculations are made?

If so i could possibly look into the spacing issues etc as part of the development cycle for my current project.

@panthony
Copy link
Contributor

It's been too long since I dived into c3js code I can't help you on that :)

@rkrabek
Copy link

rkrabek commented Aug 2, 2017

@Codewolf It looks like the bar width is calculated in the function getBarW on line 53 of shape.bar.js

It seems to work properly if it is a category chart instead of a timeseries chart (In my use case I don't need the ticks to fit to the data so axis.x.tick.fit = false for me) and the difference between the two is the value returned by axis.tickInterval() on line 293 of c3.axis.js. tickInterval does a calculation with tickOffset if it's a category chart else it calculates tickInterval with this:

length = axis.g.select('path.domain').node().getTotalLength() - outerTickSize * 2;
interval = length / axis.g.selectAll('line').size();

@fullofcaffeine
Copy link

Any news here? I'm facing the same issue.

@Codewolf
Copy link

Codewolf commented Jun 6, 2018

@fullofcaffeine i moved positions to a backend position so havent been able to keep track of this issue, but by the looks of the messages @rgbkrk commited a fix on 14th March. It may be worth downloading his patch.

@Benji81
Copy link

Benji81 commented Jan 6, 2019

Still the issue in 0.6.12 (timeseries with gapes in data).

@rgoupil
Copy link

rgoupil commented Jun 25, 2020

Bump, the issue persists for us in 0.7.18 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

8 participants