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