Add Points to VictoryLine Chart by Combining with Scatter Plot 🥳

Omar Shishani
2 min readJan 12, 2021

--

Boats in archipelago.

When using VictoryCharts, it doesn’t seem to be possible to add points to the line chart — however we can add a scatter plot, VictoryScatter, beside VictoryLine, and simply pass in the same data! That will give us the points we desire.

Below is an example of code for the line chart with and without the scatter:

Code for just the line graph:

<VictoryChart
theme={VictoryTheme.material}
scale={{y:'time'}}
domainPadding={{ x: 20, y: 20 }}
>
{/* ONLY VICTORY LINE */}
<VictoryLine
data={data}
/>
</VictoryChart>

Only line graph:

Line graph.

Code for scatter and line graphs together:

<VictoryChart
theme={VictoryTheme.material}
scale={{y:'time'}}
domainPadding={{ x: 20, y: 20 }}
>
{/* ADD VICTORY SCATTER */}
<VictoryLine
data={data}
/>
<VictoryScatter
style={{ data: { fill: "#c43a31" } }}
size={7}
data={data}
/>
</VictoryChart>

Scatter and line graph:

Line graph.

I Googled around this several times, and it took me a while to think of this idea on my own, so I thought it would be useful to add this short post to the potential search engine results.

Girl in hammock.

Boats in Archapelago by Karl Paul Baldacchino on Unsplash

Girl in Hammock by Ida Marie Dyrøy on Unsplash

--

--

Omar Shishani
Omar Shishani

Written by Omar Shishani

Hi! I am a React developer who loves technology and learning new things in all different fields. https://omarshishani.com

No responses yet