Add null guards for querySelector results and division by zero in AttributesFilter
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -650,6 +650,7 @@ function getPercentLabel(val) {
|
||||
* @param {object} chart - The Chart.js instance data.
|
||||
*/
|
||||
function resizeMask(chart) {
|
||||
if (selectRange.value === 0) return;
|
||||
const from = (selectArea.value[0] * 0.01) / (selectRange.value * 0.01);
|
||||
const to = (selectArea.value[1] * 0.01) / (selectRange.value * 0.01);
|
||||
resizeLeftMask(chart, from);
|
||||
@@ -663,6 +664,7 @@ function resizeMask(chart) {
|
||||
function resizeLeftMask(chart, from) {
|
||||
const canvas = document.querySelector("#chartCanvasId canvas");
|
||||
const mask = document.getElementById("chart-mask-left");
|
||||
if (!canvas || !mask) return;
|
||||
mask.style.left = `${canvas.offsetLeft + chart.chartArea.left}px`;
|
||||
mask.style.width = `${chart.chartArea.width * from}px`;
|
||||
mask.style.top = `${canvas.offsetTop + chart.chartArea.top}px`;
|
||||
@@ -676,6 +678,7 @@ function resizeLeftMask(chart, from) {
|
||||
function resizeRightMask(chart, to) {
|
||||
const canvas = document.querySelector("#chartCanvasId canvas");
|
||||
const mask = document.getElementById("chart-mask-right");
|
||||
if (!canvas || !mask) return;
|
||||
mask.style.left = `${canvas.offsetLeft + chart.chartArea.left + chart.chartArea.width * to}px`;
|
||||
mask.style.width = `${chart.chartArea.width * (1 - to)}px`;
|
||||
mask.style.top = `${canvas.offsetTop + chart.chartArea.top}px`;
|
||||
|
||||
Reference in New Issue
Block a user