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

[Bug] XAxis WithXAxisOpts show设置为false时候,line.JSON返回的数据里面没有show属性,设置为true的时候会带上 #402

Open
lufeng4828 opened this issue Feb 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@lufeng4828
Copy link

lufeng4828 commented Feb 22, 2024

Describe the issue

line := charts.NewLine()
	line.SetXAxis(names).AddSeries(metric, items).
		SetGlobalOptions(
			charts.WithTooltipOpts(opts.Tooltip{
				Show:    true,
				Trigger: "axis",
			}),
			charts.WithColorsOpts(opts.Colors{"#0052d9"}),
			charts.WithLegendOpts(opts.Legend{Show: false}),
			charts.WithXAxisOpts(opts.XAxis{
				Show: false,
			}),
		).
		SetSeriesOptions(
			charts.WithMarkPointNameTypeItemOpts(
				opts.MarkPointNameTypeItem{Name: "Maximum", Type: "max"},
				opts.MarkPointNameTypeItem{Name: "Average", Type: "average"},
				opts.MarkPointNameTypeItem{Name: "Minimum", Type: "min"},
			),
			charts.WithAreaStyleOpts(
				opts.AreaStyle{
					Opacity: 0.3,
					Color:   "#0052d9",
				},
			),
			charts.WithMarkPointStyleOpts(
				opts.MarkPointStyle{Label: &opts.Label{Show: true}}),
		)
line.Validate()
line.JSON()

需要把 type XAxis struct 里面的Show的json tag中的omitempty去掉
// Set this to false to prevent the axis from showing.
Show bool json:"show,omitempty"

How to reproduce this issue

charts.WithXAxisOpts(opts.XAxis{
Show: false,
}),

line.Validate()
line.JSON()

Other information

No response

go-echarts version

v2.3.3

@lufeng4828 lufeng4828 added the bug Something isn't working label Feb 22, 2024
@Koooooo-7 Koooooo-7 added the need investigation Need investigation about this issue label Feb 22, 2024
@Koooooo-7
Copy link
Member

Hi @lufeng4828, 确实有bool类型不一致导致序列化后出来的问题。 建议升级到v2.4.0-rc1 试试。

@Koooooo-7 Koooooo-7 removed the need investigation Need investigation about this issue label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants