score:60
When you add the value to the series.data you can also set the color using the point options e.g
series.data.push({ y: parseInt(Data[i]), color: '#FF0000' });
For more details about the point options see https://api.highcharts.com/class-reference/Highcharts.Point#color
score:0
i had colors from API response and 2 series. second series with dynamic colors.
following is sample to set dynamic colors while series mapping.
const response = [{
'id': 1,
'name': 'Mango',
'color': '#83d8b6',
'stock': 12.0,
'demand': 28,
},
{
id ': 2,
'name': 'Banana',
'color': '#d7e900',
'stock': 12.0,
'demand': 28,
}
];
let chartData: {
categories: [],
series: []
};
chartData.categories = response.map(x => x.name);
chartData.series.push({
name: 'Series 1',
type: 'column',
data: response.map(x => x.demand)
});
chartData.series.push({
name: 'Series 2',
type: 'column',
data: response.map(x => ({
y: x.stock,
color: x.color // set color here dynamically
}))
});
console.log('chartData: ', chartData);
you could also read more about Highcharts series Point and Marker
score:8
Try either of these approaches:
Approach 1:
Highcharts.setOptions({ colors: ['#3B97B2', '#67BC42', '#FF56DE', '#E6D605', '#BC36FE'] });
Approach 2:
var colors = ['#3B97B2', '#67BC42', '#FF56DE', '#E6D605', '#BC36FE', '#000'];
$('#bar_chart').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: ''
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: false
}
}
},
series: [{
name: '',
colorByPoint: true,
data: [{
name: 'Blue',
y: 5.78,
color: colors[0]
}, {
name: 'Green',
y: 5.19,
color: colors[1]
}, {
name: 'Pink',
y: 32.11,
color: colors[2]
}, {
name: 'Yellow',
y: 10.04,
color: colors[3]
}, {
name: 'Purple',
y: 19.33,
color: colors[4]
}]
}]
});
score:78
Here is another solution with the latest version of Highcharts (currently 3.0).
Set the colorByPoint option to true and define the color sequence that you want.
options = {
chart: {...},
plotOptions: {
column: {
colorByPoint: true
}
},
colors: [
'#ff0000',
'#00ff00',
'#0000ff'
]
}
Here is an example based upon Highcharts Column with rotated labels demo
Source: stackoverflow.com
Related Query
- set different colors for each column in highcharts
- Set different width for each column in highcharts
- Set different colors for each column in DotNet.HighCharts
- Set a different tooltip formatter for each sunburst levels - Highcharts
- after using for loop all my column graphs are plotted in single color i need each bar in different color in highcharts
- javascript - Highcharts - Type Bar - How to set different starting for each bar
- Highcharts - How to set custom colors for the series
- Different border for selected column in highcharts
- highcharts different colors for selected columns
- Highcharts stacked column how to use different label on each category
- Legend for each point in column chart in highcharts
- Highcharts datalabel for each stacked column
- Highcharts - Different Marker for Each Point of Area Plot
- Highcharts gantt chart : Task progress indicator need to show a single task for various status like completed,inprogress etc with different colors
- Highcharts - stacked column - order series index dynamically for each category
- Set different color for each bubble in Bubble-Map
- how to show different colors for each grid line using highcharts?
- How to set column colors, title colors , font size , font family in external css file for highcharts?
- Different colors for positive/negative parts of column
- Highcharts for multiple plot lines each with a different color and show tooltip?
- Highcharts define colors for each data point in a pair
- Different xAxis label, max and colors for drilldown in Highcharts
- How To Set Different Colors For Different Plots In A Same Chart?
- Highcharts - How to set a gradient theme for each type of graph globally?
- set individual color for each bar in bar chart using highcharts
- Highcharts Theming: How to set gradient colors for certain chart types only?
- Highcharts how to make a set number of colors for pie chart data and drilldown data
- Creating a drilldown chart with Highcharts that contain double(multiple) columns for each column (see example for better explanation)
- HighCharts adding a multi-select dropdown for each column of a series
- Add a line on each bar for stacked and grouped column in HighCharts
More Query from same tag
- error TS2440: Import declaration conflicts with local declaration of 'Highcharts3d'
- How do I include scripts in my AngularJS controller?
- Highcharts problems
- Working with Charts in motion [Animating chart]
- Highcharts - Drilldown with setSize causes chart corruption
- How to match columns height with spline in Highcharts
- Pie chart legend shows empty values
- Scroll bar in Highcharts tooltip
- HighCharts Custom SVG Marker Symbol
- How to plot Highcharter side by side in RStudio Viewer?
- How to get axis's coordinates when i click on column in Highchart
- How to bring up tooltips in a line chart when the points are on the same point x
- How to create packedbubble with HighchartsReact
- Highcharts data label on last point of series not displayed
- Highcharts Angular - Highcharts Error #12
- How to avoid bad behavior zooming to areas outside the data range
- Highcharts with boost not rendering correctly at small intervals
- Highcharts - navigation by 3rd element in series 'hidden' in plot
- Highcharts fill serie's color on svg marker
- Highcharts: Selecting single series from plot with multiple series
- Highcharts setting the colour of columns in each month period
- Show custom xaxis in highchart with angular
- Javascript window.print() gives me a different output
- Drilldown in highmaps - how to remove a series
- Highcharts plotOptions.series.compare='percent' renders blank
- Highcharts Caption when verticalAlign set to 'top' margin does not work
- How to change gauge meter color based on value in highcharts
- How to position dataLabels at the midpoint of an arearange chart in highcharts?
- How to merge two Highcharts container with the same legend-item
- How to update async await function when a variable change?