-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Bar Chart y1 and y2 #4863
Comments
Some things to consider:
|
@simonbrunel @etimberg does this plan sound good to you? |
+1 that would be a great feature for us to have! |
My thoughts:
|
|
I think the first bar will define the min value, then the height (
That's the same with What I mean is that the core implementation should not be defined by some external / connotated concepts (such as the financial chart) but should stay generic and flexible. If I don't think we should support all of them but instead provide a public way to parse data, then user (or plugin or external charts) can provide their own way to read data (of course that would be implemented in another PR). |
That all makes sense to me. Not so sure about the stacked bar behavior, but I don't use that chart type, so I don't have as much insight into it and don't have strong feelings about it. |
I think
The |
I am using [x1, x2, data] right now in my timeline chart implement. I prefer to use y1 and y2 because it should work better when using time scale. |
I'm not sure Actually, instead of using named properties, why not using array as suggested by @larsnystrom? labels: [x0, x1, ...]
datasets: [{
data: [
[min, max], // eq. [start, end] or [l, h]
[min, max],
[min, max],
value, // implicit min: 0 if value > 0 or
// implicit max: 0 if value < 0
// (current implementation)
]
}]
// ... or ...
datasets: [{
data: [
{x: x0, y: [min, max]},
{x: x1, y: [min, max]},
{x: x1, y: value},
...
]
}] |
#4120 |
@dhib-dy That's not the fix for this issue. I can't remember why exactly but this definitely doesn't work for this issue because I tried it. |
We use named properties rather than arrays for the most part, so it would be a bit inconsistent to support only arrays. We have had a request for it (#4601). And in fact if we used the array notation above it would conflict with the request array notation in #4601 which put the x-value in the array I think we should probably default to named properties for consistency with the other charts for now. I think support array notation might be an issue all on its own |
I think supporting the formats @simonbrunel suggested above. datasets: [{
data: [
[min, max],
value,
]
}] datasets: [{
data: [
{ x: x, y: y },
{ x: x, y: [min, max] }
]
}] In terms of stacked bars, I'm not sure how that works. One idea is to consider two datasets, each with a
|
Any news on this feature? |
There's an open pull request implementing it: #6056 |
@benmccann, is there any ETA on when this might be merged and available in the npm package? This is basically the only hangup preventing us from being able to use chartjs for a project. |
That PR is quite close to being merged. I'd imagine it will be part of the next release (2.9.0). I don't have an estimated date for when that might happen |
@benmccann Hope it will be merged soon |
@bobalazek @marcuswindecker @hoangngk and everyone on this thread: #6056 has just been merged. Feel free to checkout master, build and test that new feature. Any feedback / bug reports will be really appreciated before we release it. |
hi, can I create this chart on X-axis with the above feature, @simonbrunel |
You can make a horizontal chart: https://www.chartjs.org/samples/latest/charts/bar/horizontal.html If you don't want space between you can make it a stacked chart: https://www.chartjs.org/samples/latest/charts/bar/stacked.html If you do want space between, then yes you'll need this floating bar feature |
...or create the spaces yourself like 52 - (5) - 177 - (5) - 58 where the bracketed spacers have transparent color. |
I am trying to build a bar chart having some data, but i want for every bar to provide its starting Y1 and its finishing Y2, is there a way to do such as the following :
The text was updated successfully, but these errors were encountered: