score:0
Accepted answer
You need to format your data to the series structure required by Highcharts. The rest of the requirements are achievable by using chart options - please check xAxis
and yAxis
properties in API.
var data = <?= $json_data?>
var series = [{
name: "temperature",
data: []
},
{
name: "humidity",
data: [],
yAxis: 1
}
];
data.forEach(function(dataEl) {
series[0].data.push([
new Date(dataEl.Timestamp).getTime(),
Number(dataEl.temperature)
]);
series[1].data.push([
new Date(dataEl.Timestamp).getTime(),
Number(dataEl.humidity)
]);
});
Highcharts.chart('container', {
series: series,
yAxis: [{
title: {
text: 'temperature'
}
},
{
title: {
text: 'humidity'
},
opposite: true
}
],
xAxis: {
type: 'datetime'
}
});
Live demo: http://jsfiddle.net/BlackLabel/aw95vek6/
API Reference: https://api.highcharts.com/highcharts/series.line.data
score:0
you can achive with below code but when you choosing chart first know the purpose and create json data accroding to the series use apexcharts for free
<script type="text/javascript">
var data=[{"Timestamp":"10:04 02/01/21","temperature":"5","humidity":"66"},{"Timestamp":"10:19 02/01/21","temperature":"6","humidity":"65"},{"Timestamp":"10:35 02/01/21","temperature":"6","humidity":"64"},{"Timestamp":"10:50 02/01/21","temperature":"6","humidity":"64"},{"Timestamp":"11:06 02/01/21","temperature":"6","humidity":"64"},{"Timestamp":"11:21 02/01/21","temperature":"7","humidity":"63"},{"Timestamp":"11:34 02/01/21","temperature":"10","humidity":"66"},{"Timestamp":"04:21 02/01/21","temperature":"15","humidity":"64"},{"Timestamp":"04:36 02/01/21","temperature":"16","humidity":"61"},{"Timestamp":"04:51 02/01/21","temperature":"15","humidity":"59"},{"Timestamp":"05:07 02/01/21","temperature":"15","humidity":"60"},{"Timestamp":"05:22 02/01/21","temperature":"14","humidity":"61"}];
console.log(data);
var timestamp=[];
var temperature=[];
var humidity=[];
$.each(data, function(i, item) {
console.log(data[i]);
timestamp.push(data[i].Timestamp);
temperature.push(data[i].temperature);
humidity.push(data[i].humidity);
});
Highcharts.chart('container', {
title: {
text: 'Solar Employment Growth by Sector, 2010-2016'
},
subtitle: {
text: 'Source: thesolarfoundation.com'
},
yAxis: {
title: {
text: 'Number of Employees'
}
},
xAxis: {
categories: timestamp,
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 2010
}
},
series: [{
name: 'temperature',
data: temperature
}, {
name: 'humidity',
data: humidity
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
Source: stackoverflow.com
Related Query
- Produce highcharts multiple line chart from JSON / MySQL data
- Add dynamic data to line chart from mysql database with highcharts
- Plotting Highcharts Chart from multiple data points in json
- Data Conversion from SQL, C# with Linq to JSON for Highcharts Line chart
- Load mysql data to Highcharts line chart using JSON
- How to generate highcharts chart from multiple local json files
- Highcharts polar chart wind rose data from JSON
- Plot Highchart multiple series line chart using JSON data
- Highcharts chart dynamic json data from sql
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- Highcharts combination chart from JSON data
- Having trouble JSON encoded data from MySQL through Highcharts
- Highcharts to display area range and line chart with data from a CSV file
- how to make chart real time with 2 line and get data from php with highcharts
- Highcharts real-time line chart with multiple data streams
- Dynamic chart using Highcharts with data from MySQL database
- Populating Highcharts chart with data received from MySQL
- create column chart in highcharts dynamically from json data
- Highchart json from mysql data not able to show up in line graph
- HighCharts pie chart X-axies values are not displayed while trying to get data from MySQL database using PHP
- Passing data from PHP array to Highcharts chart with JSON
- Highcharts displays series names but missing data points from json source
- how to create proper json data format from mysql for highcharts
- Highcharts data from Google spreadsheet show line chart for one series
- Reload chart data via JSON with Highcharts
- Send JSON data to highcharts pie from asp.net MVC controller in C#
- Highcharts with JSON data and multiple series
- Formatting JSON data monthwise for HighCharts using MySQL
- Highcharts column + line combination chart with multiple series. Issue aligning line over the column
- Highcharts bargraph from json data in angularJS
More Query from same tag
- highcharts plugin cakephp option for 3d not found
- can we create an overlapping bar chart using highcharts?
- Highcharts y-axis tick interval
- Highcharts unable to handle large amount of data?
- How to pass the another variable to the Highchart basic line which should be dynamic
- Highcharts: areasplinerange with fill color that takes account of direction of range
- Highcharts: Add Dynamic Data to xAxis Label
- How to apply a gradient to a rectangle in Highcharts
- Highcharts async multi level drill down
- How to properly set datetime as x-axis value on Highcharts(React JS)
- Highcharts add points but not to all categories
- Highcharts Datetime X-Axis invalid date
- Issue with tooltip on Highcharts with multiple series added dynamically
- how to map serial and data points using json Array
- Multi Series Highchart Data with Multidimensial Array
- Display and use time values on Highcharts
- How do I add a series to a column chart at a specific index
- highchart with numberformat (unit)
- parse file from input with papaparse
- Highstock Navigator Displayed Twice
- Control spacing and height between bars in Highcharts.js bar chart
- Highcharts: Change Highlight Color of Column Chart
- Highchart advance formatting of x-Axis datetime labels
- Highchart Treemap: forcing layout on 3 lines
- Highcharts.js: Customization of Funnel
- Bind a function with dynamic arguments to Highcharts point
- Highcharts Speedometer, dataLabel for mileage counter
- Unable to load Map Chart in Angular 7 using HighMaps 7
- how to dynamically update series data using ember-highcharts
- How to have common options for multiple y-axes in Highcharts