You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @vicanso
Can we do customisation for line colors in LineChart
func GenerateLineChart(values [][]float64, xaxisArray []string, chartName string, id string) {
minValue := 0.0
maxValue := 100.0
show := true
splitLineShow := true
yAxisOption1 := charts.YAxisOption{
Min: &minValue,
Max: &maxValue,
Font: nil, // Replace with actual *truetype.Font if available
Data: []string{"A", "B", "C"},
FontSize: 6,
Position: "left",
FontColor: charts.Color{R: 0, G: 0, B: 0, A: 255}, // Black color
Formatter: "{value}",
Color: charts.Color{R: 255, G: 0, B: 0, A: 255}, // Red color
Show: &show,
DivideCount: 5,
Unit: 1,
SplitLineShow: &splitLineShow,
}
fmt.Print(yAxisOption1)
p, err := charts.LineRender(
values,
charts.XAxisDataOptionFunc(xaxisArray),
func(opt *charts.ChartOption) {
opt.Legend.Padding = charts.Box{
Top: 20,
Bottom: 30,
}
opt.YAxisOptions = []charts.YAxisOption{
{
SplitLineShow: charts.TrueFlag(),
FontSize: 10,
FontColor: charts.Color{R: 0, G: 0, B: 0, A: 255}, // Black color
Formatter: "{value} " + "MB",
},
}
opt.XAxis = charts.XAxisOption{
Data: xaxisArray,
FontSize: 10,
FontColor: charts.Color{R: 0, G: 0, B: 0, A: 255}, // Black color
}
opt.SymbolShow = charts.TrueFlag()
opt.LineStrokeWidth = 4
opt.Width = 600
opt.Height = 300
// Customize line colors for each series using StrokeStyle
colors := []charts.Color{
{R: 255, G: 0, B: 0, A: 255}, // Red
{R: 255, G: 0, B: 0, A: 255}, // Green
{R: 255, G: 0, B: 0, A: 255}, // Blue
{R: 255, G: 0, B: 0, A: 255}, // Orange
}
for i := range opt.SeriesList {
opt.SeriesList[i].Style = charts.Style{
StrokeColor: colors[i%len(colors)],
FontColor: colors[i%len(colors)],
FillColor: colors[i%len(colors)],
}
}
},
charts.TitleOptionFunc(charts.TitleOption{
Text: "MB", // Set the title with the unit
FontColor: charts.Color{R: 69, G: 69, B: 69, A: 255}, // Black color
}),
)
The text was updated successfully, but these errors were encountered:
Hi @vicanso
Can we do customisation for line colors in LineChart
func GenerateLineChart(values [][]float64, xaxisArray []string, chartName string, id string) {
minValue := 0.0
maxValue := 100.0
show := true
splitLineShow := true
The text was updated successfully, but these errors were encountered: