score:0
Highcharts only have two types of gradients, linear and radial, so you cannot solve your problem using them. That is why I start thinking how to do it and after wasting a lot of time, I decided to implement it by dividing the chart in small slices with different colors. Then I have a donut/pie chart with 100 little slices and each one has a different color.
Gradient color degraded from 0 to 100% Gradient color degraded from 0 to 60% I am developing a react-native application, so I post you the code here:
gradientColors.js
export default ['#41E500','#44E500','#47E500','#4AE500','#4DE600','#50E601','#53E601','#56E601','#59E701','#5CE702','#5FE702','#62E702','#65E802','#68E803','#6BE803','#6EE903','#71E903','#74E904','#77E904','#7AEA04','#7DEA04','#80EA05','#83EA05','#86EB05','#89EB05','#8CEB05','#8FEC06','#92EC06','#95EC06','#98EC06','#9BED07','#9EED07','#A1ED07','#A4ED07','#A7EE08','#AAEE08','#ADEE08','#B0EE08','#B3EF09','#B6EF09','#B9EF09','#BCF009','#BFF00A','#C2F00A','#C5F00A','#C8F10A','#CBF10A','#CEF10B','#D1F10B','#D4F20B','#D7F20B','#DAF20C','#DDF30C','#E0F30C','#E3F30C','#E6F30D','#E9F40D','#ECF40D','#EFF40D','#F2F40E','#F5F50E','#F8F50E','#FBF50E','#FFF60F','#FFF60F','#FFF20E','#FFEF0E','#FFEC0D','#FFE80D','#FFE50C','#FFE20C','#FFDE0C','#FFDB0B','#FFD80B','#FFD50A','#FFD10A','#FFCE0A','#FFCB09','#FFC709','#FFC408','#FFC108','#FFBE07','#FFBA07','#FFB707','#FFB406','#FFB006','#FFAD05','#FFAA05','#FFA705','#FFA705','#FF9805','#FF8906','#FF7B06','#FF6C07','#FF5D07','#FF4F08','#FF4008','#FF3109','#FF230A','#FF230A'];
ProgressChart.js
'use strict';
const Highcharts = 'Highcharts';
import { COLORS } from '@theme';
import gradientColors from './gradientColors';
const fakeData = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
const data = [{
y: 100,
color: COLORS.dark_red,
drilldown: {
name: 'Categories',
categories: ['A', 'B', 'C', 'D', 'E', 'F'],
data: fakeData,
color: COLORS.dark_red
}
}];
const donutData = [];
const donutDataOuter = [];
const dataLen = data.length;
// Build the data arrays
for (let i = 0; i < dataLen; i += 1) {
// add data
const drillDataLen = data[i].drilldown.data.length;
for (let j = 0; j < drillDataLen; j += 1) {
if (j > 60) {
donutData.push({
y: data[i].drilldown.data[j],
color: 'white',
borderColor: 'white'
});
donutDataOuter.push({
y: data[i].drilldown.data[j],
color: 'white',
borderColor: 'white'
});
} else {
donutData.push({
y: data[i].drilldown.data[j],
color: gradientColors[j],
borderColor: gradientColors[j]
});
donutDataOuter.push({
y: data[i].drilldown.data[j],
color: gradientColors[j],
borderColor: gradientColors[j]
});
}
}
}
const donutConf = {
chart: {
type: 'pie',
animation: Highcharts.svg
},
title: {
text: 'Equipment types (%)',
align: 'center',
verticalAlign: 'middle',
floating: true,
style: {
color: COLORS.light_grey_2,
fontWeight: 'bold',
fontSize: 38
}
},
plotOptions: {
pie: {
shadow: false,
center: ['50%', '50%']
},
showCheckbox: true
},
tooltip: {
formatter() {
return '<b>' + this.series.name + '</b><br/>' +
Highcharts.numberFormat(this.y, 2) + ' %';
}
},
legend: {
enabled: true
},
exporting: {
enabled: false
},
series: [
{
name: 'Categories',
data: donutData,
size: '93%',
innerSize: '58%',
dataLabels: {
enabled: false
},
id: 'inner'
},
{
name: 'Categories2',
data: donutDataOuter,
size: '100%',
innerSize: '97%',
dataLabels: {
enabled: false
},
id: 'outer'
}],
};
export default donutConf;
I have developed it very fast. So the example code above is for the 60% chart. In my final version I won't include this dirty if-else clauses I will solve it
Then in your case I recommend you to use this webpage http://www.perbang.dk/rgbgradient/ and use the number of steps that you need. For instance you can simply chose 2 from green to blue as I show you in this image. After copying the hex codes to the gradientColors variable you will be able to solve your problem.
score:2
you can use radial gradient for highcharts, but I'm afraid you would not get the filling of color as per the value.
highcharts have provided in their documentation here that radial and linear gradients can be used with highcharts.
Source: stackoverflow.com
Related Query
- Highcharts pie donut with gradient
- Highcharts Semi Donut Pie with Negative Percentage
- highcharts issues in pie chart with gradient fill
- iOS Swift Highcharts Pie with Gradient Fill is black
- Styling bar colors in Highcharts with a gradient issue
- Highcharts connecting scatter chart and pie chart with single legend
- Highcharts Donut chart is rendered as a Pie chart in IE 8
- Highcharts - Global configuration with common code and unique data & Headings
- DotNet HighCharts , Populates a pie with the result of a query
- Highcharts pie graph with two rings filtering
- Grouping Legends in Pie Chart with Highcharts
- HighChart: Donut Pie with URL
- Highcharts - Getting a 3d effect with selected pie chart slices
- highcharts donut pie - different color for the data than its drilldown
- highcharts donut chart center text overlaps with tooltip
- Not able to draw a Pie Chart with external csv file in HighCharts
- Sweep animation with highcharts pie
- Highcharts: Only animate pie size with donut graph / prevent innersize animation
- Highcharts solidgauge with green/yellow/red gradient
- passing formatting JavaScript code to HighCharts with JSON
- Image on pie graph with highcharts
- Highcharts 3D pie with custom colors
- Highcharts - pie chart with html div at center
- Show/Update Separate Bar graphs with Drilldown Pie chart of Highcharts
- Highcharts datalabels with gradient color
- Highcharts pie rendering in conflict with legend
- Highcharts - Pie chart with negative values
- Highcharts display label for pie chart using html table as data source
- Highcharts pie with a single value in %
- HighCharts populate Pie Chart with data from SQL Database
More Query from same tag
- convert SVG to Highcharts.SVGRenderer.prototype.symbols
- Prevent JSON.parse(data) from cutting off zero digit for String floats
- Highcharts server side image generation, how to set up legend labelFormatter in callback argument
- Highstock - Pulling data from JSON file
- In highcharts how can I provide data with values x, y, title so that I can put the title in the tooltip?
- How to draw on charts?
- HighCharts HighStocks event flag is obscured by chart border
- Highcharts - CUSTOM DATA LABELS in line series, are disappearing on window resize
- Highcharts: Uncommon x axis value set at the end of the graph.
- How to proceed reactive function of dataset in Shiny - line chart R
- Highcharts - Trying to get a dyamic spline to update from left to right
- Using html2canvas to render a highcharts chart to pdf doesn't work on IE and Firefox
- Dynamically allocating Highcharts.Chart options noData
- dashStyle property is not working in angular 4
- highcharts error 14 when passing time
- How to end crosshair line where x meets y on line chart in high charts
- Highcharts doesnt work on pagination next page
- Trying to push data to a JSON array
- Highcharts data labels not showing on multiple xAxis and yAxis
- Symfony webpack "Highcharts is not defined"
- How can I force highcharts to show every x-axis label regardless of spacing constraints?
- (HighCharts) Color reverts on mouseOut after manual mouseOver
- JQuery UI Slider in Highcharts using more then one datapoint
- Marge yAxis column's cells vertically in highcharts gantt
- Tool tip formatter for donut highcharts
- Highcharts not rendering properly on legend clicks
- Understanding javascript event handling and ajax requests
- How to colorize highcharts above threshold value?
- populating highchart series by looping my query every month
- Highcharts: phantomjs export image missing labels