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

Allow linear (continuous) type in bar charts x axis #8233

Closed
joanapaulaso opened this issue Dec 26, 2020 · 7 comments
Closed

Allow linear (continuous) type in bar charts x axis #8233

joanapaulaso opened this issue Dec 26, 2020 · 7 comments

Comments

@joanapaulaso
Copy link

Feature Proposal

Allow linear (continuous) type in vertical bar charts x axis, by which intervals would be automatically filled, so continuous ploted data can make sense. As for now, data is treated only as categorical, also I gess temporal, on the x axis.

Feature Use Case

A lot of data traditionally ploted on bar charts use continuous data type on both x and y axes... So it would be great if Chart.js had support for this kind of data. Check out "mass spectrum" plots as exemples.

@kurkle
Copy link
Member

kurkle commented Dec 26, 2020

'category' in only the default, you are free to use other scale types.

@joanapaulaso
Copy link
Author

image

scales: { x: { type: 'linear', }, y: { type: 'linear', } }

In my data, there is a gap between 285.1301 and 430.0905 (x axis). Would you be kind and tell me why isn't it filling the axis as a continuous data type, instead of reproducing the gap from the data? What I am doing wrong? Thanks in advance.

@kurkle
Copy link
Member

kurkle commented Dec 26, 2020

I don't probably get what you are after. Area chart instead of bar?

@etimberg
Copy link
Member

@joanapaulaso if you wanted more bars, you'd need to add the data manually. Our view has generally been not to modify the data array passed into the chart and just display it directly. Are you able to create a fiddle with what you're looking for?

Another idea would be to use an area chart but with a stepped interpolation so a value was held until the next was available.

@joanapaulaso
Copy link
Author

Oh, I get it. I was looking for that in bar charts, @kurkle and @etimberg, because they are traditionally used to show mass spectrum data (which I work with). If I do that in Excel, i. e., and configure the x axis as a date type, it will give me exactly what I need (the chart on the left). On the right side is what I get for treating data as text or number ~ which is the same that I get with Chart.js... I'm sorry I can't reproduce any of this in fiddle. But I hope the image makes it clear. Any chance or way this can be implemented?

image

And here is the data used in both charts in the figure:

x y
67.019 8
68.9983 26
69.0347 26
70.0062 8
71.0139 21
72.9932 11
79.9906 11
82.0061 64
91.019 194
92.0268 258
93.0346 20
95.0139 977
97.0294 15
106.0061 50
121.0296 54
123.0088 124
136.0166 80
151.0402 12

@etimberg
Copy link
Member

This is close to the left picture. https://jsfiddle.net/ob0xc5u7/

@joanapaulaso
Copy link
Author

Wonderful! That's it! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants