Open vishnukumarkvs opened 11 months ago
Part of code
charts.WithItemStyleOpts(opts.ItemStyle{ Color: "#0F22C2", Color0: "#C2BA0F", BorderColor: "#0F22C2", BorderColor0: "#C2BA0F", BorderWidth: 4, }),
Full code below:-
func Kline(company string, data []dto.OHLC) string{ kline := charts.NewKLine() x := make([]string, 0) y := make([]opts.KlineData, 0) kd := ConvertOHLCtoKlineData(data) // Improvement: Uneccessary reverse order for i, j := 0, len(kd)-1; i < j; i, j = i+1, j-1 { kd[i], kd[j] = kd[j], kd[i] } for i := 0; i < len(kd); i++ { x = append(x, kd[i].Date) y = append(y, opts.KlineData{Value: kd[i].Data}) } kline.SetGlobalOptions( charts.WithTitleOpts(opts.Title{ Title: company, }), charts.WithXAxisOpts(opts.XAxis{ SplitNumber: 20, }), charts.WithYAxisOpts(opts.YAxis{ Scale: true, }), charts.WithDataZoomOpts(opts.DataZoom{ Type: "inside", Start: 50, End: 100, XAxisIndex: []int{0}, }), charts.WithDataZoomOpts(opts.DataZoom{ Type: "slider", Start: 50, End: 100, XAxisIndex: []int{0}, }), charts.WithTooltipOpts(opts.Tooltip{Show: true}), charts.WithLegendOpts(opts.Legend{Show: true, Right: "80px"}), ) kline.SetXAxis(x).AddSeries("kline", y). SetSeriesOptions( charts.WithMarkPointNameTypeItemOpts(opts.MarkPointNameTypeItem{ Name: "highest value", Type: "max", ValueDim: "highest", }), charts.WithMarkPointNameTypeItemOpts(opts.MarkPointNameTypeItem{ Name: "lowest value", Type: "min", ValueDim: "lowest", }), charts.WithMarkPointStyleOpts(opts.MarkPointStyle{ Label: &opts.Label{ Show: true, }, }), charts.WithItemStyleOpts(opts.ItemStyle{ Color: "#0F22C2", Color0: "#C2BA0F", BorderColor: "#0F22C2", BorderColor0: "#C2BA0F", BorderWidth: 4, }), ) kline.SetXAxis(x).AddSeries("kline", y) f, _ := os.Create("kline_all.html") kline.Render(f) var b bytes.Buffer err := kline.Render(&b) if err != nil { log.Fatal(err) } return b.String() }
Hi @vishnukumarkvs ,plz upgrade to the latest version and try again, it should work after I tested in #461 .
kline candlestick colors are not changing even though changing colors in WithItemStyleOpts option
Part of code
As you can see, border colors are changing but not color and color0, which represent inside colors
Full code below:-