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

Drawing a mixed bar/line and having the bars span across an axis #6733

Closed
UglyHobbitFeet opened this issue Nov 12, 2019 · 14 comments
Closed

Comments

@UglyHobbitFeet
Copy link

UglyHobbitFeet commented Nov 12, 2019

I've looked at the docs/examples for chartjs, but is there any support for the following?

  • Create bars where the width (x-axis) is variable but the height is always full (aka the entire y-axis)?
  • There can be x number of those bars in a chart
  • Create a line that spans all the way across the x axis but can change it's y-axis (aka not a straight line, but a curvy one).

I have a crude drawing here where the yellow is the bars and the black is the line

I kinda got the first part down using stacked bars and swapping the axis, but the y-axis (the bars height) is only set to 1. That's a problem when trying to draw a curved line in mixed mode since there is only one y-axis point (instead of many y-axis points):

Here's another attempt that has multiple y-axis points, but I cannot control the bar widths:

A third attempt is here, but I need a border around the overall bar (instead of each mini-bar that comprises it) as well as no gaps between the mini-bars.

@benmccann
Copy link
Contributor

That's a problem when trying to draw a curved line in mixed mode since there is only one y-axis point (instead of many y-axis points)

Maybe try using two y axes?

@UglyHobbitFeet
Copy link
Author

Hi, thanks. I'm not exactly sure what you mean. How do I go about doing that?

@UglyHobbitFeet
Copy link
Author

UglyHobbitFeet commented Nov 13, 2019 via email

@kurkle
Copy link
Member

kurkle commented Nov 13, 2019

Ben means something like that: https://codepen.io/kurkle/pen/pooOBKQ?editors=1010

@UglyHobbitFeet
Copy link
Author

UglyHobbitFeet commented Nov 13, 2019 via email

@benmccann
Copy link
Contributor

I thought I read that mixed line/horizontal stacked bar don't play together well

I'm not aware of any such issues

@UglyHobbitFeet
Copy link
Author

UglyHobbitFeet commented Nov 13, 2019 via email

@benmccann
Copy link
Contributor

There's an example of a horizontal line chart later on in that discussion though: #4096 (comment)

@kurkle
Copy link
Member

kurkle commented Nov 13, 2019

You can use new the new floating bars feature too: https://codepen.io/kurkle/pen/ExxdyXQ

@UglyHobbitFeet
Copy link
Author

UglyHobbitFeet commented Nov 14, 2019 via email

@kurkle
Copy link
Member

kurkle commented Nov 14, 2019

Float bars are configured as [start, end]
So for example if "normal" bar is data: [1, 2, 3], float bar is data: [[1,2], [3,4], [5,6]]
(pay attention only in the format, not the values)

@benmccann
Copy link
Contributor

@kurkle
Copy link
Member

kurkle commented Jan 15, 2020

Closing as resolved

@kurkle kurkle closed this as completed Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants