我正在使用 go 圖表庫https://github.com/wcharczuk/go-chart制作條形圖。我面臨的問題是標簽值很長,我想將文本旋轉 45 度以顯示完整文本我喜歡顯示的日期格式是這樣的2018-05-12。var values []chart.Value for k, v := range timeline { // leng += 1 new_data := k[0:10] println(new_data) val := float64(v) values = append(values, chart.Value{Label: new_data, Value: val, Style: chart.Style{FontColor: drawing.Color{R: 255, G: 0, B: 0, A: 255}, FontSize: 4.0}}) } pie := chart.BarChart{ Title: "Timeline Chart", Height: 350, TitleStyle: chart.StyleShow(), Background: chart.Style{ Padding: chart.Box{ Top: 40, }, }, BarWidth: 60, XAxis: chart.StyleShow(), YAxis: chart.YAxis{ Style: chart.StyleShow(), // TickStyle: chart.Style{ // TextRotationDegrees: 45.0, // }, NameStyle: chart.Style{Show: true, TextRotationDegrees: 45.0}, }, Bars: values,}chart.Style屬性也不起作用,因為我想縮小字體大小并更改標簽文本的顏色
1 回答

臨摹微笑
TA貢獻1982條經驗 獲得超2個贊
創建時chart.BarChart
,只需添加TextRotationDegrees
到您的樣式XAxis
XAxis: chart.Style{ Show: true, TextRotationDegrees: 45.0, },
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報
0/150
提交
取消