vicanso / go-charts

A charts library for Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Funnel to have smooth edges even if numbers are not evenly spread

lesichkovm opened this issue · comments

At the moment the funnel dows not look much like a funnel when numbers are not very even

image

Is there a way that the funnel is made smoother, and looking like a funnel, even with vastly different numbers

@lesichkovm The design of go-charts is referred to echarts, you can have a try on the website:https://echarts.apache.org/examples/en/editor.html?c=funnel, by adjusting the config to get the preview. If you are satisfied the preview, please provide the config to me.

Thank you for the suggestion @vicanso

Played with it a for a bit, and it does not seem to support it outright.

So to make it work as expected had to basically hardcode the values, regardless of the real values to get the visual effect.

But instead of hardcoding it, I manually deduced it from the number of labels.

Examples:

painter, errChart := charts.FunnelRender(
  lo.Reverse(lo.RangeFrom(1.0, len(labels))),
  charts.TitleTextOptionFunc("Funnel"),
  charts.LegendLabelsOptionFunc(labels), func(opt *charts.ChartOption) {
	  for index := range opt.SeriesList {
		  opt.SeriesList[index].Label.Formatter = "{b}"
	  }
  },
  charts.ThemeOptionFunc(charts.ThemeAnt),
)

Output:
image