score:2
Accepted answer
You can use the setExtremes
axis method to bind a dropdown event with the chart range:
var chart = Highcharts.chart('container', {
...,
xAxis: {
minRange: 0,
...
}
});
document.getElementById('selectFrom')
.addEventListener('change', function() {
chart.xAxis[0].setExtremes(Number(this.value), chart.xAxis[0].max);
});
document.getElementById('selectTo')
.addEventListener('change', function() {
chart.xAxis[0].setExtremes(chart.xAxis[0].min, Number(this.value));
});
Live demo: http://jsfiddle.net/BlackLabel/xevgsjdo/
API Reference: https://api.highcharts.com/class-reference/Highcharts.Axis#setExtremes
score:1
Parse your JSON data and use Array.prototype.filter()
For example:
// allData is your parsed JSON data
const filteredByYear = allData.filter(function(single) {
if (single["NSYEAR"] >= 2016 && single["NSYEAR"] <= 2018) {
return single;
}
});
score:1
Use filter
and also typeOf NSYEAR
is string
so you have to convert into number
:
function getFilterDataBetweenYears(fromYear, toYear) {
return data.filter(obj => {
if (+obj["NSYEAR"] >= fromYear && +obj["NSYEAR"] <= toYear) {
return obj;
}
});
}
Source: stackoverflow.com
Related Query
- How can i get the json data with the specific between Year?
- How can I work with JSON to get Bureau of Labor Statistics data into Highcharts?
- How can i get pie chart with dynamic json data in Angular js
- How can I configure the legend with a specific height in highstock?
- How to get the last 10 objects only from JSON data
- How can I switch between JSON data sets in HighMaps using setData?
- In highcharts how can I provide data with values x, y, title so that I can put the title in the tooltip?
- How can i load external json data in highcharts to show the bar chart
- How can I create a specific Json output for use with Highcharts?
- How can i set the json encode result to the highchart series data using getJSON
- How to fill the blank space between the bars with specific color in gantt chart of highcharts?
- How can I get the max value of a y axis at highcharts?
- How can I do in Highchart to have 1px space between the columns and the y Axis?
- In highcharts's stacked bar chart, how can I remove the white space between different
- How can I hide ALL series with the same ID with a button on highcharts? (line graph)
- How can I get the navigator selection from a Highstock chart?
- How can I force ticks/grid lines on a Highcharts datetime X axis to arbitrarily line up with data points?
- How to achieve the best possible performance with mutable data and real-time charts in React?
- How to fill the Area between two series with multiples yAxis in HighChart?
- How to show the json data in Pie chart HighChart?
- How can I make preset json data ready to be used in my highchart?
- With HighCharts, how can I have the same tooltip formatter as my y axis
- How can I do a padding between my highest x-value and the plot's right gap in Highcharts?
- How can I disable the Highstocks range selector buttons when loading data asynchronously?
- Highcharts: how to get the data points in the zoomed window?
- Vue js + HighChart - how can I make a synchronous axios call before the component get rendered?
- How can I make milestone lines with a GANTT chart using the highcharts library?
- How can I have both a legend and data labels, with different labels, in Highcharts?
- Issue with JSON data encoded from the server, not able to plot the chart
- Highcharts - How can I get the nearest point on click event
More Query from same tag
- Highcharts sparklines from ajax-inserted data
- HighCharts: getting access to calculated spline 'points'
- Creating charts and including them in email, a PHP lib that can render to image?
- Highchart re renders 0 values
- Is it possible in Vue JS to make several vue components reuse existing data structure with different data?
- highcharts series data[] not populating/displayed
- resizing multiple highcharts in a table
- How to add separate annotation style tooltip for Highcharts marker?
- Highcharts event handler after finishing redraw
- Parsing CSV data into JS Objects to use in chart. Uncaught ReferenceError: data is not defined(jsfiddle included)
- Highstock.js - Adding a point to the chart dynamically to a new series
- Add settings to javascript plug-gin
- Highcharts dual axes navigator
- Origin of a coordinate space
- HighStock: chart gets broken when navigator touches right border
- Multiple Boxplots in one HighCharts chart
- Highcharts : How to fix labels to the top when xAxis rotation is 90°?
- can you have more than one ajax?
- How to show the transition in highchart series graph without refreshing the html webpage?
- Highstock/Highchart cannot set Individual Point color
- Highcharts - disable hover for slices on pie chart
- creating highchart from json file
- Highchart live data gauge
- Highcharts legend position same as tooltip position or make tooltip still visible after hiden series
- Delay Loading Highcharts' Chart
- Binding empty array to chart
- Higcharts population pyramid with csv data
- Issue with closing angular ui bootstrap modal
- Custom bar chart text with Highcharts
- Highcharts solidgauge with drilldown