mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
add HoverColumns.svelte for hoverzone styling
This commit is contained in:
parent
7bc41366e8
commit
9dc6e059f2
10 changed files with 32 additions and 18 deletions
|
@ -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 HoverColumns from "./HoverColumns.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;
|
||||||
|
@ -36,7 +37,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" />
|
<HoverColumns />
|
||||||
<AxisTicks {bounds} />
|
<AxisTicks {bounds} />
|
||||||
<NoDataOverlay {bounds} {i18n} />
|
<NoDataOverlay {bounds} {i18n} />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
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 CumulativeOverlay from "./CumulativeOverlay.svelte";
|
||||||
|
import HoverColumns from "./HoverColumns.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 +20,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" />
|
<HoverColumns />
|
||||||
<CumulativeOverlay />
|
<CumulativeOverlay />
|
||||||
<AxisTicks {bounds} />
|
<AxisTicks {bounds} />
|
||||||
<NoDataOverlay {bounds} {i18n} />
|
<NoDataOverlay {bounds} {i18n} />
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
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";
|
import CumulativeOverlay from "./CumulativeOverlay.svelte";
|
||||||
|
import HoverColumns from "./HoverColumns.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;
|
||||||
|
@ -37,7 +38,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" />
|
||||||
<CumulativeOverlay />
|
<CumulativeOverlay />
|
||||||
<g class="hoverzone" />
|
<HoverColumns />
|
||||||
<AxisTicks {bounds} />
|
<AxisTicks {bounds} />
|
||||||
<NoDataOverlay {bounds} {i18n} />
|
<NoDataOverlay {bounds} {i18n} />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
19
ts/graphs/HoverColumns.svelte
Normal file
19
ts/graphs/HoverColumns.svelte
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!--
|
||||||
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
-->
|
||||||
|
<style lang="scss">
|
||||||
|
.hover-columns {
|
||||||
|
:global(rect) {
|
||||||
|
fill: none;
|
||||||
|
pointer-events: all;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
fill: grey;
|
||||||
|
opacity: 0.05;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<g class="hover-columns" />
|
|
@ -10,6 +10,7 @@
|
||||||
import CumulativeOverlay from "./CumulativeOverlay.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";
|
||||||
|
import HoverColumns from "./HoverColumns.svelte";
|
||||||
|
|
||||||
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
export let sourceData: pb.BackendProto.GraphsOut | null = null;
|
||||||
export let revlogRange: RevlogRange;
|
export let revlogRange: RevlogRange;
|
||||||
|
@ -65,7 +66,7 @@
|
||||||
<g class="bars{i}" />
|
<g class="bars{i}" />
|
||||||
{/each}
|
{/each}
|
||||||
<CumulativeOverlay />
|
<CumulativeOverlay />
|
||||||
<g class="hoverzone" />
|
<HoverColumns />
|
||||||
<AxisTicks {bounds} />
|
<AxisTicks {bounds} />
|
||||||
<NoDataOverlay {bounds} {i18n} />
|
<NoDataOverlay {bounds} {i18n} />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -248,7 +248,7 @@ export function renderButtons(
|
||||||
return `${button}: ${d.buttonNum}<br>${timesPressed}: ${d.count}<br>${correctStr}`;
|
return `${button}: ${d.buttonNum}<br>${timesPressed}: ${d.count}<br>${correctStr}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
svg.select("g.hoverzone")
|
svg.select("g.hover-columns")
|
||||||
.selectAll("rect")
|
.selectAll("rect")
|
||||||
.data(data)
|
.data(data)
|
||||||
.join("rect")
|
.join("rect")
|
||||||
|
|
|
@ -104,16 +104,6 @@
|
||||||
padding-right: 0.5em;
|
padding-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hoverzone rect {
|
|
||||||
fill: none;
|
|
||||||
pointer-events: all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hoverzone rect:hover {
|
|
||||||
fill: grey;
|
|
||||||
opacity: 0.05;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
0% {
|
0% {
|
||||||
-webkit-transform: rotate(0deg);
|
-webkit-transform: rotate(0deg);
|
||||||
|
|
|
@ -161,7 +161,7 @@ export function histogramGraph(
|
||||||
|
|
||||||
// hover/tooltip
|
// hover/tooltip
|
||||||
const hoverzone = svg
|
const hoverzone = svg
|
||||||
.select("g.hoverzone")
|
.select("g.hover-columns")
|
||||||
.selectAll("rect")
|
.selectAll("rect")
|
||||||
.data(hoverData)
|
.data(hoverData)
|
||||||
.join("rect")
|
.join("rect")
|
||||||
|
|
|
@ -202,7 +202,7 @@ export function renderHours(
|
||||||
}
|
}
|
||||||
|
|
||||||
// hover/tooltip
|
// hover/tooltip
|
||||||
svg.select("g.hoverzone")
|
svg.select("g.hover-columns")
|
||||||
.selectAll("rect")
|
.selectAll("rect")
|
||||||
.data(data)
|
.data(data)
|
||||||
.join("rect")
|
.join("rect")
|
||||||
|
|
|
@ -367,7 +367,7 @@ export function renderReviews(
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// hover/tooltip
|
// hover/tooltip
|
||||||
svg.select("g.hoverzone")
|
svg.select("g.hover-columns")
|
||||||
.selectAll("rect")
|
.selectAll("rect")
|
||||||
.data(hoverData)
|
.data(hoverData)
|
||||||
.join("rect")
|
.join("rect")
|
||||||
|
|
Loading…
Reference in a new issue