ui: fix sankey node titles, fix option saving,
This commit is contained in:
parent
6e7ced6959
commit
4819907635
4 changed files with 32 additions and 19 deletions
|
|
@ -4,7 +4,6 @@ import { SankeyChart } from 'echarts/charts';
|
||||||
import { sankeyTooltip, getEventPriority, getNodeName } from './sankeyUtils';
|
import { sankeyTooltip, getEventPriority, getNodeName } from './sankeyUtils';
|
||||||
import { NoContent } from 'App/components/ui';
|
import { NoContent } from 'App/components/ui';
|
||||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||||
import { X } from 'lucide-react';
|
|
||||||
|
|
||||||
echarts.use([SankeyChart]);
|
echarts.use([SankeyChart]);
|
||||||
|
|
||||||
|
|
@ -210,8 +209,15 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
? ((nodeVal / startNodeValue) * 100).toFixed(1) + '%'
|
? ((nodeVal / startNodeValue) * 100).toFixed(1) + '%'
|
||||||
: '0%';
|
: '0%';
|
||||||
|
|
||||||
|
const maxLen = 20;
|
||||||
|
const safeName =
|
||||||
|
params.name.length > maxLen
|
||||||
|
? params.name.slice(0, maxLen / 2 - 2) +
|
||||||
|
'...' +
|
||||||
|
params.name.slice(-(maxLen / 2 - 2))
|
||||||
|
: params.name;
|
||||||
return (
|
return (
|
||||||
`{header|${params.name}}\n` +
|
`{header|${safeName}}\n` +
|
||||||
`{body|}{percentage|${percentage}} {sessions|${nodeVal}}`
|
`{body|}{percentage|${percentage}} {sessions|${nodeVal}}`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
@ -352,11 +358,11 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
|
|
||||||
if (params.dataType === 'node') {
|
if (params.dataType === 'node') {
|
||||||
const node = params.data;
|
const node = params.data;
|
||||||
const filters = []
|
const filters = [];
|
||||||
if (node && node.type) {
|
if (node && node.type) {
|
||||||
const type = node.type.toLowerCase();
|
const type = node.type.toLowerCase();
|
||||||
if (unsupported.includes(type)) {
|
if (unsupported.includes(type)) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
filters.push({
|
filters.push({
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
|
|
@ -370,12 +376,15 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
const linkIndex = params.dataIndex;
|
const linkIndex = params.dataIndex;
|
||||||
const link = filteredLinks[linkIndex];
|
const link = filteredLinks[linkIndex];
|
||||||
|
|
||||||
const firstNode = data.nodes.find(n => n.id === link.source)
|
const firstNode = data.nodes.find((n) => n.id === link.source);
|
||||||
const lastNode = data.nodes.find(n => n.id === link.target)
|
const lastNode = data.nodes.find((n) => n.id === link.target);
|
||||||
const firstNodeType = firstNode?.eventType?.toLowerCase() ?? 'location';
|
const firstNodeType = firstNode?.eventType?.toLowerCase() ?? 'location';
|
||||||
const lastNodeType = lastNode?.eventType?.toLowerCase() ?? 'location';
|
const lastNodeType = lastNode?.eventType?.toLowerCase() ?? 'location';
|
||||||
if (unsupported.includes(firstNodeType) || unsupported.includes(lastNodeType)) {
|
if (
|
||||||
return
|
unsupported.includes(firstNodeType) ||
|
||||||
|
unsupported.includes(lastNodeType)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const filters = [];
|
const filters = [];
|
||||||
if (firstNode) {
|
if (firstNode) {
|
||||||
|
|
@ -383,7 +392,7 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
type: firstNodeType,
|
type: firstNodeType,
|
||||||
value: [firstNode.name],
|
value: [firstNode.name],
|
||||||
isEvent: true
|
isEvent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -392,7 +401,7 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
type: lastNodeType,
|
type: lastNodeType,
|
||||||
value: [lastNode.name],
|
value: [lastNode.name],
|
||||||
isEvent: true
|
isEvent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,11 +435,13 @@ const EChartsSankey: React.FC<Props> = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div style={{ maxHeight: 620, overflow: 'auto', maxWidth: 840, }}>
|
||||||
ref={chartRef}
|
<div
|
||||||
style={containerStyle}
|
ref={chartRef}
|
||||||
className="min-w-[600px] overflow-scroll"
|
style={containerStyle}
|
||||||
/>
|
className="min-w-[600px] overflow-scroll"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,6 @@ function WidgetChart(props: Props) {
|
||||||
.fetchMetricChartData(metric, payload, isSaved, period, isComparison)
|
.fetchMetricChartData(metric, payload, isSaved, period, isComparison)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
if (isComparison) setCompData(res);
|
if (isComparison) setCompData(res);
|
||||||
// /65/metrics/1014
|
|
||||||
if (metric.metricId === 1014) return;
|
|
||||||
clearTimeout(tm)
|
clearTimeout(tm)
|
||||||
setStale(false)
|
setStale(false)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,10 @@ const PathAnalysisFilter = observer(({ metric, writeOption }: any) => {
|
||||||
{ value: 'input', label: 'Input' },
|
{ value: 'input', label: 'Input' },
|
||||||
{ value: 'custom', label: 'Custom Events' },
|
{ value: 'custom', label: 'Custom Events' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const onPointChange = (value: any) => {
|
||||||
|
writeOption({ name: 'startType', value: { value } })
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="rounded-lg bg-white border">
|
<div className="rounded-lg bg-white border">
|
||||||
<div className='flex flex-col justify-start gap-2 flex-wrap'>
|
<div className='flex flex-col justify-start gap-2 flex-wrap'>
|
||||||
|
|
@ -210,7 +214,7 @@ const PathAnalysisFilter = observer(({ metric, writeOption }: any) => {
|
||||||
{ value: 'end', label: 'End Point' },
|
{ value: 'end', label: 'End Point' },
|
||||||
]}
|
]}
|
||||||
defaultValue={metric.startType || 'start'}
|
defaultValue={metric.startType || 'start'}
|
||||||
onChange={(value) => writeOption({ name: 'startType', value })}
|
onChange={onPointChange}
|
||||||
placeholder="Select Start Type"
|
placeholder="Select Start Type"
|
||||||
size="small"
|
size="small"
|
||||||
/>
|
/>
|
||||||
|
|
@ -220,7 +224,6 @@ const PathAnalysisFilter = observer(({ metric, writeOption }: any) => {
|
||||||
<Select
|
<Select
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
className="rounded-lg h-[26px] w-max min-w-44 max-w-58"
|
className="rounded-lg h-[26px] w-max min-w-44 max-w-58"
|
||||||
// style={{ width: 'auto', minWidth: '9rem', maxWidth: '12rem' }}
|
|
||||||
allowClear
|
allowClear
|
||||||
name="metricValue"
|
name="metricValue"
|
||||||
options={metricValueOptions}
|
options={metricValueOptions}
|
||||||
|
|
|
||||||
|
|
@ -182,6 +182,7 @@ export default class Widget {
|
||||||
if (this.metricType === USER_PATH) {
|
if (this.metricType === USER_PATH) {
|
||||||
this.hideExcess = json.hideExcess;
|
this.hideExcess = json.hideExcess;
|
||||||
this.startType = json.startType;
|
this.startType = json.startType;
|
||||||
|
this.metricValue = json.metricValue && json.metricValue.length > 0 ? json.metricValue : ['location'];
|
||||||
if (json.startPoint) {
|
if (json.startPoint) {
|
||||||
if (Array.isArray(json.startPoint) && json.startPoint.length > 0) {
|
if (Array.isArray(json.startPoint) && json.startPoint.length > 0) {
|
||||||
this.startPoint = new FilterItem().fromJson(json.startPoint[0]);
|
this.startPoint = new FilterItem().fromJson(json.startPoint[0]);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue