mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 05:42:36 +08:00
Some improvements thanks to feedback :) - One highlight is this: <img width="936" height="247" alt="Screenshot 2026-06-19 at 2 42 37 PM" src="https://github.com/user-attachments/assets/9366d6c8-5890-4b0c-8dfe-e49b8557b4c0" /> - the new chart options allow memory, i.e. if you go back to the DE query page, it will remember your option as well - few rows of "text, num" results default to bar chart - (related to above) numerous rows of "text, num" results default to table, chart available - numerous rows of "date, num" results default to line chart, with bar available - sparse "text, num, num" results default to table (ganncamp on meta) - "date, num, num" results default to line chart, with dual axis available ✨ - numerous "date, numeric" results defaults to table - looser "date" definition, i.e. "MMM DD" or "MMM YY" is a date, line chart (tyler-mairose-sp on meta)
36 lines
1.1 KiB
JavaScript
Vendored
36 lines
1.1 KiB
JavaScript
Vendored
import { module, test } from "qunit";
|
|
import {
|
|
formatChartDateLabel,
|
|
looksLikeDate,
|
|
} from "../../discourse/lib/chart-helpers";
|
|
|
|
module("Unit | Lib | chart-helpers", function () {
|
|
test("detects compact date labels for chart defaults", function (assert) {
|
|
assert.true(looksLikeDate("Jan 03"), "detects month/day labels");
|
|
assert.true(looksLikeDate("Jan 24"), "detects month/year labels");
|
|
assert.true(looksLikeDate("Jan 2024"), "detects long month/year labels");
|
|
});
|
|
|
|
test("formats tooltip labels without inventing years for compact labels", function (assert) {
|
|
assert.strictEqual(
|
|
formatChartDateLabel("2024-01-03"),
|
|
"January 3, 2024",
|
|
"expands ISO dates"
|
|
);
|
|
assert.strictEqual(
|
|
formatChartDateLabel("Jan 03"),
|
|
"Jan 3",
|
|
"normalizes month/day labels"
|
|
);
|
|
assert.strictEqual(
|
|
formatChartDateLabel("Jan 24"),
|
|
"Jan 24",
|
|
"leaves ambiguous compact labels alone"
|
|
);
|
|
assert.strictEqual(
|
|
formatChartDateLabel("Jan 2024"),
|
|
"Jan 2024",
|
|
"leaves month/year labels alone"
|
|
);
|
|
});
|
|
});
|