diff options
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/Histogram.tsx')
-rw-r--r-- | src/client/views/nodes/DataVizBox/components/Histogram.tsx | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx index b6ae15709..7a866d742 100644 --- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx +++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx @@ -91,7 +91,7 @@ export class Histogram extends React.Component<HistogramProps> { this._disposers.chartData = reaction( () => ({ dataSet: this._histogramData, w: this.width, h: this.height }), ({ dataSet, w, h }) => { - if (dataSet) { + if (dataSet!.length>0) { this.drawChart(dataSet, w, h); // redraw annotations when the chart data has changed, or the local or inherited selection has changed @@ -226,10 +226,10 @@ export class Histogram extends React.Component<HistogramProps> { }) return valid; }) - var field = Object.keys(dataSet[0])[0] + var field = dataSet[0]? Object.keys(dataSet[0])[0]: undefined; const data = validData.map((d: { [x: string]: any; }) => { - if (this.numericalData) { return +d[field].replace(/\$/g, '').replace(/\%/g, '') } - return d[field] + if (this.numericalData) { return +d[field!].replace(/\$/g, '').replace(/\%/g, '') } + return d[field!] }) return data; } @@ -241,7 +241,7 @@ export class Histogram extends React.Component<HistogramProps> { var field = Object.keys(dataSet[0])[0] const data = this.data(dataSet); - let uniqueArr = [...new Set(data)] + let uniqueArr: unknown[] = [...new Set(data)] var numBins = uniqueArr.length var startingPoint = 0; var endingPoint = numBins; |