score:11
Try:
fillColor: a==1 ? "#ff0000" : "#00ff00"
etc.
score:0
I was working on something like this and I thought I would update this post with a 2021 response. Turns out with Highcharts you have to feed in an array into data, but it can be an array of objects that have parameters associated with the point. I was attempting to make the point fill to be on a different scale than the y axis see below:
tempScale(value: any) {
if(value > 32) {
return 'red'
}
else if(value > 31) {
return 'orange'
}
else if(value > 30) {
return 'yellow'
}
else if(value > 28) {
return 'green'
}
else if(value > 27) {
return 'blue'
}
else {
return '#99ffff'
}
}
I ended up finding this codepen where is shows an example on how you can feed in an array of objects and use the keys y, color, marker, and radius to feed attributes to each item in the array.
{
y: 9,
color: 'green',
marker: {
radius: 10
}
}
I ended up combining the 2 and calculating out the color for each of them before they were pushed into the array and it worked great for my purposes.
array.push({
y: item.attributes.Sal,
color: this.tempScale(item.attributes.Temp),
marker: {
lineWidth: 1,
lineColor: 'black',
}
})
score:1
Expanding upon Asad Saeeduddin's answer:
I am using dataLabels in a doughnut pie chart and the proposed solution was very specific to a singular situation. I wanted to change the label text colors for individual pie slices, based on conditional logic, comparing values.
Just sharing because my search brought me here.
data: outerData,
dataLabels: {
formatter:
function () {
if ((outerData[this.point.x].y > innerData[this.point.x].y) && (this.point.x != 0)) {
return this.y > 0.1 ? '<span style="fill: red;">' + this.point.name + ': ' + this.y + '% ' + '</span>' : null;
} else {
return this.y > 0.1 ? '<span style="fill: #006400;">' + this.point.name + ': ' + this.y + '% ' + '</span>' : null;
}
}
}
score:3
How about removing the logic from your chart and use it only to display data?
var a = 1,
color = a ? 'red' : 'green';
plotOptions: {
series: {
marker: {
fillColor: color,
lineWidth: 2,
}
}
}
score:6
You also use zones:
$(function () {
$('#container').highcharts({
series: [{
data: [-10, -5, 0, 5, 10, 15, 10, 10, 5, 0, -5],
zones: [
{
value: 0,
color: '#f7a35c'
},
{
color: '#90ed7d'
}
]
}]
});
});
Source: stackoverflow.com
Related Query
- conditional marker colors in highcharts
- Conditional coloring of marker in box plot in highcharts
- Conditional Highcharts Marker Symbol Using Javascript
- Highcharts add a legend for marker colors
- HighCharts : Is it possible to customize the colors of individual series?
- set different colors for each column in highcharts
- How can I change the colors of my highcharts piechart?
- Styling bar colors in Highcharts with a gradient issue
- Highcharts Area graph, use 2 fill colors above / below X axis
- highcharts - disable fading series on marker hover
- Customizing the colors of individual series in HighCharts
- Highcharts - How to set custom colors for the series
- Flexdashboards and Leaflet and marker click with Highcharts
- How do I set highcharts line graph point colors to an array of colors?
- Dynamically draw marker on last point in highcharts
- highcharts different colors for selected columns
- highcharts heatmap : arbitrarily set cell colors
- Color contrast setting on dataLabels style parameter using Highcharts 5 is not working on some colors
- Update Chart Colors When Using Styled HighCharts Version
- Increase different marker sizes when hovering series using highcharts
- Using PhantomJS to create HighCharts grahps server side for use in PDF creation (PHP) - results in exit code 11 from PHPs exec();
- How to remove the halo/glow around a marker upon hovering a series in Highcharts
- Highcharts - Global configuration with common code and unique data & Headings
- How to add background colors to category groupings in Highcharts
- Need to make tooltip border color same as marker color using Highcharts
- R Highcharter: Polar graph having conditional colors
- HighCharts Custom SVG Marker Symbol
- HighCharts area graph - show tooltip only on hover of marker
- Highcharts - How do I dynamically change Marker radius when zooming?
- Highcharts - Remove first marker from Area chart in every series
More Query from same tag
- Add more charts in angular highcharts
- How to add two dataLabels to a bar chart using HightCharts
- Connect limit's series in Highcharts
- Highcharts with decrease order in each interval
- How to show highchart graph depends on select tag from HTML
- How to create a row isolated heatmap with Highcharts
- DotnetHighCharts does not show negative values?
- Position single data label of highcharts pie chart centered below the chart
- Highcarts: Hide xAxis categorie when serie is not visible
- How to retrieve/display title, units, copyright along with JSON data in Highcharts
- Scraping data from Highcharts using selenium
- Highchart x-axis hide only values greater than 100
- Highchart group chart points with same date
- highcharts - changing color of area depending on y-value
- Own back button for drilldown charts
- Highchart issue when added into bootstrap carousel
- Highcharts Treemap
- highcharts line not showing properly
- jQuery slider range with HighCharts y-Axis
- How do I not show GMT and Timezone labels for Highcharts
- plot bands in x-axis is not working on time
- Highchart Funnel for Angular
- calculate the difference between 2 series in tooltip for highstock
- Highcharts with angularjs without jquery
- One genral inquisitiveness about highcharts:
- Not able to render windbarb Highchart in angular
- highchart 3d column - show "beta axis title" and "beta axis label"
- Highcharts missing first date label on xAxis
- Highcharts show blank colum with text
- Angular 2 Typescript Highcharts Highmap mouse wheel scroll