* feat ui: dashboards redesign start * more cards * fix ui: more different cards... * feat ui: finish cards, all trigger, all icons * change(ui): added missin const * feature(ui): new dashboard modal * feature(ui): new dashboard modal * change(ui): new cards * change(ui): dashboard redesign * change(ui): dashboard redesign * change(ui): dashboard redesign * change(ui): modal context and alert form * change(ui): table card show more with modal * change(ui): examples * change(ui): example categorize and other improvements * change(ui): example categorize and other improvements * change(ui): performance cards * change(ui): insights card * Various style updates in dashboards and other pages. (#2308) * Various minor style updates * Various style improvements * Update ExampleCards.tsx * change(ui): fixed an issue with card create * change(ui): fixed an issue with card create * change(ui): default filters and events order * change(ui): random data * Dashboards redesign - improvments (#2313) * Various minor style updates * Various style improvements * Update ExampleCards.tsx * various minor improvements in dashbaords. * revised dashboard widget header * change(ui): sessions by user * change(ui): funnel example * change(ui): modal height and scroll * change(ui): example cards with data * change(ui): example cards with data * change(ui): funnel bar text color * change(ui): example cards overlay click * change(ui): path analysis filter card --------- Co-authored-by: Shekar Siri <sshekarsiri@gmail.com> Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import React from 'react'
|
|
import {Styles} from '../../common';
|
|
import {AreaChart, ResponsiveContainer, XAxis, YAxis, Area, Tooltip} from 'recharts';
|
|
import CountBadge from '../../common/CountBadge';
|
|
import {numberWithCommas} from 'App/utils';
|
|
|
|
interface Props {
|
|
data: any;
|
|
}
|
|
|
|
function CustomMetricOverviewChart(props: Props) {
|
|
const {data} = props;
|
|
const gradientDef = Styles.gradientDef();
|
|
|
|
return (
|
|
<div className="relative -mx-4">
|
|
<div className="absolute flex items-start flex-col justify-start inset-0 p-3">
|
|
<div className="mb-2 flex items-center">
|
|
</div>
|
|
<div className="flex items-center">
|
|
<CountBadge
|
|
// title={subtext}
|
|
count={countView(Math.round(data.value), data.unit)}
|
|
change={data.progress || 0}
|
|
unit={data.unit}
|
|
// className={textClass}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<ResponsiveContainer height={100} width="100%">
|
|
<AreaChart
|
|
data={data.chart}
|
|
margin={{
|
|
top: 50, right: 0, left: 0, bottom: 0,
|
|
}}
|
|
>
|
|
{gradientDef}
|
|
<Tooltip {...Styles.tooltip} />
|
|
<XAxis hide {...Styles.xaxis} interval={4} dataKey="time"/>
|
|
<YAxis hide interval={0}/>
|
|
<Area
|
|
name={''}
|
|
// unit={unit && ' ' + unit}
|
|
type="monotone"
|
|
dataKey="value"
|
|
stroke={Styles.strokeColor}
|
|
fillOpacity={1}
|
|
strokeWidth={2}
|
|
strokeOpacity={0.8}
|
|
fill={'url(#colorCount)'}
|
|
/>
|
|
</AreaChart>
|
|
</ResponsiveContainer>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default CustomMetricOverviewChart
|
|
|
|
|
|
const countView = (avg: any, unit: any) => {
|
|
if (unit === 'mb') {
|
|
if (!avg) return 0;
|
|
const count = Math.trunc(avg / 1024 / 1024);
|
|
return numberWithCommas(count);
|
|
}
|
|
if (unit === 'min') {
|
|
if (!avg) return 0;
|
|
const count = Math.trunc(avg);
|
|
return numberWithCommas(count > 1000 ? count + 'k' : count);
|
|
}
|
|
return avg ? numberWithCommas(avg) : 0;
|
|
}
|