From 1d62065c189ff6f55aac4e315b5a8499f11d5014 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 25 Feb 2021 17:51:29 -0800 Subject: [PATCH] Document HAnnotations + LineChart with a story --- ui/stories/charts/line-chart.stories.js | 46 ++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/ui/stories/charts/line-chart.stories.js b/ui/stories/charts/line-chart.stories.js index 4f1f9219f..0632c30cc 100644 --- a/ui/stories/charts/line-chart.stories.js +++ b/ui/stories/charts/line-chart.stories.js @@ -176,7 +176,7 @@ export let Gaps = () => { }; }; -export let Annotations = () => { +export let VerticalAnnotations = () => { return { template: hbs`
Line Chart data with annotations
@@ -278,6 +278,50 @@ export let Annotations = () => { }; }; +export let HorizontalAnnotations = () => { + return { + template: hbs` +
+ {{#if (and this.data this.annotations)}} + + <:svg as |c|> + + + <:after as |c|> + + + + {{/if}} +
+ `, + context: { + data: DelayedArray.create( + new Array(180).fill(null).map((_, idx) => ({ + y: Math.sin((idx * 4 * Math.PI) / 180) * 100 + 200, + x: moment() + .add(idx, 'd') + .toDate(), + })) + ), + annotations: [ + { + y: 300, + info: 'High', + }, + { + y: 100, + info: 'Low', + }, + ], + }, + }; +}; + export let StepLine = () => { return { template: hbs`