|
@@ -22,7 +22,7 @@ export class Graph extends PureComponent<GraphProps> {
|
|
|
showBars: false,
|
|
showBars: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- element: HTMLElement;
|
|
|
|
|
|
|
+ element: HTMLElement | null;
|
|
|
|
|
|
|
|
componentDidUpdate() {
|
|
componentDidUpdate() {
|
|
|
this.draw();
|
|
this.draw();
|
|
@@ -33,6 +33,10 @@ export class Graph extends PureComponent<GraphProps> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
draw() {
|
|
draw() {
|
|
|
|
|
+ if (this.element === null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const { width, timeSeries, timeRange, showLines, showBars, showPoints } = this.props;
|
|
const { width, timeSeries, timeRange, showLines, showBars, showPoints } = this.props;
|
|
|
|
|
|
|
|
if (!width) {
|
|
if (!width) {
|
|
@@ -74,7 +78,7 @@ export class Graph extends PureComponent<GraphProps> {
|
|
|
max: max,
|
|
max: max,
|
|
|
label: 'Datetime',
|
|
label: 'Datetime',
|
|
|
ticks: ticks,
|
|
ticks: ticks,
|
|
|
- timeformat: time_format(ticks, min, max),
|
|
|
|
|
|
|
+ timeformat: timeFormat(ticks, min, max),
|
|
|
},
|
|
},
|
|
|
grid: {
|
|
grid: {
|
|
|
minBorderMargin: 0,
|
|
minBorderMargin: 0,
|
|
@@ -107,7 +111,7 @@ export class Graph extends PureComponent<GraphProps> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Copied from graph.ts
|
|
// Copied from graph.ts
|
|
|
-function time_format(ticks, min, max) {
|
|
|
|
|
|
|
+function timeFormat(ticks: number, min: number, max: number): string {
|
|
|
if (min && max && ticks) {
|
|
if (min && max && ticks) {
|
|
|
const range = max - min;
|
|
const range = max - min;
|
|
|
const secPerTick = range / ticks / 1000;
|
|
const secPerTick = range / ticks / 1000;
|