diff --git a/frontend/app/components/Dashboard/components/WidgetChart/LongLoader.tsx b/frontend/app/components/Dashboard/components/WidgetChart/LongLoader.tsx
new file mode 100644
index 000000000..3f82c77f5
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/WidgetChart/LongLoader.tsx
@@ -0,0 +1,35 @@
+import React from 'react'
+import { Progress, Button } from 'antd';
+import { Icon } from 'UI';
+
+function LongLoader({ onClick }: { onClick: () => void }) {
+ return (
+
+
+
+
+ This is taking longer than expected.
+
+
+ Use sample data to speed up query and get a faster response.
+
+
+
+ )
+}
+
+export default LongLoader;
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx
index 1beaa99db..50044f983 100644
--- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx
+++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx
@@ -37,6 +37,7 @@ import { filterMinorPaths } from 'Shared/Insights/SankeyChart/utils'
import CohortCard from '../../Widgets/CustomMetricsWidgets/CohortCard';
import SessionsBy from 'Components/Dashboard/Widgets/CustomMetricsWidgets/SessionsBy';
import { useInView } from 'react-intersection-observer';
+import LongLoader from "./LongLoader";
interface Props {
metric: any;
@@ -59,6 +60,7 @@ function WidgetChart(props: Props) {
const drillDownFilter = dashboardStore.drillDownFilter;
const colors = Styles.safeColors;
const [loading, setLoading] = useState(true);
+ const [stale, setStale] = useState(false);
const params = { density: dashboardStore.selectedDensity };
const metricParams = _metric.params;
const prevMetricRef = useRef();
@@ -119,6 +121,8 @@ function WidgetChart(props: Props) {
}
};
+ const loadSample = () => console.log('clicked')
+
const depsString = JSON.stringify({
..._metric.series,
..._metric.excludes,
@@ -134,12 +138,20 @@ function WidgetChart(props: Props) {
) => {
if (!isMounted()) return;
setLoading(true);
+ const tm = setTimeout(() => {
+ setStale(true)
+ }, 4000)
dashboardStore
.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)
})
.finally(() => {
+ if (metric.metricId === 1014) return;
setLoading(false);
});
};
@@ -534,7 +546,7 @@ function WidgetChart(props: Props) {
const showTable = _metric.metricType === TIMESERIES && (props.isPreview || _metric.viewType === TABLE)
return (
-
+ {loading ? stale ? : : (
{renderChart()}
{showTable ? (
@@ -549,9 +561,10 @@ function WidgetChart(props: Props) {
/>
) : null}
-
+ )}
);
}
+
export default observer(WidgetChart);