score:1
Accepted answer
Bit of a pain to get this to work but I believe this is a solution to your question. Unfortenly there doesn't appear to be a way to do this with highcharts
directly so you have to manipulate the data beforehand.
library(highcharter)
library(tidyverse)
cols <- c("#2c3e50", "#f39c12")
dta %>%
ungroup() %>%
mutate(antibiotic = factor(antibiotic) %>% fct_reorder(n, .desc = TRUE)) %>%
mutate(cat_index = as.numeric(antibiotic)) %>%
hchart(
type = "bar",
hcaes(x = cat_index,
y = n,
group = category,
name = antibiotic),
color = cols
) %>%
hc_xAxis(type = "category", labels = list(step = 1)) %>%
hc_yAxis(title = "", stackLabels = list(enabled = TRUE)) %>%
hc_tooltip(headerFormat = "",
pointFormat = "{point.n} patients have taken {point.antibiotic}") %>%
hc_plotOptions(series = list(stacking = "normal"))
Source: stackoverflow.com
Related Articles
- Custom colors in R highcharter barplot
- Custom colors in Highcharter are not mapping correctly to the legend
- Highcharts - How to set custom colors for the series
- r highcharter package barplot group vs. color
- How to change the palette colors of a highcharter column plot which depends on a variable?
- HighCharts: How to combine custom colors with gradient
- Highcharter R custom button for log axis
- Customize colors for boxplot with highcharter
- Highcharter bar colors issue
- Highcharts 3D pie with custom colors
- Highchart highlight area between points with custom colors
- How to change colors of a highcharter matrix/heatmap?
- Applying a custom colors on HighCharts Line?
- Strange character in the Highstock source code
- How to Create Custom Shapes in R Highcharter
- Setting custom colors in Highcharts drill-down maps
- Highcharts - apply gradient on custom colors
- highcharts custom colors and tootip point color
- Highcharts heatmap with custom colors for each yAxis
- Color coutries/continents with own custom colors in highmaps
- highcharter custom animation
- HeatMap with custom colors for each cell
- 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: dynamically define colors in pie chart
- Highcharts Area graph, use 2 fill colors above / below X axis
- highcharts datetime x-axis custom formatting
- R Highcharter Sankey nodes column property trouble
- Converting Datatable columns to array of array
- Gradient background bars in Highchart bar chart
- Highcharts dont display statistics with MySQL Query
- How to get data in Highstock from PHP MySQL data on AJAX call
- 3D Pie chart in Highcharts/Javascript
- Display Percentage Values on Z-axis (highcharts) bubble chart
- Set Opacity Pie Chart Highcharts
- highcharts ampersand
- Highcharts increase the space/gap between grouped data series
- Charting with 500K data points
- Highcharts remove gap between start of xAxis and first value
- Highcharts in a modal window on click
- "Uncaught ReferenceError: chart is not defined"
- Remove SVG rendered path on Legend Item Click
- breaking json for stacked highcharts
- Highlight a region in scatter plot using Highcharts
- High Charts Rendering on Internet Explorer 10
- Add more data to series in highchart pie chart
- Highcharts - Force Categories in x-axis to be shown, even without data
- How I can rotate a polar chart?