echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Sunburst customization by layers

Open AThibault92 opened this issue 5 years ago • 3 comments

Hello,

I'm trying to custom a sunburst layer by layer (like this example : https://echarts.apache.org/examples/en/editor.html?c=sunburst-drink)

But I cannot manage to do it... All i can do is custom all layers, but not a specific one.

Here what I tried :

df <- tibble(
  name = c("earth", "mars", "venus"),
  value = c(30, 40, 30),
  # 1st level
  itemStyle = tibble(color = c(NA, "red", "blue")),
  # embedded styles, optional
  children = list(
    tibble(
      name = c("land", "ocean"),
      value = c(10, 20),
      # 2nd level
      children = list(
        tibble(name = c("forest", "river"), value = c(3, 7)),
        # 3rd level
        tibble(
          name = c("fish", "kelp"),
          value = c(10, 5),
          children = list(
            tibble(name = c("shark", "tuna"), value = c(2, 6)),
            # 4th level
            NULL # kelp
          )
        )
      )
    ),
    tibble(name = c("crater", "valley"), value = c(20, 20)),
    NULL # venus
  )
)


df %>%
  e_charts() %>%
  e_sunburst(levels = list(list(), list(), list(), list(r0 = "70%")))

Is it possible to do that with this R package ? Or it is not yet implemented ?

Thank you !

AThibault92 avatar Apr 23 '21 11:04 AThibault92

Sorry, I'm not sure what you mean by "custom," do you mean the use of the levels argument?

JohnCoene avatar Apr 23 '21 12:04 JohnCoene

Yes, i tried to use the levels argument to change :

  • the r0 and r
  • the label orientation et position

In the example, they used this to change the style of each level:

levels: [{}, {
            r0: '15%',
            r: '35%',
            itemStyle: {
                borderWidth: 2
            },
            label: {
                rotate: 'tangential'
            }
        }, {
            r0: '35%',
            r: '70%',
            label: {
                align: 'right'
            }
        }, {
            r0: '70%',
            r: '72%',
            label: {
                position: 'outside',
                padding: 3,
                silent: false
            },
            itemStyle: {
                borderWidth: 3
            }
        }]

I manage to change the itemStyle of each layer, but not the other argument (r0, r and label) :(

AThibault92 avatar Apr 23 '21 12:04 AThibault92