indiespirit / react-native-chart-kit

📊React Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)
https://expo.io/@indiespirit/react-native-chart-kit
MIT License
2.87k stars 662 forks source link

how to change the stroke color of a selected point? react-native-chart-kit #419

Open marcelomunozr opened 4 years ago

marcelomunozr commented 4 years ago

I need to change the stroke color of a selected point. It only allows you to change the color of the point, but not the stroke.

this i did: image

this i need: image

I love this package, please help me.

react-native-chart-kit

dnlsilva commented 4 years ago

@marcelomunozr Were you able to solve the problem?

marcelomunozr commented 4 years ago

@GleidsonDaniel at the moment I have this solution ...

const [indexPuntoSeleccionado, setIndexPuntoSeleccionado] = useState(0);
const renderChart = () => {
        const white = '#ffffff';
        const primary = '#295EFF';
        return (
            <LineChart
                onDataPointClick={(info) => {
                    const {
                        index,
                    } = info;
                    console.log('IndexMarkerChart', index);
                    setIndexPuntoSeleccionado(index);
                }}
                getDotColor={(value, index) => (index === indexPuntoSeleccionado ? (white) : (primary))}
                {...OTHER_PROPS}
            />
        );
    };

if i find some way to modify the stroke i will post it, At the moment there is no other solution

azarsammie commented 3 years ago

@marcelomunozr I have a solution to let you change the stroke color to your desire design.

amit-1712 commented 2 years ago

You can use the getDotProps getDotProps={(value, index) => ({ r: '7', strokeWidth: '5', stroke: index !== selectedPoint(coming from the onDataPointClick prop) ? 'red' : 'yellow, })}