go-chart icon indicating copy to clipboard operation
go-chart copied to clipboard

Sample line in legend too long

Open d-Rickyy-b opened this issue 3 years ago • 5 comments

Hi there and thank you so much for this great project!

I just created my first chart and was wondering if there's the ability to change the length of the "sample" line shown in the legend. It's ridiculously long in the following example:

grafik

I'll attach a minimal configuration (without actual values) for the above chart:

mainSeries := chart.TimeSeries{
	Name: "Intel Core i5-12600K, 6C+4c/16T, 3.70-4.90GHz, boxed ohne Kühler (BX8071512600K)",
	Style: chart.Style{
		StrokeColor: <...>,
		StrokeWidth: 2,
	},
}
linRegSeries := &chart.LinearRegressionSeries{
	Name:        "Trend",
	InnerSeries: mainSeries,
	Style: chart.Style{
		StrokeColor:     <...>,
		StrokeWidth:     2,
		StrokeDashArray: []float64{5.0, 5.0},
	},
}
graph := chart.Chart{
	Width:  1280,
	Height: 720,
	YAxis: chart.YAxis{
		Name: "Preis",
		Range: &chart.ContinuousRange{
			Min: minPrice - (maxPrice)*0.1,
			Max: maxPrice + (maxPrice)*0.1,
		},
	},
	XAxis: chart.XAxis{
		Name: "Datum",
	},
	Series: []chart.Series{
		mainSeries,
		linRegSeries,
	},
}
graph.Elements = []chart.Renderable{chart.Legend(&graph, chart.Style{
	FillColor: <...>,
	FontColor: <...>,
})}

Even in other cases it just looks a bit weird: grafik

Thank you in advance!

Cheers, Rico

d-Rickyy-b avatar Jan 09 '22 11:01 d-Rickyy-b

A suggestion would be to have the sample line shown first: grafik

d-Rickyy-b avatar Jan 09 '22 23:01 d-Rickyy-b

hey!

Sorry I'm just seeing this, that's a great suggestion, lemme take a crack at creating an option for it.

wcharczuk avatar Jan 10 '22 00:01 wcharczuk

Hi @wcharczuk - I implemented a fix for this in #189. I added it as a new legend type (new func) instead of modifying your Legend func. Please let me know what you think about it. Would be great if you could merge my changes.

Also I added #190 which implements several style improvements.

PS: I saw that there are a lot of open issues and several PRs - if you need help maintaining this repo, let me know. I'd be happy to help. But I can also understand if you don't want to.

d-Rickyy-b avatar Feb 08 '22 03:02 d-Rickyy-b

Hey @wcharczuk - mind checking the PR?

d-Rickyy-b avatar Mar 22 '22 13:03 d-Rickyy-b

Hi @wcharczuk, could you please check the PR?

d-Rickyy-b avatar Jun 18 '22 23:06 d-Rickyy-b