1

我用 highcharts 创建了一个柱形图和折线图。

X 轴类别名称在使用相同代码创建的其他图表中显示良好,但现在我遇到了一个问题,即整个类别名称被缩短,仅第一个字母仅显示在图表中。

例如,一个类别应该是“运行”,但它只显示为“R”。

我还注意到,这发生在只有 1 个类别要显示的图表中(就像一个只显示一列的单独柱形图)。

在这里会很感激一些帮助:)

highchart() %>%
hc_title(text = "Creative Performance") %>%
hc_yAxis_multiples(
list(title = list(text = "Spend"),labels=list(format ='${value:,.2f}'), min=0, max=max(data_creative_trueview$Spend), showFirstLabel= TRUE,showLastLabel=TRUE,opposite = FALSE),
list(title = list(text = "TrueView: CPCV"),min=0,max = max(data_creative_trueview$`TrueView: CPCV`)+0.5, labels = list(format = "${value:,.2f}"),showLastLabel = FALSE, opposite = TRUE)) %>%
hc_add_series(data = data_creative_trueview, type= "column", hcaes(y=Spend), name="Spend") %>%
hc_add_series(data = data_creative_trueview, type = "line", hcaes(y=`TrueView: CPCV`), name="TrueView: CPCV", yAxis=1) %>%
hc_xAxis(title="Creative", categories=data_creative_trueview$Creative) %>%
hc_tooltip(pointFormat = '${point.y:,.2f}') %>%
emphasized text hc_legend(align = "right", verticalAlign = "top")
4

2 回答 2

2

我在发布此内容后立即找到了答案。显然这是一个普遍的问题。当只有一个类别时,必须以列表的形式提供类别。参考:https ://github.com/jbkunst/highcharter/issues/173

于 2018-11-15T08:56:31.080 回答
0

在我的情况下xlabel={{"64"}},只显示了 6 个,因为xlabel={{"64",}}给了我 64 个,这是我想要的。

于 2020-08-23T14:47:33.123 回答