|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
// Libraries
|
|
|
|
|
import React, { CSSProperties } from 'react'; |
|
|
|
|
import React, { CSSProperties, Suspense } from 'react'; |
|
|
|
|
import tinycolor from 'tinycolor2'; |
|
|
|
|
import { Chart, Geom } from 'bizcharts'; |
|
|
|
|
|
|
|
|
|
// Utils
|
|
|
|
|
import { formattedValueToString, DisplayValue, getColorForTheme } from '@grafana/data'; |
|
|
|
|
@ -14,6 +13,16 @@ import { getTextColorForBackground } from '../../utils'; |
|
|
|
|
const LINE_HEIGHT = 1.2; |
|
|
|
|
const MAX_TITLE_SIZE = 30; |
|
|
|
|
|
|
|
|
|
const Chart = React.lazy(async () => { |
|
|
|
|
const { Chart } = await import(/* webpackChunkName: "bizcharts" */ 'bizcharts'); |
|
|
|
|
return { default: Chart }; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const Geom = React.lazy(async () => { |
|
|
|
|
const { Geom } = await import(/* webpackChunkName: "bizcharts" */ 'bizcharts'); |
|
|
|
|
return { default: Geom }; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export abstract class BigValueLayout { |
|
|
|
|
titleFontSize: number; |
|
|
|
|
valueFontSize: number; |
|
|
|
|
@ -166,6 +175,7 @@ export abstract class BigValueLayout { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Suspense fallback={<div>Loading chart...</div>}> |
|
|
|
|
<Chart |
|
|
|
|
height={this.chartHeight} |
|
|
|
|
width={this.chartWidth} |
|
|
|
|
@ -177,6 +187,7 @@ export abstract class BigValueLayout { |
|
|
|
|
> |
|
|
|
|
{this.renderGeom()} |
|
|
|
|
</Chart> |
|
|
|
|
</Suspense> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -209,10 +220,10 @@ export abstract class BigValueLayout { |
|
|
|
|
lineStyle.stroke = lineColor; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<Suspense fallback={<div>Loading chart...</div>}> |
|
|
|
|
<Geom type="area" position="time*value" size={0} color={fillColor} style={lineStyle} shape="smooth" /> |
|
|
|
|
<Geom type="line" position="time*value" size={1} color={lineColor} style={lineStyle} shape="smooth" /> |
|
|
|
|
</> |
|
|
|
|
</Suspense> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|