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

Chart with data left Line and data right Barchart #392

Closed
ducsilva opened this issue Sep 19, 2023 · 2 comments
Closed

Chart with data left Line and data right Barchart #392

ducsilva opened this issue Sep 19, 2023 · 2 comments

Comments

@ducsilva
Copy link

Describe the isssue

I want to show my chart with LineChart data left and Bar chart with data right as below image. Have you any idea for this?

To ReproduceScreenshot 2023-09-19 at 10 26 12Steps to reproduce the

@Abhinandan-Kushwaha
Copy link
Owner

Hi @ducsilva 👋
Thanks for requesting this feature. It is now implemented in the latest version of the library. Please use version 1.3.8 of react-native-gifted-charts

I have added support for a new property named isSecondary in the lineConfig object. Setting isSecondary to true results in making the line correspond to the secondary Y axis.

Here's an example-

Screenshot 2023-09-20 at 3 54 57 AM

The code for the above chart is-

const data = [10, 20, 30, 20, 15, 12];
const lineData = [12, 5, 8, 15, 8, 10];

return (
  <View style={{backgroundColor: 'black'}}>
    <BarChart
      data={data.map(i => {
        return {value: i};
      })}
      showGradient
      frontColor={'#8BC9CB'}
      gradientColor={'#07A0A3'}
      barBorderTopLeftRadius={4}
      barBorderTopRightRadius={4}
      hideRules
      yAxisColor={'gray'}
      xAxisColor={'gray'}
      yAxisTextStyle={{color: 'gray'}}
      secondaryYAxis={{
        yAxisLabelPrefix:'$'
      }}
      showLine
      lineData={lineData.map(i => {
        return {value: i};
      })}
      lineConfig={{
        thickness: 4,
        color: 'yellow',
        hideDataPoints: true,
        isSecondary: true, // this is the newly added property
      }}
    />
  </View>
);

@ducsilva
Copy link
Author

thank you for your support. It's very helpful for me! I resolved this issue. Your library is so very good

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