diff --git a/src/chart_types/partition_chart/layout/viewmodel/viewmodel.ts b/src/chart_types/partition_chart/layout/viewmodel/viewmodel.ts index 66f2790ea9..9e31f4d244 100644 --- a/src/chart_types/partition_chart/layout/viewmodel/viewmodel.ts +++ b/src/chart_types/partition_chart/layout/viewmodel/viewmodel.ts @@ -69,9 +69,9 @@ function topGrooveAccessor(topGroovePx: Pixels) { } export const VerticalAlignments = Object.freeze({ - top: 'top' as 'top', - middle: 'middle' as 'middle', - bottom: 'bottom' as 'bottom', + top: 'top' as const, + middle: 'middle' as const, + bottom: 'bottom' as const, }); // we might add more in the future; also, the intent is to still be of CanvasTextBaseline @@ -207,7 +207,6 @@ export function shapeViewModel( partitionLayout, sectorLineWidth, } = config; - const innerWidth = width * (1 - Math.min(1, margin.left + margin.right)); const innerHeight = height * (1 - Math.min(1, margin.top + margin.bottom)); diff --git a/src/chart_types/partition_chart/state/chart_state.tsx b/src/chart_types/partition_chart/state/chart_state.tsx index 372cc92cf7..cf7bd8ea18 100644 --- a/src/chart_types/partition_chart/state/chart_state.tsx +++ b/src/chart_types/partition_chart/state/chart_state.tsx @@ -47,7 +47,7 @@ export class PartitionState implements InternalChartState { } chartType = ChartTypes.Partition; isInitialized(globalState: GlobalChartState) { - return globalState.specsInitialized && getPieSpec(globalState) !== null; + return getPieSpec(globalState) !== null; } isBrushAvailable() { return false; diff --git a/src/chart_types/xy_chart/renderer/canvas/xy_chart.tsx b/src/chart_types/xy_chart/renderer/canvas/xy_chart.tsx index 115716b3de..6a398cf6e2 100644 --- a/src/chart_types/xy_chart/renderer/canvas/xy_chart.tsx +++ b/src/chart_types/xy_chart/renderer/canvas/xy_chart.tsx @@ -137,19 +137,12 @@ class XYChartComponent extends React.Component { isChartEmpty, chartContainerDimensions: { width, height }, } = this.props; - if (!initialized || width === 0 || height === 0) { + + if (!initialized || isChartEmpty) { this.ctx = null; return null; } - if (isChartEmpty) { - this.ctx = null; - return ( -
-

No data to display

-
- ); - } return ( 0; + return getSeriesSpecsSelector(globalState).length > 0; } isBrushAvailable(globalState: GlobalChartState) { diff --git a/src/components/chart_container.tsx b/src/components/chart_container.tsx index 4fd72ba329..9a5ab8657f 100644 --- a/src/components/chart_container.tsx +++ b/src/components/chart_container.tsx @@ -137,14 +137,19 @@ class ChartContainerComponent extends React.Component { }; render() { - const { initialized } = this.props; + const { initialized, isChartEmpty } = this.props; if (!initialized) { + return null; + } + + if (isChartEmpty) { return (

No data to display

); } + const { pointerCursor, internalChartRenderer, getChartContainerRef, forwardStageRef } = this.props; return (
{ + const { + parentDimensions: { width, height }, + specsInitialized, + } = state; + + if (width <= 0 || height <= 0 || !specsInitialized) { + return false; + } if (state.internalChartState) { return state.internalChartState.isInitialized(state); - } else { - return false; } + return false; };