I want to show the distribution of windturbine's events using Highcharts.
My X-axis won't display its values entirely well. I found that when I have only one event defined for one year, it mucks up the vizualisation.
However when I have multiple events on several years, it goes smooth. I don't know if the code misses one option or if I should use another function to display my results.
Below is the code and the associated results.
library(highcharter)
library(dplyr)
library(highcharter)
mpgg_EX <- data.frame("Country" = c("Belux","Belux","Belux","Belux","Belux"), "WT_Manufacturer" = c("bubble","bubble","bubble","bubble","fever"), "Start_Event_Date" = c("2013", "2014","2015","2016","2013"),"BLA"=c(0,0,0,0,0),"ELEC"=c(1,0,0,0,0),"MECA"=c(1,1,1,1,1),"OTH"=c(0,0,0,0,0),"PWEL"=c(0,1,0,0,0),"VAR"=c(1,0,0,0,0),stringsAsFactors = FALSE)
categories_grouped_EX <- mpgg_EX %>%
group_by(name = WT_Manufacturer) %>%
do(categories = .$Start_Event_Date) %>%
list_parse()
categories_grouped_EX<- lapply(categories_grouped_EX, function(x) x[!is.na(x)])
hc_indispo_EX <- highchart() %>%
hc_chart(type = "column") %>%
hc_colors("#fc5421") %>%
hc_title(text = "Unavailability Manufacturer Example") %>%
hc_xAxis(title = "Suppliers"
,type = "category"
,categories = categories_grouped_EX
) %>%
hc_legend(layout = "vertical", verticalAlign = "bottom",align = "right", valueDecimals = 0, reversed = TRUE) %>%
hc_plotOptions(
series = list(
cropThreshold = 1000,
stacking = "normal",
borderWidth = 0,
grouping = TRUE,
dataLabels = list(enabled = FALSE)
)
) %>%
hc_add_series(
data = mpgg_EX,
type = "column",
name = "MECA",
hcaes(x = Start_Event_Date,
y = MECA)
) %>%
hc_tooltip(formatter = JS("function(){
var point = this.point;
s = '<b>' + this.series.name + '</b>' + ' :' + Highcharts.numberFormat(this.y,0) + '<br/>';
s += '<b>' + 'Total : ' + '</b>' + Highcharts.numberFormat(point.stackTotal,0) + '<br/>';
return (s)}"
))
hc_indispo_EX