mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-24 01:48:18 +03:00
Recovered function to render pie chart labels
This commit is contained in:
parent
0572bc2854
commit
d55160e8f6
2 changed files with 10 additions and 4 deletions
|
@ -6,7 +6,13 @@ export const pointerOnHover = ({ native }: ChartEvent, [ firstElement ]: ActiveE
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(native.target as any).style.cursor = firstElement ? 'pointer' : 'default';
|
const canvas = native.target as HTMLCanvasElement;
|
||||||
|
|
||||||
|
canvas.style.cursor = firstElement ? 'pointer' : 'default';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const renderChartLabel = ({ dataset, label }: TooltipItem<ChartType>) => `${dataset.label}: ${prettify(label)}`;
|
export const renderChartLabel = ({ dataset, formattedValue }: TooltipItem<ChartType>) =>
|
||||||
|
`${dataset.label}: ${prettify(formattedValue)}`;
|
||||||
|
|
||||||
|
export const renderPieChartLabel = ({ label, formattedValue }: TooltipItem<ChartType>) =>
|
||||||
|
`${label}: ${prettify(formattedValue)}`;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { Chart, ChartData, ChartDataset, ChartOptions, LegendItem } from 'chart.
|
||||||
import { fillTheGaps } from '../../utils/helpers/visits';
|
import { fillTheGaps } from '../../utils/helpers/visits';
|
||||||
import { Stats } from '../types';
|
import { Stats } from '../types';
|
||||||
import { prettify } from '../../utils/helpers/numbers';
|
import { prettify } from '../../utils/helpers/numbers';
|
||||||
import { pointerOnHover, renderChartLabel } from '../../utils/helpers/charts';
|
import { pointerOnHover, renderChartLabel, renderPieChartLabel } from '../../utils/helpers/charts';
|
||||||
import {
|
import {
|
||||||
HIGHLIGHTED_COLOR,
|
HIGHLIGHTED_COLOR,
|
||||||
HIGHLIGHTED_COLOR_ALPHA,
|
HIGHLIGHTED_COLOR_ALPHA,
|
||||||
|
@ -149,7 +149,7 @@ const DefaultChart = (
|
||||||
// Do not show tooltip on items with empty label when in a bar chart
|
// Do not show tooltip on items with empty label when in a bar chart
|
||||||
filter: ({ label }) => !isBarChart || label !== '',
|
filter: ({ label }) => !isBarChart || label !== '',
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: renderChartLabel,
|
label: isBarChart ? renderChartLabel : renderPieChartLabel,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue