I am trying to display a scatterplot from a variable called data.
data should contain the x and y values for the scatterplot. The method below is what I am attempting to do to insert the x and y values, however the graph is showing up blank.
let data = []
for(var i = 0; i < sixth_x.length; ++i){
data.push({xField: sixth_x[i], yField: sixth_y[i]})
}
x is a string, and y is a number.
This is my method to display the graph
<ChartSeriesItem type="scatter" data={data} xField="sixth_x"
yField="sixth_y"/>
</ChartSeries>
ChartSeriesItem xField and yField expect property name of source array object. In your case source array object is {xField: <some string>, yField: <some number>}.
So you should pass these property names (xField, yField) to your props.
<ChartSeriesItem type="scatter" data={data} xField="xField" yField="yField"/></ChartSeries>
which looks strange.
I recommend rename properties to identify what exactly your chart about, ex. price growing per year chart, so you will do something like this
data.push({price: sixth_x[i], year: sixth_y[i]})
and <ChartSeriesItem type="scatter" data={data} xField="price" yField="year"/></ChartSeries>
I think you get the idea.