Skip to content

Commit

Permalink
Improve filter example
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Jan 13, 2025
1 parent 5e9369d commit 60e2c11
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/chart-requests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ y-axis = 'pace'
title = 'Marathons and half-marathons'
filters = ['or (label half-marathon) (label marathon)']
y-axis = 'pace'

# Longer runs
[[charts]]
title = 'Long runs'
filters = ['distance >= 25 km']
y-axis = 'distance'
y1-axis = 'pace'
121 changes: 121 additions & 0 deletions test/functional/goldens/testExampleChart.golden
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,127 @@
}
}
}
},
{
"datasets": {
"xAxis": [
"2024-10-20T14:30:00",
"2024-10-25T12:00:00-08:00",
"2024-10-28T12:00:00-08:00"
],
"yAxes": [
{
"data": [
32.18,
42.195,
42.195
],
"fill": false,
"label": "distance",
"pointHoverRadius": 20,
"tension": 0,
"yAxisID": "y"
},
{
"data": [
300,
284.3938855314611,
447.9203697120512
],
"fill": false,
"label": "pace",
"pointHoverRadius": 20,
"tension": 0,
"yAxisID": "y1"
}
]
},
"extra": {},
"options": {
"maintainAspectRatio": false,
"plugins": {
"legend": {
"labels": {
"color": "#c3c3c3"
}
},
"title": {
"align": "center",
"color": "#c3c3c3",
"display": true,
"font": {
"size": 24
},
"text": "Long runs"
},
"tooltip": {
"backgroundColor": "rgba(204, 204, 204, 0.75)",
"bodyColor": "black",
"titleColor": "black"
}
},
"pointHitRadius": 20,
"responsive": true,
"scales": {
"x": {
"grid": {
"color": "#393939"
},
"ticks": {
"color": "#c3c3c3"
},
"time": {
"displayFormats": {
"day": "dd MMM yy"
},
"unit": "day"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "datetime"
},
"type": "timeseries"
},
"y": {
"grid": {
"color": "#393939"
},
"position": "left",
"ticks": {
"color": "#c3c3c3"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "km"
}
},
"y1": {
"grid": {
"color": "#393939"
},
"position": "right",
"ticks": {
"color": "#c3c3c3"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "pace /km"
}
}
}
}
}
]

118 changes: 118 additions & 0 deletions test/functional/goldens/testPathRunsOverrideData.golden
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,124 @@
}
}
}
},
{
"datasets": {
"xAxis": [
"2024-10-20T14:30:00",
"2024-10-25T12:00:00-08:00"
],
"yAxes": [
{
"data": [
32.18,
42.195
],
"fill": false,
"label": "distance",
"pointHoverRadius": 20,
"tension": 0,
"yAxisID": "y"
},
{
"data": [
300,
284.3938855314611
],
"fill": false,
"label": "pace",
"pointHoverRadius": 20,
"tension": 0,
"yAxisID": "y1"
}
]
},
"extra": {},
"options": {
"maintainAspectRatio": false,
"plugins": {
"legend": {
"labels": {
"color": "#c3c3c3"
}
},
"title": {
"align": "center",
"color": "#c3c3c3",
"display": true,
"font": {
"size": 24
},
"text": "Long runs"
},
"tooltip": {
"backgroundColor": "rgba(204, 204, 204, 0.75)",
"bodyColor": "black",
"titleColor": "black"
}
},
"pointHitRadius": 20,
"responsive": true,
"scales": {
"x": {
"grid": {
"color": "#393939"
},
"ticks": {
"color": "#c3c3c3"
},
"time": {
"displayFormats": {
"day": "dd MMM yy"
},
"unit": "day"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "datetime"
},
"type": "timeseries"
},
"y": {
"grid": {
"color": "#393939"
},
"position": "left",
"ticks": {
"color": "#c3c3c3"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "km"
}
},
"y1": {
"grid": {
"color": "#393939"
},
"position": "right",
"ticks": {
"color": "#c3c3c3"
},
"title": {
"color": "#c3c3c3",
"display": true,
"font": {
"size": 16
},
"text": "pace /km"
}
}
}
}
}
]

17 changes: 17 additions & 0 deletions test/unit/goldens/testParseExampleChartRequestsToml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,22 @@ MkChartRequests
, yAxis = YAxisPace
, y1Axis = Nothing
}
, MkChartRequest
{ description = Nothing
, filters =
[ Atom
( FilterDistance MkFilterOp >= _
( MkSomeDistance SKilometer
( MkDistance
( UnsafePositive 25.0 ) Kilometer
)
)
)
]
, title = "Long runs"
, unit = Nothing
, yAxis = YAxisDistance
, y1Axis = Just YAxisPace
}
]
}

0 comments on commit 60e2c11

Please sign in to comment.