Code Monkey home page Code Monkey logo

Comments (5)

Koooooo-7 avatar Koooooo-7 commented on June 29, 2024 1

Hi @dpajkovic , the legend and the data is not in the same system, there is no corresponding legend for each data.
It needs set it individual and bind to the series via name.
Base on the code you provide:

	legends := []map[string]interface{}{
		{
			"name": "Number of production Events",
			"itemStyle": map[string]string{
				"color": "#516a91",
			},
		},
		{
			"name": "Number of pre-production Events",
			"itemStyle": map[string]string{
				"color": "#93b7e3",
			},
		},
		{
			"name": "Linear regression of production Events",
			"itemStyle": map[string]string{
				"color": "#516a91",
			},
		},
		{
			"name":"Linear regression of pre-production Events",
			"itemStyle": map[string]string{
				"color": "#93b7e3",
			},
		}

		charts.WithLegendOpts(
			opts.Legend{
				...
				Data:   legends,
			},
		),

from go-echarts.

dpajkovic avatar dpajkovic commented on June 29, 2024 1

Interesting. And a nice workaround. But I would argue that it stands to reason the line color should be picked up by the legend from the series setting the same way the type of the line is picked up. Thanks!

from go-echarts.

Koooooo-7 avatar Koooooo-7 commented on June 29, 2024

Interesting. And a nice workaround. But I would argue that it stands to reason the line color should be picked up by the legend from the series setting the same way the type of the line is picked up. Thanks!

FYI.
It is not a workaround, it is literally how it works in echarts.
By default, the line and the legend both pick the Color from the global Colors.
When you custom the line's color individually, it does not impact the global Colors which used by legend.
You can config the global colors via Colors, but it doesn't means there has a steady corresponding legend color to the lines custom color, although you could set it as the same.

line.Colors = []string{"#ae1029","#0065c2","#26c238", "#9876aa", "#fb8649",
		"#57904b","#d35b5c"}.

// line.Colors = []string{"#516a91","#0065c2","#93b7e3"},

from go-echarts.

dpajkovic avatar dpajkovic commented on June 29, 2024

My argument is that legend picks up the line type (solid/dashed/dotted...), which I declare in LineStyle same as I do the color, and intuitively it should pick up the color as well. Is there a way to change the line type in legend Data?

Anyway, since it's the same in echarts, I can see this being an enhancement and not a bug.

from go-echarts.

Koooooo-7 avatar Koooooo-7 commented on June 29, 2024

My argument is that legend picks up the line type (solid/dashed/dotted...), which I declare in LineStyle same as I do the color, and intuitively it should pick up the color as well. Is there a way to change the line type in legend Data?

The line style of echarts is another topic and its default behavior refer to its doc:

Legend line style. If its children have values as 'inherit', the values are inherited from corresponding series options.

I see the behavior between the legend and the series seems odd with some inherit and something not.
But it is what it is...

Is there a way to change the line type in legend Data?

{
			"name": "Number of production Events",
			"itemStyle": map[string]string{
				"color": "#516a91",
			},
                        // add the lineStyle
                        lineStyle: {
                              type: "dashed"
                         }
}

from go-echarts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.