Skip to content

Commit

Permalink
refactor: table legend support click to active
Browse files Browse the repository at this point in the history
  • Loading branch information
jsers committed Aug 11, 2022
1 parent 447c13b commit 7e0f19f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/PromGraphCpt/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export default function Graph(props: IProps) {
.then((res) => {
const series = _.map(res?.result, (item) => {
return {
id: _.uniqueId('series_'),
name: getSerieName(item.metric),
metric: item.metric,
data: item.values,
};
});
Expand Down
18 changes: 18 additions & 0 deletions src/pages/dashboard/Renderer/Renderer/Timeseries/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,24 @@ export default function index(props: IProps) {
emptyText: '暂无数据',
}}
pagination={false}
rowClassName={(record) => {
return record.disabled ? 'disabled' : '';
}}
onRow={(record) => {
return {
onClick: () => {
setActiveLegend(activeLegend !== record.id ? record.id : '');
setSeriesData(
_.map(seriesData, (subItem) => {
return {
...subItem,
visible: activeLegend === record.id ? true : record.id === subItem.id,
};
}),
);
},
};
}}
/>
)}
{displayMode === 'list' && !_.isEmpty(legendData) && (
Expand Down
5 changes: 5 additions & 0 deletions src/pages/dashboard/Renderer/Renderer/Timeseries/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
line-height: unset !important;
padding: 0 !important;
}
.ant-table-row.disabled {
.ant-table-cell {
color: #24292e80
}
}
}
.renderer-timeseries-legend-container {
position: relative;
Expand Down

0 comments on commit 7e0f19f

Please sign in to comment.