score:1
Accepted answer
The Highchart examples show another example to setup the chart. The following format can be used:
$(document).ready(function() {
$.getJSON("myPHPFile.php", function(json) {
var series = json.map(function(record){
return [record.Year, record.Number];
})
Highcharts.chart('container', {
chart: {
renderTo: 'container',
type: 'line',
},
xAxis: {
title: {
text: 'Year'
}
},
yAxis: {
title: {
text: 'Number'
},
},
series: [{
data: series
}],
});
});
});
Checkout the live demo below:
const data = [{
"Year": 2016,
"Number": 41
}, {
"Year": 2017,
"Number": 512
}, {
"Year": 2018,
"Number": 1895
}, {
"Year": 2019,
"Number": 3132
}];
const series = data.map(record => [record.Year, record.Number])
Highcharts.chart('container', {
chart: {
renderTo: 'container',
type: 'line',
},
xAxis: {
title: {
text: 'Year'
}
},
yAxis: {
title: {
text: 'Number'
},
},
series: [{
data: series
}],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>
Source: stackoverflow.com
Related Query
- MSSQL Server to PHP Array to JSON Encode to Highcharts
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Passing data from PHP array to Highcharts chart with JSON
- Highcharts phantomjs export server can't parse json string
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- How to populate a Highcharts axis with string formatted data from a PHP array
- PHP JSON Highcharts load database result
- Highcharts Mysql Json arrays PHP
- Highcharts Mysql Json arrays PHP
- To pass dynamic json array to Highcharts Pie Chart
- Highcharts multiple series json from php
- Highcharts json php multiple series
- passing json values to highcharts from .net code behind
- passing formatting JavaScript code to HighCharts with JSON
- How to send json to highcharts from php
- Simple, Open source PHP wrapper for Highcharts library
- Yii2 How to pass php array data into highcharts
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- Multidimensional JSON to javascript array for highcharts
- Php 2D array into javascript array in highcharts
- Highcharts add several series with PHP array
- How do you correctly encode JSON from MYSQL, ready for Highcharts
- Highcharts SVG Export from Python Server Side Code
- How to add PHP array to JS array in Highcharts
- PHP array reformat to highchart json ob
- PHP array to correct json format
- Needing to convert JSON Object to JSON Array for Highcharts
- If Array is Empty PHP - Highcharts
- Run Highcharts on Server side code to add to Word document
- HighCharts Bubble graph JSON as data source
More Query from same tag
- Highcharts fadeIn produces plots larger than containers
- Highcharts overlapping and stacked column
- rCharts different sizes for the two graphs in Shiny App
- Export Jquery chart to csv,pdf and excel
- JS Gauge with growing arc
- Highcharts Pie Chart from Ajax
- why I am getting undefined value in angular js
- How do I redesign this highchart
- how to custom heatmap cell with padding?
- How do you set up an array to hold '0's for empty locations so graphs(Highcharts) can format them correctly?
- Highcharts - set column width dynamically
- Plot one point on Highcharts JS graph according to x-axis?
- Change marker line color in highstocks
- Horizontal Scrollbar for highcharts, NOT Highstock
- Highmaps label centering in irregular path
- HighCharts - HighStock - Show Date for Candlestick & Volume
- How to position a Highcharts title on the right of the chart?
- How to rotate first and last x-axis label in Highcharts chart?
- Highcharts I've lost my drilldown scrollbar
- setExtremes Event not working post setExtremes method call
- Highcharts json php multiple series
- Preserving jQuery dependency for highcharts with requireJS optimizer
- highstocks, how can I bring values that I will only use on the 'click' option?
- Custom color & tooltip for a single bar in Highcharts histogram
- primefaces chart x axis
- Getting information from one Rails server to Another
- Highcharts pie on legenditemclick avoid slicing of pie but show animation on legend item
- Adding data points in Highcharts
- How to suppress the bullet point and series name in Highmaps' tooltip?
- Bigger chart with highcharts