score:2
Please see brief mention of similar problem as highcharter github issue here.
I am using the COVID19
package to have some readily available data to use as illustration. I hypothetically set a few countries to different CFR_level
values as examples (this is just to demonstrate, they do not reflect actual case fatality rates).
With hchart
use coloredline
and multicolor_series
module, which allows for individual segmentColor
values to be used (more info and examples here on plugins and modules). Then, you can use a column for group
and a different column for segmentColor
.
In addition, I included hc_add_series
with empty data to add a custom legend.
Edit (12/24/20): If you set color
in hcaes
in hchart
you can get the tooltip hover color to match based on CFR_level
. For this example, I put the colors in hex equivalents (CFR_level
in this case is a color and not a character value).
library(tidyverse)
library(highcharter)
library(COVID19)
df <- covid19()
df$CFR_level <- "#008000"
df$CFR_level[df$id == "IND"] <- "#FFFF00"
df$CFR_level[df$id == "USA"] <- "#FF0000"
df %>%
filter(id %in% c("USA", "BRA", "RUS", "IND")) %>%
hchart(type = "coloredline",
hcaes(x = date, y = confirmed, group = id, color = CFR_level, segmentColor = CFR_level),
showInLegend = F) %>%
hc_add_series(name = "Low", color = "#008000", marker = list(symbol = "line")) %>%
hc_add_series(name = "Med", color = "#FFFF00", marker = list(symbol = "line")) %>%
hc_add_series(name = "High", color = "#FF0000", marker = list(symbol = "line")) %>%
hc_add_dependency("plugins/multicolor_series.js")
Plot
Source: stackoverflow.com
Related Query
- how to change color of line chart in highchart based on a categorical column in r?
- Highcharts - Column Chart Drilldown, how to change the drilldown bar color based on some value
- highcharts: column chart color change based on value
- How to Change Highchart Column Color Dynamicly
- how to dynamically change column chart to mirror chart using highchart
- How to change tooltip of a column chart programmatically in highchart
- How to change color of bar in column chart with different level of percentage in highcharts
- How to change rCharts Highchart Color based on Factor Variable
- Column based Highchart drilldown series assign color code to each column
- How to change color on the Highchart Sparkline line only?
- how to change the color of column in chart ?
- How to change the series color and mark after I draw the line chart in highcharts?Does it has databound event?
- How to dynamically change line color based on value being lower than previous in highcharts
- How to change default line color in highchart stock GUI tools?
- How to make drill down in stacked Column Line chart in Highchart
- How to change series legend text color in HighChart chart?
- Highcharts, How can I change the datalable distance in a pie chart based on the value
- How to set series-label to false by default and change the color of series label text in highchart
- Highcharts: Change Highlight Color of Column Chart
- How to add a horizontal line in Column bar chart in Highcharts plugin?
- In highcharts how do I change the color of the line above the categories?
- How to change color of donut chart in highchart?
- How to set border in column chart - Highchart
- How to change space value between grid and yAxis in Highcharts line chart
- How to change the background color of measure tool in stock chart in highstock?
- Change line color in area-spline chart in Highcharts
- How to Change the color of the text in donut chart
- Highcharts: how to change line color when hovering a scatterplot series
- Set series color based on X axis on a column Highchart
- How to change the color of single point in spiderweb chart
More Query from same tag
- Connecting NULL points in Highstock charts
- highcharts range lines issue
- Highcharts - Multiple charts with same object
- Highcharts use legend symbol and legend parms, not scatter marker symbols - in scatter plot
- Best performance for updating many Highcharts instances on demand
- How to fetch json array data into highcharts in angularjs
- How to show series dataLabels inside the Highchart pyramid in angular
- how to display menu from date in highchart
- HighCharts Combination Chart
- Different border radius
- How do I reset Highcharts bar color back to it's original color?
- Class 'ConsoleTVs\Charts\Facades\Charts' not found in laravel Charts
- Highcharts Area graph, use 2 fill colors above / below X axis
- How to show numbers in datalables donut highchart
- Adding gap between specific bars in a stacked bar chart
- Boosting area chart makes it looking like a bar chart
- Export Highcharts DataTable to PDF - Angular
- Line chart with x and y values
- highcharts zooming over line charts not working properly
- Rendering Mathjax in Highcharts
- Highchart heatmap grouped category plugin styling issues
- Programmatically change dataLabel's border with Highcharts
- Handling axis scale change when a legend item is clicked & hidden
- How can i pass my data in sqlite database to templates? ( to make line chart using highcharts)
- Highchart - colors depending on values
- How to trigger legend click event on outside when using Highchart and no using JQuery
- Add Source to Highcharts Export CSV
- Displaying Data in Django using HighCharts
- HighCharts: add dashed line
- Cannot get Highcharts solidgauge stops to work in styled mode