componentDidMount() {
Plotly.d3.json("./data/energydata.json", function (err, rows) {
var trace = {
type: 'scatter', // set the chart type
mode: 'lines',
x: [rows[0].time],
y: [rows[0].energy],
line: { // set the width of the line.
width: 1
},
};
var layout = {
height: 600,
width: 1280,
yaxis: {title: "Energy Data"}, // set the y axis title
xaxis: {
showgrid: false, // remove the x-axis grid lines
tickformat: "%B, %Y" // customize the date format to "month, day"
},
margin: { // update the left, bottom, right, top margin
l: 40, b: 30, r: 10, t: 30
}
};
Plotly.newPlot(document.getElementById('energy-plot'), [trace], layout, {showLink: false});
});
}
Error is : SyntaxError: Unexpected token < in JSON at position
Uncaught TypeEror: Cannot read property ‘0’ of undefined?