chartjs


使用例子:

  1. import "github.com/GoAdminGroup/go-admin/template/chartjs"
  2. func xxx() {
  3. ...
  4. lineChart := chartjs.Line().
  5. SetID("salechart").
  6. SetHeight(180).
  7. SetTitle("Sales: 1 Jan, 2019 - 30 Jul, 2019").
  8. SetLabels([]string{"January", "February", "March", "April", "May", "June", "July"}).
  9. AddDataSet("Electronics"). // 增加第一条数据
  10. DSData([]float64{65, 59, 80, 81, 56, 55, 40}). // 设置数据内容
  11. DSFill(false). // 是否填充颜色
  12. DSBorderColor("rgb(210, 214, 222)"). // 线边框颜色
  13. DSLineTension(0.1). // 设置压力度
  14. AddDataSet("Digital Goods"). // 增加第二条数据
  15. DSData([]float64{28, 48, 40, 19, 86, 27, 90}).
  16. DSFill(false).
  17. DSBorderColor("rgba(60,141,188,1)").
  18. DSLineTension(0.1).
  19. GetContent()
  20. ...
  21. }

具体api请见:https://www.chartjs.org/docs/latest/