Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposal] can we add links in pie-chart graphs in the legend section #382

Closed
1 task
sudip10028 opened this issue Feb 1, 2024 · 3 comments
Closed
1 task
Labels
question Further information is requested

Comments

@sudip10028
Copy link

Describe your proposal

In my usecase i want to add a custom link in every legend so that clicking on the hyperlink any one can be routed to a specific pages.

What the feature/improvement it should looks like?

.

Other information

No response

Willing to implement it?

  • Yes, I do
@sudip10028 sudip10028 added the enhancement New feature or request label Feb 1, 2024
@Koooooo-7
Copy link
Member

Hi @sudip10028 , I think you can register the event listener to achieve this on js level such as windows.open, more event type see events.

	pie := charts.NewPie()
	const handler = `
   (params) => {
      // I get the legend selected event in Console now
      console.log(params);
   }
`
	pie.SetGlobalOptions(
		charts.WithTitleOpts(opts.Title{Title: "label options"}),
		charts.WithEventListeners(event.Listener{
			EventName: "legendselectchanged",
			Handler:   opts.FuncOpts(handler),
		}),
	)

@Koooooo-7 Koooooo-7 added question Further information is requested and removed enhancement New feature or request labels Feb 5, 2024
@fingon
Copy link

fingon commented Jun 9, 2024

I don't think this is quite what the original author asked for. SVG has concept of link blocks (see https://www.w3.org/TR/SVG11/linking.html ) and given support for those, it would be much simpler just to produce pure SVG and not JS-driven 'something' (which needs to then map the actual legend selected to url).

@Koooooo-7
Copy link
Member

I don't think this is quite what the original author asked for. SVG has concept of link blocks (see https://www.w3.org/TR/SVG11/linking.html ) and given support for those, it would be much simpler just to produce pure SVG and not JS-driven 'something' (which needs to then map the actual legend selected to url).

Hi@fingon.
I think it may different here since go-echarts is not a PURE raw html generator, it's a wrapper.
On the one hand, although go-echarts supports to generate charts as SVG, there's no a directly api to manipulate it with a link. Additionally, we don't product plain dom/elements by go-echarts, it only creates the echarts instance instead.
On the other hand, the Function/Listener is wrapped by echarts itself. The underlying implementation is not on the go-echarts' layers. Either using the svg functions or js event driven is fine here.
Cos go-echarts' job is done for the echarts instance build and config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants