Skip to content

Instantly share code, notes, and snippets.

@kwando
Last active September 19, 2026 12:10
Show Gist options
  • Select an option

  • Save kwando/38ad1c0f684a50e0f501f331b5aa020b to your computer and use it in GitHub Desktop.

Select an option

Save kwando/38ad1c0f684a50e0f501f331b5aa020b to your computer and use it in GitHub Desktop.
Infer ticks bug
pub fn main() {
let start = t("2026-09-19T11:42:45.879Z")
let end = t("2026-09-19T11:57:45.879Z")
let values = [
#(t("2026-09-19T11:42:46Z"), 13.28),
#(t("2026-09-19T11:46:06Z"), 13.28),
#(t("2026-09-19T11:49:26Z"), 13.28),
#(t("2026-09-19T11:52:46Z"), 13.28),
#(t("2026-09-19T11:56:06Z"), 13.28),
]
let y = axis.float()
let x =
axis.timestamp()
|> axis.infer_ticks(5)
|> axis.min(start)
|> axis.max(end)
|> axis.show_labels(fn(label) {
timestamp.to_calendar(label, calendar.local_offset())
|> pair.second
|> format_time
})
let points =
list.map(values, fn(val) {
let #(timestamp, float) = val
chart.point(timestamp, float, [])
})
chart.new(x:, y:)
|> chart.add(chart.line([], points))
|> chart.to_svg(width: 800, height: 400)
}
fn format_time(time: calendar.TimeOfDay) {
time.hours |> int.to_string |> string.pad_start(2, "0")
<> ":"
<> time.minutes |> int.to_string |> string.pad_start(2, "0")
}
fn t(ts: String) {
let assert Ok(ts) = timestamp.parse_rfc3339(ts)
ts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment