diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/components/chart-title/chart-title.tsx b/bkmonitor/webpack/src/monitor-ui/chart-plugins/components/chart-title/chart-title.tsx index 4782c0f83..984782299 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/components/chart-title/chart-title.tsx +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/components/chart-title/chart-title.tsx @@ -364,7 +364,7 @@ export default class ChartTitle extends tsc interactive: this.showTitleIcon, }} > - {this.title} + {(this.$scopedSlots as any)?.title ? (this.$scopedSlots as any)?.title?.() : this.title} {this.inited && [ (this.showTitleIcon && this.showMetricAlarm && this.metricTitleData?.collect_interval) || diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/apm-service-caller-callee/apm-service-caller-callee.tsx b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/apm-service-caller-callee/apm-service-caller-callee.tsx index aa83d57bb..815379569 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/apm-service-caller-callee/apm-service-caller-callee.tsx +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/apm-service-caller-callee/apm-service-caller-callee.tsx @@ -112,7 +112,7 @@ export default class ApmServiceCallerCallee extends tsc this.handleFieldOperations(opt, row, item.isClick, intersection[0])} + onClick={() => + this.handleFieldOperations(opt, row, item.isClick, intersection[0], item.value) + } > {item.value} diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.scss b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.scss index d04b6dfa3..76b68abf0 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.scss +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.scss @@ -33,13 +33,10 @@ } } .caller-pie-chart-tooltips { - .tooltips-header { - word-break: break-all; - padding-right: 5px; - height: 20px; + .tooltips-span { + color: rgb(99, 101, 110) !important; + margin: 0px 0px 2px 6px; font-size: 12px; - font-weight: normal; - color: rgb(99, 101, 110); - line-height: 20px; + text-align: left; } } diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.tsx b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.tsx index b6bc686dd..0e4b63399 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.tsx +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-bar-chart/caller-bar-chart.tsx @@ -93,13 +93,13 @@ class CallerBarChart extends CommonSimpleChart { formatter: p => { const data = p[0].data; return `
-

+

${data.name}

-

+

${data.metricCalTypeName}:${data.value}

-

+

${this.$t('占比')}:${data.proportion}%

`; diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.scss b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.scss index d12d87977..932aba9bc 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.scss +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.scss @@ -6,6 +6,14 @@ width: 100%; height: 100%; background-color: transparent; + .enable-select { + width: 90px; + .bk-select-name { + font-size: 14px; + font-weight: 400; + color: #313238; + } + } .time-series-header { display: flex; diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.tsx b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.tsx index a930b4115..547bf8073 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.tsx +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/plugins/caller-line-chart/caller-line-chart.tsx @@ -137,6 +137,7 @@ class CallerLineChart extends CommonSimpleChart { drillDownOptions: IMenuChildItem[] = []; hasSetEvent = false; collectIntervalDisplay = '1m'; + panelsSelector = 'timeout_rate'; // 是否展示复位按钮 showRestore = false; @@ -162,6 +163,22 @@ class CallerLineChart extends CommonSimpleChart { return !!this.panel.options?.is_support_group_by; } + // title是否需要展示下拉框 + get enablePanelsSelector() { + return !!this.panel.options?.enable_panels_selector; + } + + get curSelectPanel() { + return (this.childPanelsSelectorVariables || []).find(item => this.panelsSelector === item.id); + } + + get curTitle() { + return this.enablePanelsSelector ? this.curSelectPanel?.title : this.panel.title; + } + + get childPanelsSelectorVariables() { + return this.panel.options?.child_panels_selector_variables || []; + } get menuList() { return ['save', 'more', 'fullscreen', 'explore', 'area', 'drill-down', 'relate-alert']; } @@ -176,6 +193,9 @@ class CallerLineChart extends CommonSimpleChart { this.getPanelData(); } + handlePanelsSelector() { + this.getPanelData(); + } /** * @description: 获取图表数据 * @param {*} @@ -226,9 +246,14 @@ class CallerLineChart extends CommonSimpleChart { callOptions[key] = this.callOptions[key]; } } + let selectPanelParams = {}; + if (this.enablePanelsSelector) { + selectPanelParams = this.curSelectPanel.variables; + } const variablesService = new VariablesService({ ...this.viewOptions, ...callOptions, + ...selectPanelParams, }); for (const time_shift of timeShiftList) { const noTransformVariables = this.panel?.options?.time_series?.noTransformVariables; @@ -282,7 +307,6 @@ class CallerLineChart extends CommonSimpleChart { down_sample_range, }, }); - // console.log(newParams, this.panel.title); return (this as any).$api[item.apiModule] [item.apiFunc](...paramsArr, { cancelToken: new CancelToken((cb: () => void) => this.cancelTokens.push(cb)), @@ -298,7 +322,7 @@ class CallerLineChart extends CommonSimpleChart { this.handleSeriesName(item, set) || set.target }`; this.legendSorts.push({ - name, + name: this.enablePanelsSelector ? this.curTitle : name, timeShift: time_shift, }); return { @@ -330,6 +354,7 @@ class CallerLineChart extends CommonSimpleChart { .filter(item => ['extra_info', '_result_'].includes(item.alias)) .map(item => ({ ...item, + name: this.enablePanelsSelector ? this.curTitle : item.name, datapoints: item.datapoints.map(point => [JSON.parse(point[0])?.anomaly_score ?? point[0], point[1]]), })); let seriesList = this.handleTransformSeries( @@ -452,7 +477,6 @@ class CallerLineChart extends CommonSimpleChart { console.error(e); this.empty = true; this.emptyText = window.i18n.tc('出错了'); - console.error(e); } this.cancelTokens = []; this.handleLoadingChange(false); @@ -778,7 +802,7 @@ class CallerLineChart extends CommonSimpleChart { break; case 'screenshot': // 保存到本地 setTimeout(() => { - this.handleStoreImage(this.panel.title || '测试'); + this.handleStoreImage(this.curTitle || '测试'); }, 300); break; case 'fullscreen': { @@ -797,6 +821,7 @@ class CallerLineChart extends CommonSimpleChart { case 'explore': { // 跳转数据检索 const copyPanel = this.getCopyPanel(); + console.log('copyPanel', copyPanel); this.handleExplore(copyPanel as any, {}); break; } @@ -827,7 +852,7 @@ class CallerLineChart extends CommonSimpleChart { if (data.child.id === 'screenshot') { /** 截图 */ setTimeout(() => { - this.handleStoreImage(this.panel.title); + this.handleStoreImage(this.curTitle); }, 300); } else if (data.child.id === 'export-csv') { /** 导出csv */ @@ -881,7 +906,7 @@ class CallerLineChart extends CommonSimpleChart { if (this.series?.length) { const { tableThArr, tableTdArr } = transformSrcData(this.series); const csvString = transformTableDataToCsvStr(tableThArr, tableTdArr); - downCsvFile(csvString, this.panel.title); + downCsvFile(csvString, this.curTitle); } } @@ -893,10 +918,12 @@ class CallerLineChart extends CommonSimpleChart { handleAllMetricClick() { const configs = this.panel.toStrategy(null); if (configs) { + console.log('this.panel', this.panel); this.handleAddStrategy(this.panel, null, {}); return; } const copyPanel = this.getCopyPanel(); + console.log('copyPanel-all', copyPanel); this.handleAddStrategy(copyPanel as any, null, {}, true); } @@ -958,6 +985,7 @@ class CallerLineChart extends CommonSimpleChart {
+ > +
+ {this.enablePanelsSelector ? ( +
+ + {(this.childPanelsSelectorVariables || []).map(option => ( + + ))} + +
+ ) : ( + {this.panel.title} + )} +
+
{!this.empty ? (
{ const data = p.data; return `
-

+

${data.name}

-

+

${this.dimensionChartOpt.metric_cal_type_name}:${data.value}

-

+

${this.$t('占比')}:${data.proportion}%

`; diff --git a/bkmonitor/webpack/src/monitor-ui/chart-plugins/typings/dashboard-panel.ts b/bkmonitor/webpack/src/monitor-ui/chart-plugins/typings/dashboard-panel.ts index ee04b28ff..423bc67a5 100644 --- a/bkmonitor/webpack/src/monitor-ui/chart-plugins/typings/dashboard-panel.ts +++ b/bkmonitor/webpack/src/monitor-ui/chart-plugins/typings/dashboard-panel.ts @@ -416,6 +416,11 @@ export type PanelOption = { unit?: string; // 单位 is_support_compare: boolean; is_support_group_by: boolean; + enable_panels_selector?: boolean; + child_panels_selector_variables?: { + id?: string; + title?: string; + }; need_zr_click_event?: boolean; // 是否需要zrender click 事件 header?: { tips: string; // 提示