Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/core/component.builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Chart, ChartData, ChartDataset, ChartOptions, ChartType, Plugin } from 'chart.js';
import * as Chartjs from 'chart.js';
import { cloneDeep, isEmpty, isEqual, isObject } from 'lodash-es';
import { cloneDeep, cloneDeepWith, isEmpty, isEqual, isObject, isArray } from 'lodash-es';
import { pascalCase } from '../utils';
import {
ComponentOptionsMixin,
Expand Down Expand Up @@ -121,7 +121,14 @@ export const defineChartComponent = <TType extends ChartType = ChartType>(

// Update attributes individually to avoid re-rendering the entire chart
for (const attribute in dataset) {
const attrValue = cloneDeep(dataset[attribute as keyof ChartDataset]);
function keepInstancesIntactCloneCustomizer<T extends unknown>(value: T): T|undefined {
if(!isObject(value)) return;
if(value.constructor.name === 'Object') return;
if(isArray(value)) return;
return value;
}

const attrValue = cloneDeepWith(dataset[attribute as keyof ChartDataset], keepInstancesIntactCloneCustomizer);
let datasetItem = chart.data.datasets[index] as any;
if (!datasetItem) {
chart.data.datasets[index] = {} as any;
Expand Down