67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
package chartjs
|
|
|
|
/*
|
|
{
|
|
label: 'My Time Series Data',
|
|
data: [
|
|
{ x: '2025-01-01', y: 10 },
|
|
{ x: '2025-01-02', y: 15 },
|
|
{ x: '2025-01-03', y: 8 },
|
|
{ x: '2025-01-04', y: 20 },
|
|
{ x: '2025-01-05', y: 12 }
|
|
],
|
|
borderColor: 'rgb(75, 192, 192)',
|
|
tension: 0.1
|
|
}
|
|
*/
|
|
|
|
type TimeseriesValue struct {
|
|
Timestamp int64 `json:"x"`
|
|
Value float64 `json:"y"`
|
|
}
|
|
|
|
// TimeseriesData 时间序列的数据
|
|
type TimeseriesData struct {
|
|
Label string `json:"label"`
|
|
Data []*TimeseriesValue `json:"data"`
|
|
BorderColor string `json:"borderColor,omitempty"`
|
|
BackgroundColor string `json:"backgroundColor,omitempty"`
|
|
Tension float64 `json:"tension,omitempty"`
|
|
Fill bool `json:"fill,omitempty"`
|
|
}
|
|
|
|
/**
|
|
{
|
|
labels: labels,
|
|
datasets: [
|
|
{
|
|
label: 'Dataset 1',
|
|
data: Utils.numbers(NUMBER_CFG),
|
|
backgroundColor: [
|
|
Utils.transparentize(Utils.CHART_COLORS.red, 0.5),
|
|
Utils.transparentize(Utils.CHART_COLORS.orange, 0.5),
|
|
Utils.transparentize(Utils.CHART_COLORS.yellow, 0.5),
|
|
Utils.transparentize(Utils.CHART_COLORS.green, 0.5),
|
|
Utils.transparentize(Utils.CHART_COLORS.blue, 0.5),
|
|
]
|
|
}
|
|
]
|
|
}
|
|
*/
|
|
|
|
type counterValue struct {
|
|
Label string `json:"label"`
|
|
Values map[string]float64 `json:"data"`
|
|
}
|
|
|
|
type CounterValue struct {
|
|
Label string `json:"label"`
|
|
Data []float64 `json:"data"`
|
|
BackgroundColor []string `json:"backgroundColor,omitempty"`
|
|
}
|
|
|
|
type CounterData struct {
|
|
Lables []string `json:"labels"`
|
|
Datasets []*CounterValue `json:"datasets"`
|
|
}
|