JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
587 stars 82 forks source link

Is it possible to create bubble chart using e_scatter #503

Open OmasuRichard opened 1 year ago

OmasuRichard commented 1 year ago

Hi,

I'm trying to create a bubble chart that look like this using e_scatter.

Screenshot_20230207_012116

This is what the data looks like and the state I am able to recreate now

data <- data.frame( group = c("Upper", "Upper", "Upper", "Upper", "Upper", "Upper", "Upper", "Upper", "Lower", "Lower"), category = c("A", "B", "C", "D", "E", "F", "G", "H", "a", "b"), size = c(0.74, 0.72, 0.68, 0.67, 0.63, 0.54, 0.53, 0.49, 0.02, 0.02), sample_x = c(0, 0.2, 0.4, 0.6, 0.8, 0.8, 0.6, 0.4, 0.2, 0), sample_y = c(1, 2, 3, 2, 1, -1, -2, -3, -2, -1) )

data |> group_by(group) |> e_charts(sample_x) |> e_scatter(sample_y, size)

Screenshot_20230207_020019

Originally the data only have group, category and value columns

Because I don't have x and y in the data, is it possible to recreate the bubble chart using e_scatter ? Or am I using the wrong chart type for this ? (I did try by adding e_polar but I couldn't scale the size of the dot using size column)

Thank you

rdatasculptor commented 1 year ago

Not sure how it should be done, but something like that is possible using custom charts: https://echarts.apache.org/examples/en/editor.html?c=circle-packing-with-d3

Maybe another approach is using the graph type, in combination with the transparent color for the edges. Not sure how it looks though. But I am interested is doing some experiments when I have time.