diff --git a/src/lib/components/EventTooltip.svelte b/src/lib/components/EventTooltip.svelte index bc89408..2e49b1b 100644 --- a/src/lib/components/EventTooltip.svelte +++ b/src/lib/components/EventTooltip.svelte @@ -7,6 +7,8 @@ export let hoveredEventData; export let width; + $: console.log(hoveredEventData) +
.event-tooltip { position: fixed; - /*border: 1px solid #ccc;*/ background: rgba(255, 255, 255, 0.95); box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2); padding: 5px; diff --git a/src/lib/components/Legend.svelte b/src/lib/components/Legend.svelte index cb7b831..8b11cb8 100644 --- a/src/lib/components/Legend.svelte +++ b/src/lib/components/Legend.svelte @@ -3,6 +3,10 @@ export let margins export let radiusScale export let opacityScale + export let tooltipX + export let tooltipY + export let hoveredLegendData + export let showLegendTooltip $: minOpacity = opacityScale.domain()[0] $: maxOpacity = opacityScale.domain()[1] @@ -16,16 +20,39 @@ maxOpacity] let height = 70 + + const tooltipContent = { + "breakout_scale": "Breakout Scale represents a range from Category One to Category Six. The smallest point on the visualization represents 'Not Applicable', indicating attributions which lack suitable evidence to justify a Breakout Scale classification.", + "attribution_score": "The opacity of attributions corresponds to the 18-point Attribution Score which attempts to qualify the credibility of an attribution." + } + + function handleMouseOver(event, id) { + console.log(id) + showLegendTooltip = true; + tooltipX = event.clientX; + tooltipY = event.clientY; + hoveredLegendData = tooltipContent[id]; + } + function handleMouseOut() { + showLegendTooltip = false; + } - - + + handleMouseOver(e, "breakout_scale")} + on:focus={(e) => handleMouseOver(e, "breakout_scale")} + on:mouseout={handleMouseOut} + on:blur={handleMouseOut} + > Breakout Scale + >Breakout Scale {#each radiusScale.domain() as rad,i} {/each} + + + + handleMouseOver(e, "attribution_score")} + on:focus={(e) => handleMouseOver(e, "attribution_score")} + on:mouseout={handleMouseOut} + on:blur={handleMouseOut} +> {/each} + + import { fade } from 'svelte/transition'; + import { utcFormat } from 'd3-time-format'; + + export let tooltipX; + export let tooltipY; + export let hoveredLegendData; + export let width; + + + +
+ +

{hoveredLegendData}

+
+ + \ No newline at end of file diff --git a/src/lib/components/Timeline.svelte b/src/lib/components/Timeline.svelte index 4f9fe2e..de7def9 100644 --- a/src/lib/components/Timeline.svelte +++ b/src/lib/components/Timeline.svelte @@ -9,6 +9,7 @@ import Square from '$lib/components/Square.svelte'; import Tooltip from '$lib/components/Tooltip.svelte'; import EventTooltip from '$lib/components/EventTooltip.svelte'; + import LegendTooltip from '$lib/components/LegendTooltip.svelte'; import { actorNationFilter, timeRangeFilter } from '../../stores/filters'; import Legend from './Legend.svelte'; @@ -122,14 +123,25 @@ // Tooltip let showTooltip = false; let showEventTooltip = false; + let showLegendTooltip = false; let hoveredCaseData; let hoveredEventData; + let hoveredLegendData; let tooltipX; let tooltipY;
- + {#if xScale} @@ -323,6 +335,9 @@ {#if showEventTooltip} {/if} + {#if showLegendTooltip} + + {/if}