You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attaching the 'brushEnd' listener inside a debounced loader without cleanup can register multiple handlers over time.
constechartsLoaded=debounce((chart)=>{// Fires only once when brush is releasedchart.on("brushEnd",(params)=>{if(!params.areas||!params.areas.length)return;constarea=params.areas[0];// Get xAxis dataconstcurrentOption=chart.getOption();constlabelData=currentOption.series[0].data||[];constxAxisData=currentOption.xAxis?.[0]?.data||[];letindices=[];if(area.coordRange&&area.coordRange.length===2){const[xRange,yRange]=area.coordRange;constxIndices=[];for(leti=xRange[0];i<=xRange[1];i++)xIndices.push(i);constyIndices=[];for(leti=0;i<labelData.length;i++){constval=labelData[i];if(val>=yRange[0]&&val<=yRange[1])yIndices.push(i);}indices=xIndices.filter((i)=>yIndices.includes(i));constfilteredLabels=indices.map((i)=>xAxisData[i]);constfilteredValues=indices.map((i)=>labelData[i]);if(filteredValues.length>0){frame.filter(`SetFrameFilter(((${currentOption.series[0]?.name}==[${filteredValues}]) AND (${currentOption.xAxis?.[0]?.name}==[${filteredLabels}])))`,);}}});},2000);
Constructing filter strings by interpolating unescaped series names and values may lead to invalid syntax or unintended behavior.
frame.filter(`SetFrameFilter(((${currentOption.series[0]?.name}==[${filteredValues}]) AND (${currentOption.xAxis?.[0]?.name}==[${filteredLabels}])))`,);}
Ensure the brush range indices are valid integers and within the bounds of the data array to avoid out-of-range or fractional index errors. Clamp and round the start/end values before iterating.
-for (let i = xRange[0]; i <= xRange[1]; i++) xIndices.push(i);+const startIdx = Math.max(0, Math.ceil(xRange[0]));+const endIdx = Math.min(labelData.length - 1, Math.floor(xRange[1]));+const xIndices: number[] = [];+for (let i = startIdx; i <= endIdx; i++) {+ xIndices.push(i);+}
Suggestion importance[1-10]: 7
__
Why: This guards against out-of-range or fractional brush indices by clamping and rounding, improving robustness without altering core functionality.
Medium
Safely extract numeric point values
Safely extract a numeric value from each data point in case the series items are objects. Fallback to the raw value if no numeric value property exists.
for (let i = 0; i < labelData.length; i++) {
- const val = labelData[i];- if (val >= yRange[0] && val <= yRange[1]) yIndices.push(i);+ const raw = labelData[i];+ const val = typeof raw === 'object' && raw.value != null ? raw.value : raw;+ if (val >= yRange[0] && val <= yRange[1]) {+ yIndices.push(i);+ }
}
Suggestion importance[1-10]: 5
__
Why: Extracting numeric values from possible object data adds safety for varied series item formats, but the impact is limited if data is already primitive.
Low
General
Serialize filter arrays correctly
Use JSON.stringify for the arrays in the filter expression to ensure proper quoting and formatting of values.
frame.filter(
- `SetFrameFilter(((${currentOption.series[0]?.name}==[${filteredValues}]) AND (${currentOption.xAxis?.[0]?.name}==[${filteredLabels}])))`,+ `SetFrameFilter((${currentOption.series[0]?.name}==${JSON.stringify(filteredValues)} AND ${currentOption.xAxis?.[0]?.name}==${JSON.stringify(filteredLabels)}))`
);
Suggestion importance[1-10]: 7
__
Why: Using JSON.stringify ensures proper quoting and formatting in the frame filter expression, preventing potential parsing errors.
Add interactive brushing filter for line charts and restrict brush tool to rectangle and clear
to commit the new content to the CHANGELOG.md file, please type:
'/update_changelog --pr_update_changelog.push_changelog_changes=true'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Changes Made
How to Test
Notes