Thomas
Thomas

Reputation: 1302

echarts4r gauge chart value in %

I have a minimal example and want to display value in percent. Any ideas?
Here you can find the API documentation.

maxValue <- 160

echarts4r::e_charts() %>% 
  echarts4r::e_gauge(
    value = round(runif(1, 0, maxValue)), 
    name = "description",
    radius = "80%",
    startAngle = 210, #225,
    endAngle = -30, #-45,
    min = 0,
    max = maxValue,
    splitNumber = maxValue/20
  )

Upvotes: 1

Views: 649

Answers (1)

JohnCoene
JohnCoene

Reputation: 2261

Sorry, only just came across this.

Would this work? Compute the percentage R-side and use the formatter to add percent sign.

maxValue <- 160

echarts4r::e_charts() %>% 
  echarts4r::e_gauge(
    value = round((runif(1, 0, maxValue) / maxValue) * 100), 
    name = "description",
    radius = "80%",
    startAngle = 210, #225,
    endAngle = -30, #-45,
    min = 0,
    max = maxValue,
    splitNumber = maxValue/20,
    detail = list(
      formatter = "{value}%"
    )
  )

Upvotes: 2

Related Questions