Reputation: 1299
Based on the example I found here I thought the code below would produce a gauge with three color ranges:
0 < x <= 1.5: green
1.5 < x <= 3: yellow
x > 3: red
Here's what I have:
library(echarts4r)
library(magrittr)
CA_gauge <- e_charts() %>%
e_gauge(4.1,
"INCIDENCE",
min=0,
max=20,
axisLine = list(
linestyle = list(
color=list(
c(1.5, "green"),
c(3, "yellow"),
c(20, "red")
)
))) %>%
e_title("CA")
print(CA_gauge)
but what it produces is
I suspect I'm missing something basic...
Thanks!
Upvotes: 0
Views: 514
Reputation: 3671
There are two point that need to be adjusted. linestyle
needs a upper S - lineStyle
- and the breacks have to be percentages.
Futhermore you can add splitNumber
to adjust the breaks and make te gauge more readable.
# breaks in percentage
1.5 / 20 = 0.075
3 / 20 = 0.15
20 / 20 = 1
CA_gauge <- e_charts() %>%
e_gauge(4.1,
"INCIDENCE",
min=0,
max=20,
splitNumber = 20,
axisLine = list(
lineStyle = list(
color=list(
c(0.075, "green"),
c(.15, "yellow"),
c(1, "red")
)
))) %>%
e_title("CA")
print(CA_gauge)
Upvotes: 2