Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.1</Version>
<Version>10.0.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ const getChartOption = function (option) {
}
}

// pie 图除外默认显示 网格线与坐标系
if (option.type !== 'pie' && option.type !== 'doughnut') {
if (option.options.showXScales === null) {
scale.x.display = true
Expand Down Expand Up @@ -491,7 +490,13 @@ export function init(id, invoke, method, option) {
}

export function update(id, option, method, angle) {
const { invoke, chart } = Data.get(id)
const { invoke, chart } = Data.get(id);
option.data.forEach(d => {
const l = chart.legend.legendItems.find(i => i.text === d.label);
if(l) {
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after 'if' keyword. JavaScript convention and most style guides recommend a space between 'if' and the opening parenthesis for better readability.

Suggested change
if(l) {
if (l) {

Copilot uses AI. Check for mistakes.
Comment on lines +494 to +496
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nested iteration pattern has O(n*m) time complexity where n is the number of data items and m is the number of legend items. For large datasets, consider creating a Map from legendItems indexed by text before the forEach loop to improve performance to O(n+m).

Suggested change
option.data.forEach(d => {
const l = chart.legend.legendItems.find(i => i.text === d.label);
if(l) {
const legendItems = chart && chart.legend && Array.isArray(chart.legend.legendItems)
? chart.legend.legendItems
: [];
const legendItemMap = new Map();
legendItems.forEach(item => {
legendItemMap.set(item.text, item);
});
option.data.forEach(d => {
const l = legendItemMap.get(d.label);
if (l) {

Copilot uses AI. Check for mistakes.
d.hidden = l.hidden;
}
});
Comment on lines +494 to +499
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes option.data is iterable but doesn't check for null/undefined. If option.data is null or undefined, this will throw a runtime error. Add a defensive check to ensure option.data exists before calling forEach.

Suggested change
option.data.forEach(d => {
const l = chart.legend.legendItems.find(i => i.text === d.label);
if(l) {
d.hidden = l.hidden;
}
});
if (Array.isArray(option.data)) {
option.data.forEach(d => {
const l = chart.legend.legendItems.find(i => i.text === d.label);
if (l) {
d.hidden = l.hidden;
}
});
}

Copilot uses AI. Check for mistakes.
Comment on lines +494 to +499
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code lacks proper null/undefined safety checks. If chart.legend is null/undefined or chart.legend.legendItems is null/undefined, this code will throw a runtime error. This can happen when the legend is disabled (showLegend: false) or in certain chart configurations. Add defensive checks to ensure these properties exist before attempting to access them.

Suggested change
option.data.forEach(d => {
const l = chart.legend.legendItems.find(i => i.text === d.label);
if(l) {
d.hidden = l.hidden;
}
});
const legendItems = chart && chart.legend && chart.legend.legendItems;
if (Array.isArray(option.data) && Array.isArray(legendItems)) {
option.data.forEach(d => {
const l = legendItems.find(i => i.text === d.label);
if (l) {
d.hidden = l.hidden;
}
});
}

Copilot uses AI. Check for mistakes.
let op = getChartOption(option);
handlerClickData(invoke, op, option.options.onClickDataMethod);
op.angle = angle
Expand Down