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
New code introduces numerous JSON.parse calls without any error handling. If the input string is not valid JSON, it could lead to runtime errors. Ensure that these calls are wrapped with try/catch or validated beforehand.
constfunctionCallReference=useRef({valuesResetCheck: false,assignedRules: [],applyRulesToChart: false,});constcolumnData=data.columns||[];// get the value of the input (wrapped in usememo because of path prop)constcomputedValue=useMemo(()=>{returncomputed(()=>{if(!data){return"";}constv=getValueByPath(data,path);if(typeofv==="undefined"){return"";}elseif(typeofv==="string"){returnv;}returnJSON.stringify(v,null,2);});},[data,path]).get();//initial setting of state data based on the json valueuseEffect(()=>{functionCallReference.current.applyRulesToChart=false;constoption=typeofcomputedValue==="string"
? JSON.parse(computedValue)
: computedValue;if(option.hasOwnProperty("customSettings")&&option["customSettings"].hasOwnProperty("appliedColourByValue")){constappliedRules=option["customSettings"]["appliedColourByValue"];setAppliedRules(appliedRules);}},[]);//whenever a computed value is changed, then respective change for colour by value component isuseEffect(()=>{setValue(computedValue);},[computedValue]);useEffect(()=>{if(functionCallReference.current.applyRulesToChart){constoption=typeofvalue==="string" ? JSON.parse(value) : value;letcolourObj={};letoptionUpdated=option;appliedRules.forEach((appliedItem,index)=>{constxAxisPosition=getXAxisPositions(appliedItem);//take all the series indexes to update the dataconstfilteredSeriesIndex=getFilteredSeriesIndex();if(xAxisPosition.length){filteredSeriesIndex.forEach((item,index)=>{constseriesIndexData=item;if(seriesIndexData>-1){constdata=option["series"][seriesIndexData]["data"];data.forEach((item,dataindex)=>{colourObj={
...colourObj,[dataindex]: xAxisPosition.includes(dataindex,)
? appliedItem.columnColour
: colourObj.hasOwnProperty(dataindex,)
? colourObj[dataindex]
: ECHART_BAR_COLOUR,};});setValuesColourMapping((prevColour)=>{return{
...prevColour,
...colourObj,};});if(option["series"][seriesIndexData].hasOwnProperty("itemStyle")){option["series"][seriesIndexData]["itemStyle"
Many components now repeatedly parse the same JSON string (via JSON.parse) in event handlers and render logic. Consider caching parsed data to improve performance and check that naming conventions remain consistent across similar modules.
constformatDataPoints=useCallback((resultData: unknown)=>{if(frame.data.values.length>0){constvaluesDataSet=JSON.parse(JSON.stringify(frame.data.values),);letheadersDataSet: string[]=JSON.parse(JSON.stringify(frame.data.headers),);headersDataSet=headersDataSet.map((header: string)=>header.replace("Average_",""),);//format the data points to match the echart specificationresultData["xAxis"]["data"]=valuesDataSet.map((x)=>x[0]);valuesDataSet.map((x)=>x.shift());headersDataSet.shift();constyAxisListLength=resultData["yAxis"]["name"].length;for(letindex=0;index<yAxisListLength;index++){resultData["series"][index]["data"]=valuesDataSet.map((x)=>{returnx[index];},);
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.