score:1
the idea behind using highchart stockchart is it uses x-axis label as timestamp.
solution to "how can i make my x-axes to use my own timestamp api data? " should be converting data[i].timestamp by parsing to real timestamp and create nested array of 'accelero_x' and pass that array to series data.
highcharts.getjson('https://gmlews.com/api/data', function (data) {
console.log(data);
var accelero_x = [], timestamp = [];
for (var i=0; i<data.length; i++){
//modification start -----
let inarr = [];
let trimdate = data[i].timestamp.split('t')[0]; // here we have many ways to extract only the date correctly
inarr.push(date.parse(trimdate));
inarr.push(data[i].accelero_x);
accelero_x.push(inarr);
//modification end -----
timestamp.push(data[i].timestamp);
}
console.log(accelero_x);
console.log(timestamp);
// create the chart
highcharts.stockchart('container', {
rangeselector: {
selected: 1
},
title: {
text: 'accelero x'
},
series: [{
name: 'accelero x',
data: accelero_x,
type: 'spline',
tooltip: {
valuedecimals: 2
}
}]
});
});
score:0
here is an api options how to set the range selections options: https://api.highcharts.com/highstock/rangeselector.buttons
your second part of the question - highcharts requires data in the following formats:
array of values - like:
[10,20,30,40]
- highcharts reads it as an array of y values and set default x values -1, 2, 3, 4
array of arrays - like:
[[3, 24], [5, 42], [8,33]]
- where first value in the array is an x and the second one is the y -[x, y]
array of objects - like:
[{x: 3, y: 24}, {x: 5, y: 42}]
- here is quite obvious
the xaxis could be a datatime type, where x value is a value in milliseconds format, that's mean you will need to convert your data into the milisecond value to set it, like here: https://jsfiddle.net/blacklabel/w9hznsey/
Source: stackoverflow.com
Related Query
- How to replace x-axes with our own timestamp data from API in Highcharts using highstocks
- How to use highcharts in reactjs with fetched data from API
- How to make multiple Y-axis with incoming series of data from database using Highcharts
- How to populate a Highcharts axis with string formatted data from a PHP array
- How to hardcode chart data in my Model then have my Controller pull it from there to display it. Using Highcharts
- highcharts example for using data from database with mvc
- How to specify a range of data when using HighCharts with <table>?
- How to make a chart with highcharts, load data from API
- How to display historical data and live data from database using Highcharts
- How to have multiple highcharts with different series data in vuejs without repeating code
- Refresh Highcharts with data from AJAX using Handlebars
- Highcharts Highstock How to Plot OHLC and Line Charts from One Set of Embedded CSV Data Using Series Map Tools?
- How to return every nth row from dataset using postgresql to control a Highcharts data series
- How to scrape data from Highcharts charts using selenium and python?
- how to make chart real time with 2 line and get data from php with highcharts
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- How to draw scatter chart with highcharts using timeseries data
- Using highcharts to display data from an API
- Dynamic chart using Highcharts with data from MySQL database
- How to query data from database using highcharts in Codeigniter?
- how to display the highchart data with data serialize from a form using button onclick?
- Highcharts with data from table, how to add custom marker for specific value from specific series?
- How do I dynamically change a data point in Highcharts using JavaScript
- How to prevent highcharts from shortening labels with ellipsis
- Scraping data from Highcharts using selenium
- Highcharts Angular with API data
- How to structure Angular with Highcharts and lots of dynamic data
- Add dynamic data to line chart from mysql database with highcharts
- How get data name in Highcharts pie chart legend instead of "Slice" using array of values?
- How can i change highcharts data values by selecting from a dropdown list
More Query from same tag
- Is there a way to scale the custom marker of a high charts scatter chart?
- How can I show vertical line in highchart as shown in below image?
- Highchart line renders bigger when exported to pdf using css2pdf
- Fixed y-axis label width in Highcharts
- How to make Highcharts to use all the colours when replotting? (it is repeating colours unnecessarily)
- Controlling Highcharts bar chart look and layout
- Why code of Horizonal line(y-axis) on a single in Highcharts get applied to all other charts integrated with Webdatarocks
- Error using Highcharts (>= 8.0.1) function stockChart() in Angular
- Add label to line in Highcharts
- highcharts line-ajax example/demo
- high-chart not showing date and time in xaxis
- Loading Highcharts from MySQL using Java
- Highcharts - colorByPoint does not work
- Highcharts distorsion
- Highcharts: Flush chart against the sides
- Highcharts - Highlight / Shade date range
- Highcharts - what is it about my data that causes "setExtremes" to not work correctly?
- extra tooltip for displaying yAxis values on right side
- Highcharts legend js error
- Remove Highcharts chart Y axis labels when legend clicked
- How do I add json data to custom flags in Highstock?
- Own Tooltip highchart
- How to add mean line in a boxplot made with highcharter?
- Is it possible to turn boost mode in highcharts only when client's browser starts to jank?
- Highchart Absolute Percentage Stacked Area
- JSON-Object as string: Use of concat(), eval() and/or JSON.parse()?
- How to add opacity in spline chart
- Highchart only wants "y" element in JSON data?
- Highstock - Group X axis plugin BlackLabel not working on highstocks library (highcharts)
- How can i use Highstock rangeSelector get the yAxis Max_value and Min_Value