vicanso / go-charts

A charts library for Golang
MIT License
216 stars 33 forks source link

Line support dash line #66

Closed ssexuejinwei closed 6 months ago

ssexuejinwei commented 9 months ago

Thank you so much for providing such a useful and beautiful open source library. The line drawn is much more beautiful than go-chart.
I used this lib to build alert lines. Show as following: img_v3_026i_ab04e6bb-7f3b-464e-8965-e3f45dcea86g I want to let the "1day" line to dotted line and I try to change the style, but it seems that doesn't take effect, the code is showing below.

charts.Series{
        Type: "line",
        Name: func() string {
            if isCurValue(lValue) {
                if len(lValue.Legend) > 0 {
                    return lValue.Legend
                } else {
                    return "Now"
                }
            } else {
                if len(lValue.Legend) > 0 {
                    return lValue.Legend
                } else {
                    return "Compare"
                }
            }
        }(),
        Min:  &min,
        Max:  &max,
        Data: charts.NewSeriesDataFromValues(yValues),
        Style: chart.Style{
            StrokeDashArray: []float64{5.0, 5.0},
        },
    }

Could you tell me how to get the dotted line, thanks a lot!

vicanso commented 9 months ago

I am sorry, dash line is not supported.

vicanso commented 9 months ago

It is difficult to support this feature. If it is not necessary to use golang, may be you can try using charts-rs , which is better performance and simplicity. And you can try to use the web demo page, https://charts.npmtrend.com/ .

image
ssexuejinwei commented 9 months ago

Thanks for your reply! I will have a try.

And for your repo, we can add 3 line codes to support dash line for line chart,

image image

You can check this and make a branch to origin repo, if you have time. (I try to make a branch, but it seems that I do not have permission)

vicanso commented 9 months ago

Do you want to make a pull request, or wait until I support this feature later.

ssexuejinwei commented 9 months ago

Well, I have created a pr, you can check this https://github.com/vicanso/go-charts/pull/67