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

Custom chart horizontal stack #620

Open
L2Develop96 opened this issue May 2, 2024 · 0 comments
Open

Custom chart horizontal stack #620

L2Develop96 opened this issue May 2, 2024 · 0 comments

Comments

@L2Develop96
Copy link

Hello,
Is there anyway to get something like this ?
image

I came with an approach to show something similar to it with the following:

const RenderBarChartStackText = (value: number): React.JSX.Element => {
  const { layout, fonts } = useTheme();
  return (
    <View style={[layout.fullHeight, layout.justifyCenter, layout.itemsCenter]}>
      <BaseText style={[layout.rotate90Inverse, fonts.white, fonts.size_11]}>
        {value}%
      </BaseText>
    </View>
  );
};

const ExpensesChart = () => {
  const { layout, gutters, fonts, colors, borders, backgrounds } = useTheme();
  return (
    <BarChart
      barWidth={35}
      showLine={false}
      showXAxisIndices={false}
      hideAxesAndRules
      noOfSections={1}
      horizontal
      barBorderRadius={10}
     stackData={[
        {
          stacks: [
            {
              value: 60,
              color: '#75B2E8',
              gradientColor: '#005AA9',
              innerBarComponent: RenderBarChartStackText(60),
            },
            {
              value: 40,
              color: '#264D7A',
              gradientColor: '#00224B',
              innerBarComponent: RenderBarChartStackText(40),
            },
            {
              value: 20,
              color: '#EA3A55',
              gradientColor: '#420109',
              innerBarComponent: RenderBarChartStackText(20),
            },
            {
              value: 20,
              color: '#ecedee',
              gradientColor: '#C7CCCF',
              innerBarComponent: RenderBarChartStackText(20),
            },
          ],
        },
      ]}
    />
  );
};` 

Here's the result

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

1 participant