Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove default small multiples value #977

Merged
merged 14 commits into from
Jan 19, 2021
Merged
30 changes: 6 additions & 24 deletions src/chart_types/xy_chart/rendering/rendering.areas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down Expand Up @@ -153,10 +150,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down Expand Up @@ -248,10 +242,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down Expand Up @@ -284,10 +275,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down Expand Up @@ -325,10 +313,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_2}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_2}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down Expand Up @@ -361,10 +346,7 @@ describe('Rendering points - areas', () => {
yAccessor: 1,
splitAccessors: new Map(),
seriesKeys: [1],
key:
'groupId{group_1}spec{spec_2}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
key: 'groupId{group_1}spec{spec_2}yAccessor{1}splitAccessors{}',
},
styleOverrides: undefined,
value: {
Expand Down
83 changes: 6 additions & 77 deletions src/chart_types/xy_chart/state/chart_state.interactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,58 +105,6 @@ function initStore(spec: BasicSeriesSpec) {
return store;
}

// const barStyle = {
// rect: {
// opacity: 1,
// },
// rectBorder: {
// strokeWidth: 1,
// visible: false,
// },
// displayValue: {
// fill: 'black',
// fontFamily: '',
// fontSize: 2,
// offsetX: 0,
// offsetY: 0,
// padding: 2,
// },
// };
// const indexedGeom1Red: BarGeometry = {
// color: 'red',
// x: 0,
// y: 0,
// width: 50,
// height: 100,
// value: {
// x: 0,
// y: 10,
// accessor: 'y1',
// },
// geometryId: {
// specId: SPEC_ID,
// seriesKey: [],
// },
// seriesStyle: barStyle,
// };
// const indexedGeom2Blue: BarGeometry = {
// color: 'blue',
// x: 50,
// y: 50,
// width: 50,
// height: 50,
// value: {
// x: 1,
// y: 5,
// accessor: 'y1',
// },
// geometryId: {
// specId: SPEC_ID,
// seriesKey: [],
// },
// seriesStyle: barStyle,
// };

describe('Chart state pointer interactions', () => {
let store: Store<GlobalChartState>;
const onElementOutCaller = createOnElementOutCaller();
Expand Down Expand Up @@ -421,14 +369,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [0, 10],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down Expand Up @@ -470,15 +415,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [0, 10],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,

smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down Expand Up @@ -523,14 +464,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [0, 10],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down Expand Up @@ -580,14 +518,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [(spec.data[0] as Array<any>)[0], (spec.data[0] as Array<any>)[1]],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down Expand Up @@ -616,14 +551,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [(spec.data[1] as Array<any>)[0], (spec.data[1] as Array<any>)[1]],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down Expand Up @@ -716,14 +648,11 @@ function mouseOverTestSuite(scaleType: XScaleType) {
datum: [1, 5],
},
{
key:
'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}smV{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}smH{__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__}',
key: 'groupId{group_1}spec{spec_1}yAccessor{1}splitAccessors{}',
seriesKeys: [1],
specId: 'spec_1',
splitAccessors: new Map(),
yAccessor: 1,
smHorizontalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
smVerticalAccessorValue: '__ECH_DEFAULT_SINGLE_PANEL_SM_VALUE__',
},
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ import createCachedSelector from 're-reselect';
import { ChartTypes } from '../../..';
import { ScaleBand } from '../../../../scales';
import { SpecTypes } from '../../../../specs/constants';
import {
DEFAULT_SINGLE_PANEL_SM_VALUE,
DEFAULT_SM_PANEL_PADDING,
SmallMultiplesSpec,
} from '../../../../specs/small_multiples';
import { DEFAULT_SM_PANEL_PADDING, SmallMultiplesSpec } from '../../../../specs/small_multiples';
import { GlobalChartState } from '../../../../state/chart_state';
import { getChartIdSelector } from '../../../../state/selectors/get_chart_id';
import { getSpecsFromStore } from '../../../../state/utils';
Expand Down Expand Up @@ -68,6 +64,6 @@ export const computeSmallMultipleScalesSelector = createCachedSelector(

function getScale(domain: Domain, maxRange: number, padding = DEFAULT_SM_PANEL_PADDING) {
const singlePanelSmallMultiple = domain.length <= 1;
const defaultDomain = domain.length === 0 ? [DEFAULT_SINGLE_PANEL_SM_VALUE] : domain;
const defaultDomain = domain.length === 0 ? [undefined] : domain;
return new ScaleBand(defaultDomain, [0, maxRange], undefined, singlePanelSmallMultiple ? 0 : padding);
}
5 changes: 2 additions & 3 deletions src/chart_types/xy_chart/state/selectors/get_cursor_band.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import createCachedSelector from 're-reselect';
import { Line, Rect } from '../../../../geoms/types';
import { Scale } from '../../../../scales';
import { SettingsSpec, PointerEvent } from '../../../../specs/settings';
import { DEFAULT_SINGLE_PANEL_SM_VALUE } from '../../../../specs/small_multiples';
import { GlobalChartState } from '../../../../state/chart_state';
import { getChartIdSelector } from '../../../../state/selectors/get_chart_id';
import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs';
Expand Down Expand Up @@ -115,8 +114,8 @@ function getCursorBand(
pointerPosition = {
x,
y: 0,
verticalPanelValue: DEFAULT_SINGLE_PANEL_SM_VALUE,
horizontalPanelValue: DEFAULT_SINGLE_PANEL_SM_VALUE,
verticalPanelValue: null,
horizontalPanelValue: null,
};
xValue = {
value: externalPointerEvent.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export const getTooltipAnchorPositionSelector = createCachedSelector(
return null;
}

const topPos = vertical.scale(projectedPointerPosition.verticalPanelValue) || 0;
const leftPos = horizontal.scale(projectedPointerPosition.horizontalPanelValue) || 0;
const topPos = vertical.scale(projectedPointerPosition.verticalPanelValue) ?? 0;
const leftPos = horizontal.scale(projectedPointerPosition.horizontalPanelValue) ?? 0;

const panel = {
width: horizontal.bandwidth,
Expand Down
Loading