簡體   English   中英

R hchart()函數的Highcharter tickmarkPlacement

[英]R Highcharter tickmarkPlacement with hchart() function

查看文檔tickmarkPlacement似乎允許將刻度線從“開”移動到“之間”,但是使用hchart函數,我似乎無法使其正常工作。

試圖改變從這種風格

library(highcharter)

# Create sample data frame
sample_df <- data_frame(sku = c(rep("12",40)),
                        type = c(rep("actuals",20), rep("forecast",20)),
                        calendar_week = rep(seq(as.Date("2017-09-08"), as.Date("2018-01-23"), by=7),2),
                        units = round(c(rnorm(11, mean=50, sd=10), rep(0, 9), c(rnorm(20, mean=100, sd=10))),0))

# Create colours vector
custom_colours <- c("#4286f4", "#d66048")

# Chart
hchart(sample_df, "line",  hcaes(calendar_week, units, group = type), color = custom_colours)  %>%
  hc_yAxis(title = list(text = "Units")) %>%  
  hc_xAxis(title = list(text = "Week"), startOfWeek = 5, type = "datetime", tickInterval = 7* 24 * 3600 * 1000, tickmarkPlacement = "between")

tickmarkPlacement僅適用於分類軸。 嘗試這個:

hchart(sample_df, "line",  hcaes(factor(format(sample_df$calendar_week, "%d-%b-%Y")), 
                                 units, group = type), color = custom_colours)  %>%
  hc_yAxis(title = list(text = "Units")) %>%  
  hc_xAxis(title = list(text = "Week"), tickmarkPlacement = "between")

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM