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

How to reorder bar charts? #201

Open
armanokka opened this issue Oct 8, 2022 · 3 comments
Open

How to reorder bar charts? #201

armanokka opened this issue Oct 8, 2022 · 3 comments

Comments

@armanokka
Copy link

Trying to put Politics & Government on right side of chart. Despire reordering passed graph.Bars Politics & Government is second anyway

	for i, value := range values {
		j := 0 // 0-9
		switch value.Label {
		case "Family & Relationships":
			j = 0
		case "Entertainment & Music":
			j = 9
		case "Society & Culture":
			j = 2
		case "Health":
			j = 3
		case "Business & Finance":
			j = 4
		case "Education & Reference":
			j = 5
		case "Sports":
			j = 6
		case "Science & Mathematics":
			j = 7
		case "Computers & Internet":
			j = 8
		case "Politics & Government":
			values[i].Label = "ХУЙ" // TODO: изменить порядок баров
			j = 2
		default:
			pp.Println("category not found", value.Label)
		}
		values[i], values[j] = values[j], values[i]
	}

	graph := chart.BarChart{
		Title: text,
		TitleStyle: chart.Style{
			Padding: chart.Box{Bottom: 50},
			Font:    font,
		},
		ColorPalette: nil,
		Width:        1100,
		Height:       600,
		DPI:          0,
		BarWidth:     60,
		Background:   chart.Style{},
		Canvas:       chart.Style{},
		XAxis:        chart.Style{},
		YAxis: chart.YAxis{
			AxisType: chart.YAxisPrimary, // TODO: need chart.YAxisSecondary but Yaxis just crops. Waiting for fixing
		},
		BarSpacing: 0,
		Font:       nil,
		Bars:       values,
		Elements:   nil,
	}

https://i.yapx.cc/UNGAJ.png

@armanokka
Copy link
Author

Solved.

@karageee
Copy link

how

@armanokka
Copy link
Author

I changed the order I pass arguments. IDK how they're being sorted I just was reordering it until it fitted as I wish

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

No branches or pull requests

2 participants