Skip to content
Closed
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
22 changes: 12 additions & 10 deletions src/components/BubbleChart/handleOptipn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,42 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import chartToken from './chartToken';
import { changeRgbaOpacity } from '../../util/color';
import defendXSS from '../../util/defendXSS';
function tooltipFormatter(params) {
const { tipSeriesNameColor, tipNameColor, tipValueColor } = chartToken;
const seriesName = params.seriesName;
const color = params.color;
const data = params.data;
const [x, y, radius, name] = data;
let htmlString = `<div style="margin-bottom:4px;">
let htmlString = `<div style="margin-bottom:4px;color:${tipSeriesNameColor};">
${defendXSS(seriesName)}
</div>`;
htmlString += `<div style="margin-bottom:4px;">
<span style="display:inline-block;width:10px;height:10px;
margin-right:8px;border-radius:5px;border-style: solid;border-width:1px;
<span style="display:inline-block;width:8px;height:8px;
margin-right:8px;border-radius:4px;border-style: solid;border-width:1px;
Comment on lines +25 to +26
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix missing closing quotes in style attributes

There are syntax errors in multiple places where the closing quotes are missing after the interpolated color values, which will cause the styles to not apply correctly.

Apply these fixes:

-                            <span style="color:${tipValueColor};>${defendXSS(name)}</span>
+                            <span style="color:${tipValueColor};">${defendXSS(name)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(x)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(x)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(y)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(y)}</span>
-                <span style="color:${tipValueColor};>${defendXSS(radius)}</span>
+                <span style="color:${tipValueColor};">${defendXSS(radius)}</span>

Also applies to: 30-30, 34-35, 40-41, 46-47

border-color:${defendXSS(changeRgbaOpacity(color, 1))};background-color:${defendXSS(
color,
)};"></span>
<span>${defendXSS(name)}</span>
<span style="color:${tipValueColor};>${defendXSS(name)}</span>
</div>`;
htmlString += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">x维度</span>
<span>${defendXSS(x)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">x维度</span>
<span style="color:${tipValueColor};>${defendXSS(x)}</span>
</div>
`;
htmlString += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">y维度</span>
<span>${defendXSS(y)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">y维度</span>
<span style="color:${tipValueColor};>${defendXSS(y)}</span>
</div>
`;
htmlString += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">半径维度</span>
<span>${defendXSS(radius)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">半径维度</span>
<span style="color:${tipValueColor};>${defendXSS(radius)}</span>
</div>
`;
return htmlString;
Expand Down
10 changes: 5 additions & 5 deletions src/components/PolarBarChart/handleOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export function getLabelData(data) {
}

function tooltipFormatter(params) {
const { tipNameColor, tipValueColor } = chartToken;
const seriesName = params.name;
const color = params.color;
const value = params.value;
const htmlString = `<div>
<span style="display:inline-block;width:10px;height:10px;
margin-right:8px;border-radius:5px;border-style: solid;border-width:1px;
border-color:${defendXSS(color)};background-color:${defendXSS(color)};"></span>
<span style="margin-right:16px">${defendXSS(seriesName)}</span>
<span>${defendXSS(value)}</span>
<span style="display:inline-block;width:8px;height:8px;
margin-right:4px;border-radius:4px;background-color:${defendXSS(color)};"></span>
<span style="margin-right:16px;color:${tipNameColor};">${defendXSS(seriesName)}</span>
<span style="color:${tipValueColor};">${defendXSS(value)}</span>
</div>`;
return htmlString;
}
Expand Down
12 changes: 7 additions & 5 deletions src/components/ScatterChart/handleOptipn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import chartToken from './chartToken';
import xAxis from '../../option/config/xAxis';
import yAxis from '../../option/config/yAxis';
import grid from '../../option/config/grid';
Expand All @@ -20,20 +21,21 @@ import { CHART_TYPE } from '../../util/constants';
* Tips提示框回调函数
*/
function toolTipFormatter(params) {
const { tipSeriesNameColor, tipNameColor, tipValueColor } = chartToken;
const data = params.data;
const [x, y, name] = data;
let htmlStrings = `<div style="margin-bottom:4px;">
let htmlStrings = `<div style="margin-bottom:4px;color:${tipSeriesNameColor};">
名称${name || ''}
</div>`;
htmlStrings += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">x维度</span>
<span>${defendXSS(x)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">x维度</span>
<span style="color:${tipValueColor};">${defendXSS(x)}</span>
</div>`;
htmlStrings += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">y维度</span>
<span>${defendXSS(y)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">y维度</span>
<span style="color:${tipValueColor};">${defendXSS(y)}</span>
</div>`;
return htmlStrings;
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/TreeMapChart/chartToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2024 - present OpenTiny HUICharts Authors.
* Copyright (c) 2024 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import Theme from '../../feature/token';
import {CHART_TYPE} from '../../util/constants'

const chartToken = Theme.getTokenByName(CHART_TYPE.TREE_MAP)

export default chartToken;
8 changes: 5 additions & 3 deletions src/components/TreeMapChart/handleOptipn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import chartToken from './chartToken';
import grid from '../../option/config/grid';
import tooltip from '../../option/config/tooltip';
import defendXSS from '../../util/defendXSS';
Expand All @@ -18,15 +19,16 @@ import { CHART_TYPE } from '../../util/constants';
* Tips提示框回调函数
*/
function toolTipFormatter(params) {
const { tipSeriesNameColor, tipNameColor, tipValueColor } = chartToken;
const data = params.data;
const { value, name } = data;
let htmlString = `<div style="margin-bottom:4px;">
let htmlString = `<div style="margin-bottom:4px;color:${tipSeriesNameColor};">
树节点${name || ''}
</div>`;
htmlString += `
<div>
<span style="display:inline-block;margin-right:8px;min-width:60px;">value:</span>
<span>${defendXSS(value)}</span>
<span style="display:inline-block;margin-right:8px;min-width:60px;color:${tipNameColor};">value:</span>
<span style="color:${tipValueColor};">${defendXSS(value)}</span>
</div>`;
return htmlString;
}
Expand Down