diff --git a/ts/graphs/AddedGraph.svelte b/ts/graphs/AddedGraph.svelte index ed30aec2b..1f541fd99 100644 --- a/ts/graphs/AddedGraph.svelte +++ b/ts/graphs/AddedGraph.svelte @@ -10,13 +10,16 @@ import GraphRangeRadios from "./GraphRangeRadios.svelte"; import TableData from "./TableData.svelte"; import { createEventDispatcher } from "svelte"; + import type { PreferenceStore } from "./preferences"; export let sourceData: pb.BackendProto.GraphsOut | null = null; export let i18n: I18n; + export let preferences: PreferenceStore; let histogramData = null as HistogramData | null; let tableData: TableDatum[] = []; let graphRange: GraphRange = GraphRange.Month; + let { browserLinksSupported } = preferences; const dispatch = createEventDispatcher(); @@ -26,7 +29,13 @@ } $: if (addedData) { - [histogramData, tableData] = buildHistogram(addedData, graphRange, i18n, dispatch); + [histogramData, tableData] = buildHistogram( + addedData, + graphRange, + i18n, + dispatch, + $browserLinksSupported + ); } const title = i18n.tr(i18n.TR.STATISTICS_ADDED_TITLE); @@ -42,7 +51,7 @@ - + diff --git a/ts/graphs/EaseGraph.svelte b/ts/graphs/EaseGraph.svelte index 559334e9f..7a6e24c83 100644 --- a/ts/graphs/EaseGraph.svelte +++ b/ts/graphs/EaseGraph.svelte @@ -7,17 +7,25 @@ import type { TableDatum } from "./graph-helpers"; import TableData from "./TableData.svelte"; import { createEventDispatcher } from "svelte"; + import type { PreferenceStore } from "./preferences"; export let sourceData: pb.BackendProto.GraphsOut | null = null; export let i18n: I18n; + export let preferences: PreferenceStore; const dispatch = createEventDispatcher(); let histogramData = null as HistogramData | null; let tableData: TableDatum[] = []; + let { browserLinksSupported } = preferences; $: if (sourceData) { - [histogramData, tableData] = prepareData(gatherData(sourceData), i18n, dispatch); + [histogramData, tableData] = prepareData( + gatherData(sourceData), + i18n, + dispatch, + $browserLinksSupported + ); } const title = i18n.tr(i18n.TR.STATISTICS_CARD_EASE_TITLE); @@ -29,7 +37,7 @@
{subtitle}
- + diff --git a/ts/graphs/FutureDue.svelte b/ts/graphs/FutureDue.svelte index ffb27fe75..e7b504eda 100644 --- a/ts/graphs/FutureDue.svelte +++ b/ts/graphs/FutureDue.svelte @@ -10,9 +10,11 @@ import GraphRangeRadios from "./GraphRangeRadios.svelte"; import TableData from "./TableData.svelte"; import { createEventDispatcher } from "svelte"; + import type { PreferenceStore } from "./preferences"; export let sourceData: pb.BackendProto.GraphsOut | null = null; export let i18n: I18n; + export let preferences: PreferenceStore; const dispatch = createEventDispatcher(); @@ -21,6 +23,7 @@ let tableData: TableDatum[] = [] as any; let backlog: boolean = true; let graphRange: GraphRange = GraphRange.Month; + let { browserLinksSupported } = preferences; $: if (sourceData) { graphData = gatherData(sourceData); @@ -33,6 +36,7 @@ backlog, i18n, dispatch, + $browserLinksSupported )); } @@ -57,7 +61,7 @@ - + diff --git a/ts/graphs/HistogramGraph.svelte b/ts/graphs/HistogramGraph.svelte index 86347ad58..d178d33af 100644 --- a/ts/graphs/HistogramGraph.svelte +++ b/ts/graphs/HistogramGraph.svelte @@ -1,5 +1,4 @@ diff --git a/ts/graphs/IntervalsGraph.svelte b/ts/graphs/IntervalsGraph.svelte index 50d979be4..f77348bae 100644 --- a/ts/graphs/IntervalsGraph.svelte +++ b/ts/graphs/IntervalsGraph.svelte @@ -13,9 +13,11 @@ import type { TableDatum } from "./graph-helpers"; import TableData from "./TableData.svelte"; import { createEventDispatcher } from "svelte"; + import type { PreferenceStore } from "./preferences"; export let sourceData: pb.BackendProto.GraphsOut | null = null; export let i18n: I18n; + export let preferences: PreferenceStore; const dispatch = createEventDispatcher(); @@ -23,13 +25,20 @@ let histogramData = null as HistogramData | null; let tableData: TableDatum[] = []; let range = IntervalRange.Percentile95; + let { browserLinksSupported } = preferences; $: if (sourceData) { intervalData = gatherIntervalData(sourceData); } $: if (intervalData) { - [histogramData, tableData] = prepareIntervalData(intervalData, range, i18n, dispatch); + [histogramData, tableData] = prepareIntervalData( + intervalData, + range, + i18n, + dispatch, + $browserLinksSupported + ); } const title = i18n.tr(i18n.TR.STATISTICS_INTERVALS_TITLE); @@ -62,7 +71,7 @@ - + diff --git a/ts/graphs/added.ts b/ts/graphs/added.ts index 3574cf959..a68fd875f 100644 --- a/ts/graphs/added.ts +++ b/ts/graphs/added.ts @@ -44,6 +44,7 @@ export function buildHistogram( range: GraphRange, i18n: I18n, dispatch: any, + browserLinksSupported: boolean ): [HistogramData | null, TableDatum[]] { // get min/max const total = data.daysAdded.length; @@ -127,7 +128,7 @@ export function buildHistogram( bins, total: totalInPeriod, hoverText, - onClick, + onClick: browserLinksSupported ? onClick : null, colourScale, showArea: true, }, diff --git a/ts/graphs/ease.ts b/ts/graphs/ease.ts index a083960d4..9468f7c04 100644 --- a/ts/graphs/ease.ts +++ b/ts/graphs/ease.ts @@ -41,6 +41,7 @@ export function prepareData( data: GraphData, i18n: I18n, dispatch: any, + browserLinksSupported: boolean ): [HistogramData | null, TableDatum[]] { // get min/max const allEases = data.eases; @@ -94,7 +95,7 @@ export function prepareData( bins, total, hoverText, - onClick, + onClick: browserLinksSupported ? onClick : null, colourScale, showArea: false, xTickFormat, diff --git a/ts/graphs/future-due.ts b/ts/graphs/future-due.ts index 498e8dff9..fbd0f880f 100644 --- a/ts/graphs/future-due.ts +++ b/ts/graphs/future-due.ts @@ -75,8 +75,7 @@ export interface FutureDueOut { function makeQuery(start: number, end: number): string { if (start === end) { return `"prop:due=${start}"`; - } - else { + } else { const fromQuery = `"prop:due>=${start}"`; const tillQuery = `"prop:due<=${end}"`; return `${fromQuery} AND ${tillQuery}`; @@ -89,6 +88,7 @@ export function buildHistogram( backlog: boolean, i18n: I18n, dispatch: any, + browserLinksSupported: boolean ): FutureDueOut { const output = { histogramData: null, tableData: [] }; // get min/max @@ -190,7 +190,7 @@ export function buildHistogram( bins, total, hoverText, - onClick, + onClick: browserLinksSupported ? onClick : null, showArea: true, colourScale, binValue, diff --git a/ts/graphs/histogram-graph.ts b/ts/graphs/histogram-graph.ts index f22b31850..4cf1a0d76 100644 --- a/ts/graphs/histogram-graph.ts +++ b/ts/graphs/histogram-graph.ts @@ -25,7 +25,7 @@ export interface HistogramData { cumulative: number, percent: number ) => string; - onClick?: (data: Bin) => void; + onClick: ((data: Bin) => void) | null; showArea: boolean; colourScale: ScaleSequential; binValue?: (bin: Bin) => number; @@ -35,7 +35,7 @@ export interface HistogramData { export function histogramGraph( svgElem: SVGElement, bounds: GraphBounds, - data: HistogramData | null, + data: HistogramData | null ): void { const svg = select(svgElem); const trans = svg.transition().duration(600) as any; @@ -162,8 +162,6 @@ export function histogramGraph( .on("mouseout", hideTooltip); if (data.onClick) { - hoverzone - .attr("class", "clickable") - .on("click", data.onClick); + hoverzone.attr("class", "clickable").on("click", data.onClick); } } diff --git a/ts/graphs/intervals.ts b/ts/graphs/intervals.ts index 9d652eb2f..91741e3dc 100644 --- a/ts/graphs/intervals.ts +++ b/ts/graphs/intervals.ts @@ -72,6 +72,7 @@ export function prepareIntervalData( range: IntervalRange, i18n: I18n, dispatch: any, + browserLinksSupported: boolean ): [HistogramData | null, TableDatum[]] { // get min/max const allIntervals = data.intervals; @@ -161,13 +162,14 @@ export function prepareIntervalData( value: meanIntervalString, }, ]; + return [ { scale, bins, total: totalInPeriod, hoverText, - onClick, + onClick: browserLinksSupported ? onClick : null, colourScale, showArea: true, },