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

feat(xy): mutilayer time axis step 1 #1326

Merged
merged 76 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
7efa762
feat: left aligned horizontal tick
monfera Aug 30, 2021
85c2eea
chore: placate prettier
monfera Aug 30, 2021
7688e5a
test: working around no gaps
monfera Aug 30, 2021
031becb
test: us time
monfera Aug 30, 2021
8ab9e36
test: niced top
monfera Aug 30, 2021
d247f5d
test: multiaxis
monfera Aug 31, 2021
165274c
test: three axis rows
monfera Aug 31, 2021
0177663
test: formatting conditional on width
monfera Aug 31, 2021
6293439
test: nicer label formats
monfera Aug 31, 2021
c447f29
test: decent mock
monfera Aug 31, 2021
ee825ff
test: baseline for whiskers
monfera Aug 31, 2021
72256a9
test: whisker knob
monfera Aug 31, 2021
d958102
test: horizontal axis title knob
monfera Aug 31, 2021
ca70875
test: indenting the higher time axes too
monfera Aug 31, 2021
af35693
test: mock update
monfera Aug 31, 2021
a4b8e80
test: more knobs
monfera Aug 31, 2021
5798a77
test: smaller y axis padding
monfera Aug 31, 2021
2e199ae
refactor: getAxesSpecForSpecId simplification
monfera Sep 2, 2021
2cb238b
perf: getAxesSpecForSpecId restore perf
monfera Sep 2, 2021
566fe6c
refactor: single use binding gone
monfera Sep 2, 2021
cc8a37f
refactor: removed redundant if branches
monfera Sep 2, 2021
546544a
chore: post merge fix
monfera Sep 2, 2021
82a01c7
refactor: avoid any work in some cases
monfera Sep 2, 2021
f4dfc44
test: mock update
monfera Sep 2, 2021
d8c230b
refactor: don't destructively modify the input
monfera Sep 2, 2021
53ecfcc
refactor: removed order check and some single use vars
monfera Sep 2, 2021
141c2ab
refactor: reduction update in one place only
monfera Sep 2, 2021
23c865e
chore: declare before first occurrence
monfera Sep 3, 2021
d9ed46e
test: knobs
monfera Sep 3, 2021
7f81cd3
refactor: fewer sorting
monfera Sep 3, 2021
1840575
chore: comment
monfera Sep 3, 2021
6472fcd
test: toIncludeSameMembers
monfera Sep 3, 2021
93adb08
refactor: sort related updates and AxesTicksDimensions type
monfera Sep 3, 2021
404d195
test: a leftover order lock-in relaxed
monfera Sep 3, 2021
46e98f3
feat: fully separated general vs axis tick label code
monfera Sep 3, 2021
e2f10a7
chore: removed unused axis properties
monfera Sep 4, 2021
fdd00d5
refactor: use all ticks for deduplication fingerprinting
monfera Sep 4, 2021
bdfa38f
refactor: use a simple reduction
monfera Sep 6, 2021
a3d1193
feat: removed the optional and unused axis deduplication
monfera Sep 6, 2021
e20c790
refactor: repackage axis view model calcs 1
monfera Sep 6, 2021
277c093
refactor: repackage axis view model calcs 2
monfera Sep 6, 2021
ebca068
refactor: repackage axis view model calcs 3
monfera Sep 6, 2021
7790347
refactor: repackage axis view model calcs 4
monfera Sep 6, 2021
82ce347
refactor: lift out scale fun
monfera Sep 6, 2021
d788082
refactor: scale calc is its own node
monfera Sep 6, 2021
b934e24
refactor: minor if and switch reduction
monfera Sep 6, 2021
8bf0136
refactor: ternary
monfera Sep 6, 2021
7d5ab28
refactor: getMinMaxRange
monfera Sep 6, 2021
6fc9bbb
refactor: flipped to more sensible order isYDomain to isXDomain
monfera Sep 6, 2021
f9af814
refactor: rest
monfera Sep 6, 2021
1e9432a
chore: removed unused getVerticalAxisTickLineProps and getHorizontalA…
monfera Sep 6, 2021
b3fe500
chore: unexported single-use utility function axisExtent
monfera Sep 6, 2021
fb012bc
refactor: getVerticalAlign
monfera Sep 7, 2021
a5587d1
refactor: getHorizontalAlign
monfera Sep 7, 2021
937c2d3
refactor: align checks
monfera Sep 7, 2021
c7e73bf
refactor: extract out multiplier
monfera Sep 7, 2021
469ca41
refactor: discontinue high noise ratio too simple function
monfera Sep 7, 2021
9a0b49a
refactor: removed costly includes checks for equality
monfera Sep 7, 2021
a607872
refactor: shorter param list for getAxisPosition
monfera Sep 7, 2021
8c67f51
refactor: hoist common constants
monfera Sep 7, 2021
b547899
refactor: getAxisPosition is now a well shaped function
monfera Sep 7, 2021
3358b60
refactor: getAxesGeometries flow simplification
monfera Sep 7, 2021
5109cc0
refactor: getAxesGeometries reduction simplification
monfera Sep 7, 2021
7e73ac1
refactor: single use util function compatible in result shape
monfera Sep 7, 2021
46d0221
refactor: avoid reducing over the same thing twice
monfera Sep 7, 2021
ed1caff
refactor: avoid reducing over the same thing twice 2
monfera Sep 7, 2021
83c77f2
refactor: type has shifted in meaning
monfera Sep 7, 2021
39a55b9
chore: minor reorder for better flow
monfera Sep 7, 2021
fee7148
refactor: updated utility function boundary
monfera Sep 7, 2021
d9944a4
test: updates for the new utility function
monfera Sep 7, 2021
f777a94
chore: removing the replaced function
monfera Sep 7, 2021
b22c647
fix: sort the right thing ht @markov00
monfera Sep 7, 2021
448babf
test: tooltip to match color ht Marco
monfera Sep 7, 2021
5a587c5
fix: showDuplicatedTicks looks for render candidate rather than theor…
monfera Sep 7, 2021
44f76ed
fix: abstractGeoms were meant to be spread ht @nickofthyme
monfera Sep 8, 2021
94aa195
Merge remote-tracking branch 'origin/master' into time-axis-04
monfera Sep 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions integration/server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ module.exports = {
},
module: {
rules: [
{
test: /\.(ttf|eot|woff|woff2|svg)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
},
},
},
{
test: /\.tsx?$/,
loader: 'ts-loader',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
3 changes: 1 addition & 2 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ export const DEFAULT_TOOLTIP_SNAP = true;
export const DEFAULT_TOOLTIP_TYPE: "vertical";

// @public (undocumented)
export type DefaultSettingsProps = 'id' | 'chartType' | 'specType' | 'rendering' | 'rotation' | 'resizeDebounce' | 'pointerUpdateDebounce' | 'pointerUpdateTrigger' | 'animateData' | 'debug' | 'tooltip' | 'theme' | 'hideDuplicateAxes' | 'brushAxis' | 'minBrushDelta' | 'externalPointerEvents' | 'showLegend' | 'showLegendExtra' | 'legendPosition' | 'legendMaxDepth' | 'ariaUseDefaultSummary' | 'ariaLabelHeadingLevel' | 'ariaTableCaption';
export type DefaultSettingsProps = 'id' | 'chartType' | 'specType' | 'rendering' | 'rotation' | 'resizeDebounce' | 'pointerUpdateDebounce' | 'pointerUpdateTrigger' | 'animateData' | 'debug' | 'tooltip' | 'theme' | 'brushAxis' | 'minBrushDelta' | 'externalPointerEvents' | 'showLegend' | 'showLegendExtra' | 'legendPosition' | 'legendMaxDepth' | 'ariaUseDefaultSummary' | 'ariaLabelHeadingLevel' | 'ariaTableCaption';

// @public (undocumented)
export const DEPTH_KEY = "depth";
Expand Down Expand Up @@ -1869,7 +1869,6 @@ export interface SettingsSpec extends Spec, LegendSpec {
debugState?: boolean;
// @alpha
externalPointerEvents: ExternalPointerEventsSettings;
hideDuplicateAxes: boolean;
minBrushDelta?: number;
noResults?: ComponentType | ReactChild;
onAnnotationClick?: AnnotationClickListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ export function geoms(
const angleScale = (x: number) => angleStart + (angleRange * (x - domain[0])) / domainExtent;
const clockwise = angleStart > angleEnd; // todo refine this crude approach

const geomObjects = abstractGeoms
.slice()
const [...geomObjects] = abstractGeoms
.sort((a, b) => a.order - b.order)
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
.map(({ landmarks, aes }) => {
const at = get(landmarks, 'at', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export function shapeViewModel(spec: GoalSpec, theme: Theme, chartDimensions: Di
y: margin.top + innerHeight / 2,
};

const pickQuads: PickFunction = (x, y) =>
-innerWidth / 2 <= x && x <= innerWidth / 2 && -innerHeight / 2 <= y && y <= innerHeight / 2
? [bulletViewModel]
: [];

const {
subtype,
base,
Expand Down Expand Up @@ -91,6 +86,11 @@ export function shapeViewModel(spec: GoalSpec, theme: Theme, chartDimensions: Di
angleEnd,
};

const pickQuads: PickFunction = (x, y) =>
-innerWidth / 2 <= x && x <= innerWidth / 2 && -innerHeight / 2 <= y && y <= innerHeight / 2
? [bulletViewModel]
: [];

return {
config: theme.goal,
chartCenter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,14 @@ function getTreesForSpec(
group.push(next);
return map;
}, new Map<string, HierarchyOfArrays>());
return Array.from(groups)
.sort(getPredicateFn(sort))
.map(([groupKey, subData], innerIndex) => ({
name: format(groupKey),
smAccessorValue: groupKey,
style: smStyle,
tree: partitionTree(
subData,
valueAccessor,
layers,
configMetadata.partitionLayout.dflt,
config.partitionLayout,
[{ index: innerIndex, value: String(groupKey) }],
),
}));
return [...groups].sort(getPredicateFn(sort)).map(([groupKey, subData], innerIndex) => ({
name: format(groupKey),
smAccessorValue: groupKey,
style: smStyle,
tree: partitionTree(subData, valueAccessor, layers, configMetadata.partitionLayout.dflt, config.partitionLayout, [
{ index: innerIndex, value: String(groupKey) },
]),
}));
} else {
return [
{
Expand Down
10 changes: 4 additions & 6 deletions packages/charts/src/chart_types/xy_chart/annotations/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ export function computeRectAnnotationTooltipState(
chartRotation: Rotation,
chartDimensions: Dimensions,
): AnnotationTooltipState | null {
// allow picking up the last spec added as the top most or use it's zIndex value
// allow picking up the last spec added as the top most or use its zIndex value
const sortedAnnotationSpecs = annotationSpecs
.filter(isRectAnnotation)
.reverse()
.sort(({ zIndex: a = Number.MIN_SAFE_INTEGER }, { zIndex: b = Number.MIN_SAFE_INTEGER }) => b - a);
.sort(({ zIndex: a = Number.MIN_SAFE_INTEGER }, { zIndex: b = Number.MIN_SAFE_INTEGER }) => a - b);

for (let i = 0; i < sortedAnnotationSpecs.length; i++) {
const spec = sortedAnnotationSpecs[i];
Expand Down Expand Up @@ -69,11 +68,10 @@ export function computeMultipleRectAnnotationTooltipState(
chartRotation: Rotation,
chartDimensions: Dimensions,
): AnnotationTooltipState[] {
// allow picking up the last spec added as the top most or use it's zIndex value
// allow picking up the last spec added as the top most or use its zIndex value
const sortedAnnotationSpecs = annotationSpecs
.filter(isRectAnnotation)
.reverse()
.sort(({ zIndex: a = Number.MIN_SAFE_INTEGER }, { zIndex: b = Number.MIN_SAFE_INTEGER }) => b - a);
.sort(({ zIndex: a = Number.MIN_SAFE_INTEGER }, { zIndex: b = Number.MIN_SAFE_INTEGER }) => a - b);
return sortedAnnotationSpecs.reduce<AnnotationTooltipState[]>((acc, spec) => {
const annotationDimension = annotationDimensions.get(spec.id);
if (!spec.hideTooltips && annotationDimension) {
Expand Down
5 changes: 3 additions & 2 deletions packages/charts/src/chart_types/xy_chart/axes/axes_sizes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import { Position } from '../../../utils/common';
import { innerPad, outerPad, PerSideDistance } from '../../../utils/dimensions';
import { AxisId } from '../../../utils/ids';
import { AxisStyle, Theme } from '../../../utils/themes/theme';
import { AxesTicksDimensions } from '../state/selectors/compute_axis_ticks_dimensions';
import { getSpecsById } from '../state/utils/spec';
import { isVerticalAxis } from '../utils/axis_type_utils';
import { AxisViewModel, getTitleDimension, shouldShowTicks } from '../utils/axis_utils';
import { getTitleDimension, shouldShowTicks } from '../utils/axis_utils';
import { AxisSpec } from '../utils/specs';

/** @internal */
export function computeAxesSizes(
{ axes: sharedAxesStyles, chartMargins }: Theme,
axisDimensions: Map<AxisId, AxisViewModel>,
axisDimensions: AxesTicksDimensions,
axesStyles: Map<AxisId, AxisStyle | null>,
axisSpecs: AxisSpec[],
smSpec?: SmallMultiplesSpec,
Expand Down
4 changes: 2 additions & 2 deletions packages/charts/src/chart_types/xy_chart/domains/x_domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function mergeXDomain(
seriesXComputedDomains = computeOrdinalDataDomain(values, identity, false, true);
if (customDomain) {
if (Array.isArray(customDomain)) {
seriesXComputedDomains = customDomain;
seriesXComputedDomains = [...customDomain];
} else {
if (fallbackScale === ScaleType.Ordinal) {
Logger.warn(`xDomain ignored for fallback ordinal scale. Options to resolve:
Expand Down Expand Up @@ -140,7 +140,7 @@ export function findMinInterval(xValues: number[]): number {
if (valuesLength === 1) {
return 1;
}
const sortedValues = xValues.slice().sort(compareByValueAsc);
const sortedValues = [...xValues].sort(compareByValueAsc);
let i;
let minInterval = Math.abs(sortedValues[1] - sortedValues[0]);
for (i = 1; i < valuesLength - 1; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function renderTickLabel(
ctx: CanvasRenderingContext2D,
tick: AxisTick,
showTicks: boolean,
{ axisSpec: { position, labelFormat }, dimension, size, debug, axisStyle }: AxisProps,
{ axisSpec: { position }, dimension, size, debug, axisStyle }: AxisProps,
) {
const labelStyle = axisStyle.tickLabel;
const tickLabelProps = getTickLabelProps(
Expand Down Expand Up @@ -46,7 +46,7 @@ export function renderTickLabel(
renderText(
ctx,
center,
labelFormat ? labelFormat(tick.value) : tick.label,
tick.axisTickLabel,
{
fontFamily: labelStyle.fontFamily,
fontStyle: labelStyle.fontStyle ?? 'normal',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable jest/no-conditional-expect */

import 'jest-extended';
import React from 'react';
import { Store } from 'redux';

Expand Down Expand Up @@ -79,7 +80,6 @@ const settingSpec = MockGlobalSpec.settings({
tooltip: {
type: TooltipType.VerticalCursor,
},
hideDuplicateAxes: false,
theme: {
chartPaddings: { top: 0, left: 0, bottom: 0, right: 0 },
chartMargins: { top: 10, left: 10, bottom: 0, right: 0 },
Expand Down Expand Up @@ -1289,7 +1289,7 @@ describe('Clickable annotations', () => {

expect(onAnnotationClick).toBeCalled();
const callArgs = onAnnotationClick.mock.calls[0][0];
expect(callArgs.rects).toEqual([
expect(callArgs.rects).toIncludeSameMembers([
monfera marked this conversation as resolved.
Show resolved Hide resolved
{
id: 'rect2',
datum: {
Expand Down
165 changes: 0 additions & 165 deletions packages/charts/src/chart_types/xy_chart/state/chart_state.test.ts

This file was deleted.

Loading