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

Add animation; #246

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

james-zhang-gb
Copy link
Contributor

Add dynamic update option feature;

  • use:SetOptionUpdater() and then send Chart into the chan;

example:

func example() {
	bar := charts.NewBar()
	anime := opts.Anime{
		Animation: true,
	}
	bar.SetGlobalOptions(
		charts.WithTitleOpts(opts.Title{
			Title: "datazoom options(inside)",
		}),
		charts.WithDataZoomOpts(opts.DataZoom{
			Type:  "inside",
			Start: 10,
			End:   50,
		}),
		charts.WithAnimationOpts(anime),
	)

	bar.SetXAxis(weeks).
		AddSeries("Category A", generateBarItems(), charts.WithSeriesAnimationOpts(anime)).
		AddSeries("Category B", generateBarItems(), charts.WithSeriesAnimationOpts(anime))
	updater := bar.SetOptionUpdater()
	go func() {
		for {
			bar.MultiSeries[1].Data = generateBarItems()
			updater <- bar
			time.Sleep(3 * time.Second)
		}
	}()
	page := components.NewPage()
	page.AddCharts(bar)
	// render to any writer
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		page.Render(w)
	})
	http.ListenAndServe("localhost:8089", nil)
}

james.zhang added 2 commits September 28, 2022 17:30
Add dynamic update option feature;
- use:SetOptionUpdater()
and then send Chart into the chan;
@Koooooo-7 Koooooo-7 added the attention Attention may include breaking changes label Oct 22, 2022
@tabiul
Copy link

tabiul commented Jun 13, 2023

Is there any possibility that is PR will be merged. I need the feature to update graph and it seems this fixes the issue

@Koooooo-7
Copy link
Member

Hi @james-zhang-gb, sorry for the late back to review this changes.
I think it could be an extension for go-echarts.
The websocket part is not part of the go-echarts core since it is more like the server/communication part instead of render chart itself. But it is actually a nice feature.
If you were willing to make it as an Extension for go-echarts.
Please let me know, I could work with you to finish it and also create an individual repo in go-echarts for this, or being maintained in your side it also fine.

@Koooooo-7 Koooooo-7 added the wait information Need more details label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention Attention may include breaking changes wait information Need more details
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants