score:1
You can edit data labels style after they have been generated:
chart: {
events: {
load: function() {
var points = this.series[0].points;
points.forEach(function(point) {
if (point.y > 100) {
point.dataLabel.text.css({
'color': 'white',
'background-color': 'red'
});
}
});
}
}
}
Live demo: https://jsfiddle.net/BlackLabel/h64gjL2t/
Also, you can individually format dataLabel
for each point: https://jsfiddle.net/BlackLabel/4k8p6mfg/
series: [{
data: [{
x: 0,
y: 29.9,
dataLabels: {
backgroundColor: 'red',
color: 'white'
}
},
71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4
]
}]
API: https://api.highcharts.com/highcharts/series.line.data.dataLabels
score:0
I find a similar solution, but not clear the use of the code. In the dataLabels nod there is this "formatter" function which defines the color code based on the this.y value, so here We can do some compare of data: which one is bigger or smaller, and the function returns the color code and concatenates into a HTML span elements inline style. However, everything is work until is use the plain "color" tag, but this is for the color of the fonts. I needed to change the a background as well. So I changed the color tag to: 1. Highcharts own tag: "backgroundColor" -- nothing happens 2. HMTL back ground color tag: "background-color" -- nothing happens
:( Im feel kind of lost.
Highcharts.chart('container', {
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
color: 'blue',
formatter: function() {
var color = this.y > 100 ? 'red': 'green'
return '<span style="color: ' + color + '">' + this.y + '</span>';
}
}
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
Source: stackoverflow.com
Related Query
- Value or Logic Dependent Data Label format in Highcharts
- Highcharts align data label based on positive / negative value
- Highcharts display label for pie chart using html table as data source
- Highcharts align data label to x-axis if value is negative
- Set highcharts y-axis min value to 0, unless there is negative data
- How do I format x-axis label in highcharts
- data label is not shown Highcharts
- Highcharts data label getting cut off
- Show value of last point as label or tooltip on Highcharts Stock Chart
- Highcharts label format with tickPositioner in a datetime x Axis
- Highcharts - Data label cut off
- Highcharts - Global configuration with common code and unique data & Headings
- HighCharts Time-based Quarterly Data - xAxis Label Issue
- highcharts data labels overlaps the plotlines value
- Format Highcharts xAxis for stock data
- Highcharts show plot value on x axis label
- Highcharts Bubble Chart - How to move an individual point's data label (dataLabel) to the front/top
- Highcharts - Gauge chart data label not positioning correctly
- How to format datetime for (x,y) pair data for Highcharts
- Highcharts - set yAxis.max to max value from data
- How to format my json data for stack column chart in HighCharts
- Centering a data label in Highcharts Bar Chart
- Highcharts Solid Gauge only want to show 1 data label
- Highcharts show the same yAxis start and end value with multiple data series
- Highcharts assign label to to x-axis max value
- Exporting with custom data label image in highcharts gantt
- How to create data in Json format for highcharts
- Highcharts JSON decimal data format issue
- Change color code on colum, depending on data value (highchartJS)
- Getting data from Postgres in JSON format in ROR into a Highcharts javascript
More Query from same tag
- How To Load Plist Data On HighChart Using Objective C?
- Remove step line points
- Error Bars in High Charts: What to do when the x axis is divided into categories?
- How to draw a background behind a plotLine label in a highstock chart
- Configure Highstock export server in Play framework (java) 1.2.5
- highcharts display tooltip on category label hover
- remove inline styles from svg in highcharts
- Creating a live web app
- How to place labels on opposite Y axis in Highchart without a second series
- HighCharts - Horizontal line with the zoomed average of the values
- min-height to chart container if no data with highcharts.js
- Spline line is very curved, how to smooth it?
- Highcharts X-Axis labels as Text
- Restructuring array for Highcharts use
- Highcharts stacked bar chart comes empty
- how to pass values to tooltip which not in x and y axis in highcharts
- make highchart stacked column chart count zero value
- How to create a stacked chart with cumulative line using Highchart.js
- Hide series used for navigator in highstocks breaks navigator
- Highcharts not displaying chart from csv file
- Highcharts label behind the second series (but above the first series)
- Highstock tooltip Formatter not able to display extra data
- Highstocks not showing stock tools
- highchart in popover - bootstrap 4
- Why is Highcharts theme not working?
- Highcharts graph does not update with firebase
- cursor:pointer on Highcharts Plotband or clickable Plotband Lable
- Highcharts errorbar with corsshairs
- How can I change the color of legend points?
- plotBands Makes the plotLines Disappears highchart