feat: assen bij de luchtdrukgrafiek
De lijn had geen schaal, dus je kon niet zien hoeveel hPa de uitslag was of wanneer een dip viel. Nu links de hoogste en laagste waarde van het venster in hele hPa, uitgelijnd op boven- en onderkant van de lijn, en eronder vijf tijdlabels (0/25/50/75/100% van het venster) met "nu" rechts, ondersteund door drie lichte verticale hulplijnen. Posities komen uit de pure functie axisMarks(), met tests. De losse tekst "1009 – 1015 hPa in 24 u" in de kopregel vervalt: de y-as zegt hetzelfde en de x-as maakt het venster duidelijk. De extra labelrij past door de marge onder de grote temperatuur 8px te krappen; er blijft 5px speling boven en onder de hero. Servicewerker naar v8. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+26
-1
@@ -121,7 +121,7 @@ test('msUntil computes the wait until the next local time', () => {
|
||||
|
||||
import {
|
||||
co2Level, fPct, fHpa, seriesRange, sparklinePath, sparklinePoints,
|
||||
windArrowDeg, fKmh, formatHour, formatFullDate, pinRoom,
|
||||
windArrowDeg, fKmh, formatHour, formatFullDate, pinRoom, axisMarks,
|
||||
} from '../../public/format.js';
|
||||
|
||||
test('co2Level uses the Netatmo thresholds', () => {
|
||||
@@ -208,3 +208,28 @@ test('pinRoom does not mutate the input array', () => {
|
||||
pinRoom(rooms, 'c');
|
||||
assert.deepEqual(rooms, original);
|
||||
});
|
||||
|
||||
test('axisMarks maps fractions to indices and percentages', () => {
|
||||
// 49 punten = 24 uur per half uur
|
||||
assert.deepEqual(axisMarks(49), [
|
||||
{ index: 0, percent: 0 },
|
||||
{ index: 12, percent: 25 },
|
||||
{ index: 24, percent: 50 },
|
||||
{ index: 36, percent: 75 },
|
||||
{ index: 48, percent: 100 },
|
||||
]);
|
||||
});
|
||||
|
||||
test('axisMarks honours custom fractions and rounds to the nearest point', () => {
|
||||
assert.deepEqual(axisMarks(10, [0, 0.5, 1]), [
|
||||
{ index: 0, percent: 0 },
|
||||
{ index: 5, percent: 50 },
|
||||
{ index: 9, percent: 100 },
|
||||
]);
|
||||
assert.deepEqual(axisMarks(4, [0.33]), [{ index: 1, percent: 33 }]);
|
||||
});
|
||||
|
||||
test('axisMarks gives nothing to label below two points', () => {
|
||||
assert.deepEqual(axisMarks(1), []);
|
||||
assert.deepEqual(axisMarks(0), []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user