Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Sample line in legend too long #185

Open
d-Rickyy-b opened this issue Jan 9, 2022 · 5 comments
Open

Sample line in legend too long #185

d-Rickyy-b opened this issue Jan 9, 2022 · 5 comments

Comments

@d-Rickyy-b
Copy link

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
Copy link
Author

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

@wcharczuk
Copy link
Owner

hey!

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

@d-Rickyy-b
Copy link
Author

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
Copy link
Author

Hey @wcharczuk - mind checking the PR?

@d-Rickyy-b
Copy link
Author

Hi @wcharczuk, could you please check the PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants