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

How to reorder bar charts?

Open armanokka opened this issue 2 years ago • 3 comments

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 avatar Oct 08 '22 18:10 armanokka

Solved.

armanokka avatar Oct 09 '22 06:10 armanokka

how

karageee avatar Jan 19 '23 01:01 karageee

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

armanokka avatar Jan 30 '23 14:01 armanokka