mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Refactored realtime page. Fixed render issue.
This commit is contained in:
parent
42f184584f
commit
35fde36b61
11 changed files with 152 additions and 172 deletions
|
|
@ -21,6 +21,7 @@ export interface BarChartProps {
|
|||
XAxisType?: string;
|
||||
YAxisType?: string;
|
||||
renderTooltipPopup?: (setTooltipPopup: (data: any) => void, model: any) => void;
|
||||
updateMode?: string;
|
||||
onCreate?: (chart: any) => void;
|
||||
onUpdate?: (chart: any) => void;
|
||||
className?: string;
|
||||
|
|
@ -37,6 +38,7 @@ export function BarChart({
|
|||
XAxisType = 'time',
|
||||
YAxisType = 'linear',
|
||||
renderTooltipPopup,
|
||||
updateMode,
|
||||
onCreate,
|
||||
onUpdate,
|
||||
className,
|
||||
|
|
@ -136,25 +138,16 @@ export function BarChart({
|
|||
const updateChart = (datasets: any[]) => {
|
||||
setTooltipPopup(null);
|
||||
|
||||
const diff = chart.current.data.datasets.reduce(
|
||||
(found: boolean, dataset: { data: any[] }, set: number) => {
|
||||
if (!found) {
|
||||
return dataset.data.find((value, index) => {
|
||||
return datasets[set].data[index].y !== value.y;
|
||||
});
|
||||
}
|
||||
return found;
|
||||
},
|
||||
false,
|
||||
);
|
||||
chart.current.data.datasets.forEach((dataset: { data: any }, index: string | number) => {
|
||||
dataset.data = datasets[index].data;
|
||||
});
|
||||
|
||||
if (diff) {
|
||||
chart.current.data.datasets = datasets;
|
||||
chart.current.options = getOptions();
|
||||
chart.current.update();
|
||||
chart.current.options = getOptions();
|
||||
|
||||
onUpdate?.(chart.current);
|
||||
}
|
||||
// Allow config changes before update
|
||||
onUpdate?.(chart.current);
|
||||
|
||||
chart.current.update(updateMode);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue