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 Horizontal Lines #636

Open
bytemtek opened this issue Oct 1, 2022 · 6 comments
Open

Custom Horizontal Lines #636

bytemtek opened this issue Oct 1, 2022 · 6 comments

Comments

@bytemtek
Copy link

bytemtek commented Oct 1, 2022

Hello,

I'm coding stock chart and I need draw same horizontal lines on chart.

How can I add a horizontal line to position which I want in my chart?

Thanks

@sushil-appstudio
Copy link

any solutions?

@waqaramjad
Copy link

Any Update?

@deepsharma370
Copy link

Any Update on this ?

@geneshairzan
Copy link

any update?

@geneshairzan
Copy link

#584

cekin on it, but seems i cannot implement it yet.

@geneshairzan
Copy link

geneshairzan commented Jun 5, 2024

find way arround using decorator

import React from 'react';
import { View, Text } from 'react-native';
import { LineChart } from 'react-native-chart-kit';
import { Dimensions } from 'react-native';
import { Svg, Line } from 'react-native-svg';

const CustomLineChart = () => {
  const screenWidth = Dimensions.get('window').width;

  const data = {
    labels: ["January", "February", "March", "April", "May", "June"],
    datasets: [
      {
        data: [20, 45, 28, 80, 99, 43],
        strokeWidth: 2,
      },
    ],
  };

  const customDecorator = () => {
    return (
      <Svg>
        <Line
          x1="0"
          y1="50"
          x2={screenWidth}
          y2="50"
          stroke="red"
          strokeWidth="2"
        />
      </Svg>
    );
  };

  return (
    <View>
      <Text>Custom Horizontal Line Chart</Text>
      <LineChart
        data={data}
        width={screenWidth}
        height={220}
        chartConfig={{
          backgroundGradientFrom: "#fff",
          backgroundGradientTo: "#fff",
          color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
        }}
        decorator={customDecorator}
      />
    </View>
  );
};

export default CustomLineChart;

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

5 participants