diff --git a/frontend/app/components/Charts/SankeyChart.tsx b/frontend/app/components/Charts/SankeyChart.tsx index 6f51140e0..f675fc570 100644 --- a/frontend/app/components/Charts/SankeyChart.tsx +++ b/frontend/app/components/Charts/SankeyChart.tsx @@ -195,7 +195,7 @@ const EChartsSankey: React.FC = (props) => { header: { fontWeight: '600', fontSize: 12, - color: '#333', + color: 'var(--color-gray-darkest)', overflow: 'truncate', paddingBottom: '.5rem', paddingLeft: '14px', @@ -203,16 +203,16 @@ const EChartsSankey: React.FC = (props) => { }, body: { fontSize: 12, - color: '#000', + color: 'var(--color-black)', }, percentage: { fontSize: 12, - color: '#454545', + color: 'var(--color-gray-dark)', }, sessions: { fontSize: 12, fontFamily: "mono, 'monospace', sans-serif", - color: '#999999', + color: 'var(--color-gray-dark)', }, clickIcon: { backgroundColor: { @@ -266,6 +266,7 @@ const EChartsSankey: React.FC = (props) => { }, tooltip: { formatter: sankeyTooltip(echartNodes, nodeValues), + backgroundColor: 'var(--color-white)', }, nodeAlign: 'left', nodeWidth: 40, diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 3106177d0..db542dd63 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -44,6 +44,7 @@ interface Props { isSaved?: boolean; isTemplate?: boolean; isPreview?: boolean; + height?: number; } function WidgetChart(props: Props) { @@ -52,7 +53,7 @@ function WidgetChart(props: Props) { triggerOnce: true, rootMargin: '200px 0px', }); - const { isSaved = false, metric, isTemplate } = props; + const { isSaved = false, metric, isTemplate, height } = props; const { dashboardStore, metricStore } = useStore(); const _metric: any = props.metric; const data = _metric.data; @@ -283,6 +284,7 @@ function WidgetChart(props: Props) { hideLegend onClick={onChartClick} label={t('Conversion')} + height={height} /> ); } @@ -293,6 +295,7 @@ function WidgetChart(props: Props) { data={data} compData={compData} isWidget={isSaved || isTemplate} + height={height} /> ); } @@ -308,6 +311,7 @@ function WidgetChart(props: Props) { metric={defaultMetric} data={data} predefinedKey={_metric.metricOf} + height={height} /> ); } @@ -331,6 +335,7 @@ function WidgetChart(props: Props) { compData={compDataCopy} onSeriesFocus={onFocus} onClick={onChartClick} + height={height} label={ _metric.metricOf === 'sessionCount' ? t('Number of Sessions') @@ -360,6 +365,7 @@ function WidgetChart(props: Props) { return ( @@ -480,6 +491,7 @@ function WidgetChart(props: Props) { @@ -490,6 +502,7 @@ function WidgetChart(props: Props) { @@ -518,18 +531,18 @@ function WidgetChart(props: Props) { ); } - return ; + return ; } if (metricType === INSIGHTS) { - return ; + return ; } if (metricType === USER_PATH && data && data.links) { const isUngrouped = props.isPreview ? !(_metric.hideExcess ?? true) : false; - const height = props.isPreview ? 550 : 240; + const height = props.height ? props.height : props.isPreview ? 550 : 240; return ( => { + ): Promise => { const r = await this.client.get( `/kai/${projectId}/chats/data/${messageId}`, ); diff --git a/frontend/app/components/Kai/KaiStore.ts b/frontend/app/components/Kai/KaiStore.ts index f1c9071e0..895aeefe5 100644 --- a/frontend/app/components/Kai/KaiStore.ts +++ b/frontend/app/components/Kai/KaiStore.ts @@ -211,7 +211,7 @@ class KaiStore { bumpUsage = () => { this.usage.used += 1; - this.usage.percent = Math.max( + this.usage.percent = Math.min( (this.usage.used / this.usage.total) * 100, 100, ); @@ -314,27 +314,13 @@ class KaiStore { supports_visualization: false, }); try { - const filters = await kaiService.getMsgChart(msgId, projectId); + const filtersStr = await kaiService.getMsgChart(msgId, projectId); + const filters = JSON.parse(filtersStr); const data = { - metricId: undefined, - dashboardId: undefined, - widgetId: undefined, - metricOf: undefined, - metricType: undefined, - metricFormat: undefined, - viewType: undefined, - name: 'Kai Visualization', - series: [ - { - name: 'Kai Visualization', - filter: { - eventsOrder: filters.eventsOrder, - filters: filters.filters, - }, - }, - ], + ...filters, }; const metric = new Widget().fromJson(data); + kaiService.saveChartData(msgId, projectId, data); return metric; } catch (e) { console.error(e); @@ -355,7 +341,7 @@ class KaiStore { this.usage = { total, used, - percent: (used / total) * 100, + percent: Math.round((used / total) * 100), }; } catch (e) { console.error(e); diff --git a/frontend/app/components/Kai/components/ChatMsg.tsx b/frontend/app/components/Kai/components/ChatMsg.tsx index 2f2439e90..4c3d97b8f 100644 --- a/frontend/app/components/Kai/components/ChatMsg.tsx +++ b/frontend/app/components/Kai/components/ChatMsg.tsx @@ -138,8 +138,8 @@ function ChatMsg({ {text} {metric ? ( -
- +
+
) : null} {isUser ? ( diff --git a/frontend/app/components/Kai/components/Usage.tsx b/frontend/app/components/Kai/components/Usage.tsx index b5f8c09c5..a2af47fa7 100644 --- a/frontend/app/components/Kai/components/Usage.tsx +++ b/frontend/app/components/Kai/components/Usage.tsx @@ -2,9 +2,6 @@ import React from 'react'; import { kaiStore } from '../KaiStore'; import { observer } from 'mobx-react-lite'; import { Progress, Tooltip } from 'antd'; -const getUsageColor = (percent: number) => { - return 'disabled-text'; -}; function Usage() { const usage = kaiStore.usage; @@ -12,12 +9,16 @@ function Usage() { if (usage.total === 0) { return null; } + + const roundPercent = Math.round((usage.used / usage.total) * 100); return (