add CumulativeOverlay.svelte for area styling

This commit is contained in:
Damien Elmes 2021-03-21 19:50:35 +10:00
parent 6e12348cfd
commit 7bc41366e8
8 changed files with 24 additions and 14 deletions

View File

@ -0,0 +1,15 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<style lang="scss">
.cumulative-overlay {
pointer-events: none;
fill: var(--area-fill);
fill-opacity: var(--area-fill-opacity);
stroke: var(--area-stroke);
stroke-opacity: var(--area-stroke-opacity);
}
</style>
<path class="cumulative-overlay" />

View File

@ -4,6 +4,7 @@
import AxisTicks from "./AxisTicks.svelte"; import AxisTicks from "./AxisTicks.svelte";
import { defaultGraphBounds } from "./graph-helpers"; import { defaultGraphBounds } from "./graph-helpers";
import NoDataOverlay from "./NoDataOverlay.svelte"; import NoDataOverlay from "./NoDataOverlay.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
import type { I18n } from "anki/i18n"; import type { I18n } from "anki/i18n";
export let data: HistogramData | null = null; export let data: HistogramData | null = null;
@ -18,7 +19,7 @@
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}> <svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
<g class="bars" /> <g class="bars" />
<g class="hoverzone" /> <g class="hoverzone" />
<path class="area" /> <CumulativeOverlay />
<AxisTicks {bounds} /> <AxisTicks {bounds} />
<NoDataOverlay {bounds} {i18n} /> <NoDataOverlay {bounds} {i18n} />
</svg> </svg>

View File

@ -6,6 +6,7 @@
import type { I18n } from "anki/i18n"; import type { I18n } from "anki/i18n";
import NoDataOverlay from "./NoDataOverlay.svelte"; import NoDataOverlay from "./NoDataOverlay.svelte";
import GraphRangeRadios from "./GraphRangeRadios.svelte"; import GraphRangeRadios from "./GraphRangeRadios.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
export let sourceData: pb.BackendProto.GraphsOut | null = null; export let sourceData: pb.BackendProto.GraphsOut | null = null;
export let i18n: I18n; export let i18n: I18n;
@ -35,7 +36,7 @@
<svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}> <svg bind:this={svg} viewBox={`0 0 ${bounds.width} ${bounds.height}`}>
<g class="bars" /> <g class="bars" />
<path class="area" /> <CumulativeOverlay />
<g class="hoverzone" /> <g class="hoverzone" />
<AxisTicks {bounds} /> <AxisTicks {bounds} />
<NoDataOverlay {bounds} {i18n} /> <NoDataOverlay {bounds} {i18n} />

View File

@ -7,6 +7,7 @@
import type pb from "anki/backend_proto"; import type pb from "anki/backend_proto";
import type { I18n } from "anki/i18n"; import type { I18n } from "anki/i18n";
import NoDataOverlay from "./NoDataOverlay.svelte"; import NoDataOverlay from "./NoDataOverlay.svelte";
import CumulativeOverlay from "./CumulativeOverlay.svelte";
import GraphRangeRadios from "./GraphRangeRadios.svelte"; import GraphRangeRadios from "./GraphRangeRadios.svelte";
import TableData from "./TableData.svelte"; import TableData from "./TableData.svelte";
@ -63,7 +64,7 @@
{#each [4, 3, 2, 1, 0] as i} {#each [4, 3, 2, 1, 0] as i}
<g class="bars{i}" /> <g class="bars{i}" />
{/each} {/each}
<path class="area" /> <CumulativeOverlay />
<g class="hoverzone" /> <g class="hoverzone" />
<AxisTicks {bounds} /> <AxisTicks {bounds} />
<NoDataOverlay {bounds} {i18n} /> <NoDataOverlay {bounds} {i18n} />

View File

@ -104,14 +104,6 @@
padding-right: 0.5em; padding-right: 0.5em;
} }
.graph .area {
pointer-events: none;
fill: var(--area-fill);
fill-opacity: var(--area-fill-opacity);
stroke: var(--area-stroke);
stroke-opacity: var(--area-stroke-opacity);
}
.hoverzone rect { .hoverzone rect {
fill: none; fill: none;
pointer-events: all; pointer-events: all;

View File

@ -133,7 +133,7 @@ export function histogramGraph(
.tickSizeOuter(0) .tickSizeOuter(0)
); );
svg.select("path.area") svg.select("path.cumulative-overlay")
.datum(areaData as any) .datum(areaData as any)
.attr( .attr(
"d", "d",

View File

@ -171,7 +171,7 @@ export function renderHours(
.tickSizeOuter(0) .tickSizeOuter(0)
); );
svg.select("path.area") svg.select("path.cumulative-overlay")
.datum(data) .datum(data)
.attr( .attr(
"d", "d",

View File

@ -340,7 +340,7 @@ export function renderReviews(
.tickSizeOuter(0) .tickSizeOuter(0)
); );
svg.select("path.area") svg.select("path.cumulative-overlay")
.datum(areaData as any) .datum(areaData as any)
.attr( .attr(
"d", "d",