score:0
As i say in the comment the this
in the IIFE is the window object. If you would like to create a self structuring object out of thin air and pass it as an argument you can do like these. I am not very familiar with HighCharts but i guess the second snippet is the correct data structure in which individual points have their own color definition.
var myObj = {
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
allowPointSelect: true
}
},
series: [{
data: [1600, 3000, 400, 700, 1234, 765, 76],
color: []
}],
init: function() {
this.series[0].color = this.series[0].data.map(e => e >= 1000 ? '#75ad74' : '#FF0000');
delete this.init;
return this;
}
}.init();
console.log(myObj);
I guess this is the correct series[0].data
structure for HighCharts.
var myObj = {
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
allowPointSelect: true
}
},
series: [{
data: [1600, 3000, 400, 700, 1234, 765, 76],
}],
init: function() {
this.series[0].data = this.series[0].data.map(e => e >= 1000 ? {y: e, color: '#75ad74'}
: {y: e, color: '#FF0000'});
delete this.init;
return this;
}
}.init();
console.log(myObj);
In real application you will provide this object definition as a parameter to the highcharts
function.
Source: stackoverflow.com
Related Query
- Change color code on colum, depending on data value (highchartJS)
- Change color of bars depending on value in Highchart bar-chart with MVC3
- Highcharts Change Bar Color Based on Value
- Highcharts dynamically change bar color based on value
- change legend color high charts based on data
- highcharts: column chart color change based on value
- How to change area graph color above certain value in Highcharts
- Highcharts Change Bar Background Color Based on categories value
- change VueJS component data value from inside Highchart event
- How can I put custom color in High Charts PIE data | Slice and want to change slice text
- How to display last data point value in a tag on Y Axis in line chart of highChartjs
- highcharts change series color when data is dynamically inserted
- Update highcharts data dynamically on HTML form value change
- How to change line color when loading static csv data into Highcharts Highstock graph?
- How to change gauge meter color based on value in highcharts
- Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value
- How to change the radius of the data point dots depending on the value/count in the data-yaxis-HIGHCHARTS
- change data point value inside load event in HighCharts
- How To Change The Color of specific span of data in a chart
- Highcharts How to change align of data labels based on value
- Highcharts Highmaps How to change value for color axis in map bubble
- Highchart changing crosshair color depending on value of y-axis
- Highcharts line color based on other data than value
- Highcharts: Change spline line color according to y value
- How to change color of single column in Highcharts column graph when data is in CSV form?
- How can I change the background color of horizontal bar if date value is less than to current date?
- How to dynamically change line color based on value being lower than previous in highcharts
- Change the color of the bar chart based on the value
- how to change my pie chart color according to the value
- Yii Highchart extension - Change color based on value
More Query from same tag
- Highcharts values in one column
- Highchart from Mysql not working
- Live plot with multiple y axis in highcharts
- fail to make xAxis on Highstock chart to go before
- Highcharts, how to use gradient without setting a color?
- Highcharts: Dynamically size a solid gauge chart
- highchart line don't show line even when data points exists
- Calling Highcharts export to jpeg but the source is https and exporting is http (security warnings issued by browser)
- How to change height of ENTIRE xAxis labels using Highcharts?
- Highcharts stacked percentage area
- Highcharts error "cannot read property of undefined"
- Highchart export filename with special characters
- Highcharts: Cannot read property 'parts/Globals.js' of undefined
- How to align HTML span at center of highchart donut graph with responsive design?
- Entire Highchart API calling from JSON file
- no idea which line of code is using getPreventDefault()
- HighCharts: Tooltip for customized drawing
- Highcharts: how to get the point category clicked on when drilling down?
- Adding stacklabels to highcharts-ng
- On common x-axis how to draw a chart with different unit of dataset array (multi line chart)
- How To Reject An Element From An Array?
- Highcharts: Add a button on the chart to hide or show multiple axes
- How to use .top() method in a crossfilter group with nested values
- How do you remove x-axis labels from a highchart.js bar chart
- How to format Highcharts columnRange to get json data for temperature Min and Max
- how to pass json string to line highchart?
- HighCharts : dynamic data with drill down
- Generate highcharts from v-for not populating all graphs with data
- Highcharts Bug: Chart out of boundary
- Making a Highcharts plot with Python