I want to plot a line chart using echarts4r, and the xAxis's label need to have the duplicated values. My packageVersion of echarts4r is 0.3.2.
And my codes as the follows:
library(echarts4r)
library(magrittr)
library(data.table)
dt <- data.table(
x_label = c('A', 'A', 'A', 'D', 'D', 'M', 'A'),
x_value = c('a', 'b', 'c', 'd', 'e', 'f', 'g'),
y = 8:14
)
p <- e_chart(dt, x_value)
p <- e_x_axis(p, show = FALSE, index = 0, position = 'top', data = purrr::map(seq_len(nrow(dt)), ~{
list(value = dt[.x, x_value])
})) # The show argument FALSE can not be worked
p <- e_line_(p, 'y', x_index = 0)
p <- e_x_axis(p, show = TRUE, position = 'bottom', data = purrr::map(seq_len(nrow(dt)), ~{
list(value = dt[.x, x_label])
}), index = 1)
p <- e_line_(p, 'y', x_index = 1)
p
But the top xAxis label can not be hide, I don't know why. Does anybody tell me how to custom the xAxis's label in a line chart with duplicated values ?
Or I don't know how to convert this options to R code:
option = {
title: {
text: 'ECharts entry example'
},
tooltip: {},
legend: {
data:['Sales']
},
xAxis: [
{
position: "bottom",
data: ["shirt","cardign","chiffon shirt","pants","heels","socks"]
},
{
position: "bottom",
data: ["group1", "", "", "group2", "", ""],
interval: 1,
axisLine: {
show: false
},
axisTick: {
alignWithLabel: false,
length: 40,
align: "left",
interval: function(index, value) {
return value ? true : false;
}
},
axisLabel: {
margin: 30
},
splitLine: {
show: true,
interval: function(index, value) {
return value ? true : false;
}
}
}
],
yAxis: {},
series: [{
name: 'Sales',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};