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

Possible to combine bar and line in same chart? #258

Closed
jannejava opened this issue May 5, 2024 · 4 comments
Closed

Possible to combine bar and line in same chart? #258

jannejava opened this issue May 5, 2024 · 4 comments

Comments

@jannejava
Copy link

Question

Is it possible to combine bars and a line in the same chart. Eg I would like to show energy consumption as bars for each day and at the same time show temperatures as a line. In this way to can see if there is a correlation.

Background Info/Attempts

Tried bar groups and also adding line to chartesian chart with no luck.

Scanned the internet and documentation for examples too.

Thanks in advance!

@zibs
Copy link
Contributor

zibs commented May 6, 2024

Hey @jannejava -- yes this should be possible if I understand you correctly. Below is a quick test I spun up using the example app inside this repo. You can provide multiple yKeys as your data to show different values if needed.

{({ points, chartBounds }) => (
            <>
              <Bar
                points={points.sales}
                chartBounds={chartBounds}
                animate={{ type: "spring" }}
              />
              <Line
                points={points.sales}
                curveType={curveType}
                color={colors.stroke!}
                strokeWidth={strokeWidth}
                animate={{ type: "spring" }}
              />
              <Scatter
                radius={scatterRadius}
                points={points.sales}
                animate={{ type: "spring" }}
                color={colors.scatter!}
              />
            </>
          )}
Screenshot 2024-05-06 at 1 22 43 PM

@jannejava
Copy link
Author

jannejava commented May 7, 2024

Thanks for the clarification, I got it!

Just a quick question. Can you have multiple y-axis with different scales if there is a significant difference in value ranges? For example if bars is between 0-150 and outside temperature (line) is between -15-20 degrees.

image

@zibs
Copy link
Contributor

zibs commented May 9, 2024

I don't think we support multiple y-axes yet sorry! Feel free to make an issue requesting that and I can tag it as an enhancement/see where it fits on the roadmap.

@zibs
Copy link
Contributor

zibs commented May 30, 2024

Closing since we addressed the initial issue!

@zibs zibs closed this as completed May 30, 2024
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

2 participants