chart_series.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type ChartSeries struct {
  7. ChartSeriesId int `orm:"column(chart_series_id);pk"`
  8. SeriesName string `description:"系列名称"`
  9. SeriesNameEn string `description:"系列英文名称"`
  10. ChartInfoId int `description:"图表ID"`
  11. ChartStyle string `description:"图表类型"`
  12. ChartColor string `description:"颜色"`
  13. ChartWidth int `description:"线条大小"`
  14. IsPoint int `description:"是否用数据点展示(0 否,1是)"`
  15. IsNumber int `description:"是否用数值展示(0 否,1是)"`
  16. IsAxis int `description:"1:左轴,0:右轴"`
  17. MaxData float64 `description:"上限"`
  18. MinData float64 `description:"下限"`
  19. IsOrder bool `description:"true:正序,false:逆序"`
  20. CreateTime time.Time `description:"创建时间"`
  21. ModifyTime time.Time `description:"修改时间"`
  22. }
  23. func (c *ChartSeries) TableName() string {
  24. return "chart_series"
  25. }
  26. func GetChartSeriesByChartInfoId(chartInfoId int) (items []*ChartSeries, err error) {
  27. o := orm.NewOrm()
  28. sql := "SELECT * FROM chart_series WHERE chart_info_id = ?"
  29. _, err = o.Raw(sql, chartInfoId).QueryRows(&items)
  30. return
  31. }
  32. type ChartSectionSeriesValSortAsc []ChartSectionSeriesValSort
  33. type ChartSectionSeriesValSortDesc []ChartSectionSeriesValSort
  34. type ChartSectionSeriesValSort struct {
  35. Index int
  36. Value float64
  37. }
  38. func (s ChartSectionSeriesValSortAsc) Len() int {
  39. return len(s)
  40. }
  41. func (s ChartSectionSeriesValSortAsc) Less(i, j int) bool {
  42. return s[i].Value < s[j].Value // 升序排序,如果想要降序则改为 s[i].Value > s[j].Value
  43. }
  44. func (s ChartSectionSeriesValSortAsc) Swap(i, j int) {
  45. s[i], s[j] = s[j], s[i]
  46. }
  47. func (s ChartSectionSeriesValSortDesc) Len() int {
  48. return len(s)
  49. }
  50. func (s ChartSectionSeriesValSortDesc) Less(i, j int) bool {
  51. return s[i].Value > s[j].Value // 升序排序,如果想要降序则改为 s[i].Value > s[j].Value
  52. }
  53. func (s ChartSectionSeriesValSortDesc) Swap(i, j int) {
  54. s[i], s[j] = s[j], s[i]
  55. }