Reputation: 312
I am trying to create something like this resizable HighChart.
The difference is that i am loading my data from a blob.
This is the graph that i receive:
This is part of the received data, from the console.log(lines);:
[{ date: '7/13/2016 8:35:00 AM', value: 60 },{ date: '7/13/2016 8:36:00 AM', value: 45 },...]
This is my code: https://jsfiddle.net/end5xc7m/
series: [{
turboThreshold: 20000,
type: 'area',
name: 'Values to date',
data: data}
I believe this is where i am getting the problem from, in the function visitorData.
I am not having the data projected onto the graph.
Upvotes: 0
Views: 70
Reputation: 3554
As jlbriggs noted, this is due to a formatting issue. Unless you you're using categories to plot your axes, Highcharts visualizations will not draw if data are input as strings.
I've updated your fiddle with a few fixes: https://jsfiddle.net/brightmatrix/end5xc7m/2/
function processData(allText) {
var allTextLines = allText.split(/\r?\n/);
var lines = [];
for (var i = 0; i < allTextLines.length - 1; i++) {
var currentLine = allTextLines[i].split(',');
var thisLineValue = [Date.parse(currentLine[0]),parseInt(currentLine[1])];
lines.push(thisLineValue);
}
return lines;
}
Here's what I changed:
[x,y]
, where these variables are either dates or numbers. Building the values using curly braces and +
concatenation operators turns these into strings. So, instead, I created a temporary array called thisLineValue
and pushed that to your lines
array.Date.parse()
to turn your date values into timestamps. This is happily understood by Highcharts for datetime
axes, as you set with your x-axis.parseInt()
to avoid those values being turned into strings as well.toString()
function when you return the lines
array to the chart. Again, this keeps the values in the format the chart is expecting (dates and numbers).I hope this is helpful for you!
Upvotes: 2