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: scales #1410

Merged
merged 151 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
7d0241e
refactor: remove some default values like ScaleData required domain a…
monfera Sep 22, 2021
14e36af
refactor: getSpecsFromStore simplification
monfera Sep 22, 2021
ab728f6
refactor: isClicking simplification
monfera Sep 22, 2021
848504f
chore: remove redundant bbox type
monfera Sep 22, 2021
685892c
chore: mandatory title
monfera Sep 22, 2021
4e378f2
refactor: name clarification for meaning
monfera Sep 23, 2021
53a8df9
test: textMeasure test update for mandatory arguments
monfera Sep 23, 2021
da234bc
refactor: simpler getAxesDimensions
monfera Sep 23, 2021
995f5a9
refactor: guarantee fresh object and no benefit of extraction
monfera Sep 23, 2021
031cf01
chore: remove an assertion
monfera Sep 23, 2021
3de1f9f
chore: remove another assertion
monfera Sep 23, 2021
c537e7c
chore: avoid a possibly infinite loop
monfera Sep 23, 2021
869f7ba
chore: avoid a possibly infinite loop 2
monfera Sep 23, 2021
710218c
chore: a bit more safety for log scales
monfera Sep 23, 2021
fcaba5a
chore: remove disused property ht MarcoV
monfera Sep 23, 2021
5715651
refactor: inline single use variable
monfera Sep 23, 2021
eae74ad
refactor: single exit point
monfera Sep 23, 2021
3778d62
refactor: merging tick functions 1
monfera Sep 23, 2021
941c525
refactor: merging tick functions 2
monfera Sep 23, 2021
8e5f4a5
refactor: merging tick functions 3 - test deactivation
monfera Sep 25, 2021
70a1e88
refactor: flatter function
monfera Sep 24, 2021
6989c93
refactor: flatter function 2
monfera Sep 24, 2021
5b5da23
refactor: flatter function 3
monfera Sep 24, 2021
9108fb7
chore: remove some curly and space noise
monfera Sep 24, 2021
3da18ce
fix: remove an assertion
monfera Sep 24, 2021
5bdda43
refactor: getPixelPaddedDomain for stp
monfera Sep 24, 2021
bbd7c8c
refactor: non-optional param
monfera Sep 24, 2021
7a44a16
refactor: remove noisy abstraction 1
monfera Sep 24, 2021
7cfa0ba
refactor: remove noisy abstraction 2
monfera Sep 24, 2021
185ee65
refactor: remove noisy abstraction 3
monfera Sep 24, 2021
79e0069
refactor: remove noisy abstraction 4
monfera Sep 24, 2021
6951747
refactor: remove noisy abstraction 5
monfera Sep 24, 2021
052459b
refactor: computeSeriesDomains signature change
monfera Sep 24, 2021
ec1edd0
refactor: computeSeriesDomains signature change 2
monfera Sep 24, 2021
291f4a5
chore: remove sort series 1
monfera Sep 24, 2021
3ecfd36
chore: remove sortSeriesBy 2
monfera Sep 24, 2021
2f8cd1b
refactor: simplify setBarSeriesAccessors
monfera Sep 24, 2021
1a34d65
refactor: minor inlining
monfera Sep 25, 2021
c9e3e97
refactor: rename getTicks to estimatedNonOverlappingTickCount
monfera Sep 25, 2021
9fa8a59
fix: return integer and rename to apt name
monfera Sep 25, 2021
5849c30
chore: no need to restate the domain
monfera Sep 25, 2021
251027e
refactor: removing scaleOrThrow 1
monfera Sep 25, 2021
e75fd80
refactor: removing scaleOrThrow 2
monfera Sep 25, 2021
9ec1e28
refactor: idiomatic integer check
monfera Sep 25, 2021
2e3010a
refactor: remove redundant map
monfera Sep 25, 2021
ff34e33
refactor: removing scaleOrThrow 3
monfera Sep 25, 2021
0ae60a7
refactor: removing scaleOrThrow 3 - area catch removal
monfera Sep 25, 2021
4ea677b
refactor: removing scaleOrThrow 3 - area catch removal 2
monfera Sep 25, 2021
60e5117
refactor: removing scaleOrThrow 3 - line catch removal
monfera Sep 25, 2021
2d16d9b
refactor: removing scaleOrThrow 3 - point catch removal
monfera Sep 25, 2021
107351b
refactor: simpler getDomainPolarity with minor behavioral difference
monfera Sep 25, 2021
7b208be
refactor: move getDomainPolarity to avoid exporting
monfera Sep 25, 2021
47b9deb
refactor: removing scaleOrThrow 4 - leftover renaming
monfera Sep 25, 2021
bd80dbe
refactor: isSingleValue order independency robustness
monfera Sep 25, 2021
61feedc
refactor: drive by invertWithStep return simplification
monfera Sep 25, 2021
299a071
refactor: drive by invertWithStep return simplification 2
monfera Sep 25, 2021
aea010a
refactor: remove a type assertion
monfera Sep 25, 2021
c2ed87f
refactor: isNaN is problematic
monfera Sep 25, 2021
0aec4bf
refactor: isNaN is problematic 2
monfera Sep 25, 2021
f774f85
refactor: removed two anies and one isNaN
monfera Sep 25, 2021
391ba94
refactor: isNaN is problematic 4
monfera Sep 25, 2021
5ae2b64
refactor: isNaN is problematic 5
monfera Sep 25, 2021
22c7f5e
refactor: isNaN is problematic 6
monfera Sep 25, 2021
9ce41f7
refactor: isNaN is problematic 7
monfera Sep 25, 2021
e3d7bca
refactor: isNaN is problematic 8
monfera Sep 25, 2021
4cca718
refactor: isNaN is problematic 9
monfera Sep 25, 2021
a3c55c7
refactor: minor if nesting
monfera Sep 25, 2021
c68ff55
refactor: minor if nesting 2
monfera Sep 25, 2021
8d5ed3a
refactor: minor if nesting 2
monfera Sep 25, 2021
a864419
refactor: minor if nesting 3
monfera Sep 25, 2021
58cc66a
refactor: minor if nesting 4
monfera Sep 25, 2021
87eed4c
refactor: minor if nesting 5
monfera Sep 25, 2021
2b8b7f7
refactor: minor if nesting 6
monfera Sep 25, 2021
dd8e0ef
refactor: getDomainPolarity uses
monfera Sep 25, 2021
5bd7ab2
refactor: remove enum object for numeric log base value
monfera Sep 25, 2021
a352716
chore: move module-internal types out of sight
monfera Sep 25, 2021
39bc868
chore: move exported type into the type file
monfera Sep 25, 2021
04fde2f
chore: move utility functions to the end
monfera Sep 25, 2021
9c54a7a
refactor: bring defaultScaleOptions to the front and avoid decomposin…
monfera Sep 25, 2021
0920114
refactor: topological ordering of scale initialization
monfera Sep 25, 2021
955fa26
refactor: topological ordering of scale initialization 2
monfera Sep 25, 2021
6884b42
refactor: topological ordering of scale initialization 3
monfera Sep 25, 2021
b910e24
refactor: topological ordering of scale initialization 4 - factor out…
monfera Sep 25, 2021
0e311e6
refactor: topological ordering of scale initialization 5
monfera Sep 25, 2021
e865663
refactor: topological ordering of scale initialization 6
monfera Sep 25, 2021
5bd14e3
refactor: topological ordering of scale initialization 7
monfera Sep 25, 2021
8282b03
refactor: topological ordering of scale initialization 8
monfera Sep 25, 2021
17674a9
refactor: topological ordering of scale initialization 9
monfera Sep 25, 2021
6e108e3
refactor: topological ordering of scale initialization a
monfera Sep 25, 2021
66cc01e
refactor: topological ordering of scale initialization b - remove imp…
monfera Sep 25, 2021
b216811
refactor: topological ordering of scale initialization c - lint membe…
monfera Sep 25, 2021
fb88445
refactor: topological ordering of scale initialization d - scale last
monfera Sep 25, 2021
9e66743
refactor: topological ordering of scale initialization d - cleanup
monfera Sep 25, 2021
0e0628f
refactor: topological ordering of scale initialization e - tick count…
monfera Sep 25, 2021
7056dbb
refactor: topological ordering of scale initialization f - no d3scale…
monfera Sep 25, 2021
aeb59fd
chore: remane rawDomain to dataDomain
monfera Sep 26, 2021
cc2db45
refactor: simplify value generation
monfera Sep 27, 2021
3843641
refactor: simplify value generation 2
monfera Sep 27, 2021
85bb376
refactor: pureScale always yields a number
monfera Sep 27, 2021
e6fd246
refactor: pureScale always yields a number 2
monfera Sep 27, 2021
6ca01c7
refactor: scale always yields a number
monfera Sep 27, 2021
68d23b9
refactor: minor cleanup
monfera Sep 27, 2021
19fdcf2
refactor: minor cleanup 2
monfera Sep 27, 2021
140658b
refactor: remove syllogisms
monfera Sep 27, 2021
d8596a1
minor: renames
monfera Sep 27, 2021
3340fac
refactor: dry up the thrice repeated logic for fallbackTickFormatter
monfera Sep 27, 2021
74e2fa5
refactor: extracted out scale lookup and console warn
monfera Sep 27, 2021
f2bd586
chore: one fewer if
monfera Sep 27, 2021
b0b8fe4
refactor: extracted out getThemedAxesStyles
monfera Sep 27, 2021
cbdc459
chore: map set returns the set
monfera Sep 27, 2021
6d3ef05
chore: fewer args are enough
monfera Sep 27, 2021
b03e984
refactor: separate the axis data join from measurement
monfera Sep 27, 2021
31dab4a
refactor: separate the axis data join from measurement 2
monfera Sep 27, 2021
c30ecec
refactor: simplify getAxesStylesSelector
monfera Sep 28, 2021
f36c901
refactor: rolling out mergeOptionals 1
monfera Sep 28, 2021
642d3ca
refactor: rolling out mergeOptionals 2
monfera Sep 28, 2021
36d6718
refactor: rolling out mergeOptionals 3
monfera Sep 28, 2021
d15b729
minor: rename
monfera Sep 28, 2021
b39ec9b
refactor: rolling out mergeOptionals 4 - switching former falsy ones
monfera Sep 28, 2021
76f840c
refactor: rolling out mergeOptionals 5 - switching over unit tests an…
monfera Sep 28, 2021
03e9f24
refactor: rolling out mergeOptionals 6 - unexport
monfera Sep 28, 2021
1a15e51
refactor: rolling out mergeOptionals 7 - rename
monfera Sep 28, 2021
7887bc8
refactor: rolling out mergeOptionals 7 - rename to former name
monfera Sep 28, 2021
d933cc5
refactor: very incomplete refactoring of computeAnnotationDimensions
monfera Sep 28, 2021
72d29d0
refactor: minor refactor of computeChartDimensions
monfera Sep 28, 2021
13a4219
refactor: single and simpler getGridLinesSelector
monfera Sep 28, 2021
4cfbce6
refactor: getCursorBandPosition wrapper noise removed
monfera Sep 28, 2021
88d05b3
refactor: misc selector changes and removals
monfera Sep 28, 2021
53192e1
refactor: simplify isOutElement logic
monfera Sep 28, 2021
5b5b713
refactor: simplify isOverElement logic
monfera Sep 28, 2021
dea3ebc
refactor: simplify hasPointerEventChanged logic
monfera Sep 28, 2021
559d06a
refactor: simplify hasPointerEventChanged logic 2
monfera Sep 28, 2021
b238af1
refactor: simplify hasPointerEventChanged logic 3
monfera Sep 28, 2021
8d0275e
refactor: removed some more boolean literal ternary yields
monfera Sep 28, 2021
f9374ee
refactor: mergePartial changes with default options
nickofthyme Sep 30, 2021
5cd3f3b
holder
nickofthyme Sep 30, 2021
40f23d1
cleanup: excessive line returns and set explcit mergeOptionalPartialV…
nickofthyme Sep 30, 2021
a6aa2dd
fix: merge partial mocks
nickofthyme Sep 30, 2021
252b94d
chore: untangle continuous scales file
nickofthyme Sep 30, 2021
9a96a00
Revert "chore: untangle continuous scales file"
monfera Oct 5, 2021
f2f27e9
chore: removed the former vestigial void 0 arguments
monfera Oct 5, 2021
4ba73bb
Revert "chore: mandatory title"
monfera Oct 5, 2021
d4c923e
chore: void 0 switched to warning level
monfera Oct 5, 2021
d7dc0d8
chore: reverted the renaming of showOverlappingTicks as it will go aw…
monfera Oct 5, 2021
ed6a3c0
Merge remote-tracking branch 'origin/master' into time-axis-07
monfera Oct 5, 2021
6fe5921
chore: used a verb
monfera Oct 5, 2021
c994a15
chore: reify isOutElement as booean
monfera Oct 5, 2021
cf24d2d
chore: remove an unnecessary line, part 1
monfera Oct 5, 2021
73855b6
chore: remove an unnecessary line, part 2
monfera Oct 5, 2021
802334d
chore: line breaking fix for suggested commit
monfera Oct 5, 2021
50269be
chore: further simplified hasPointerEventChanged
monfera Oct 5, 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
12 changes: 6 additions & 6 deletions docs/1-Typesofchart/0-Bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This chart now includes x and y axes. These axes can be `linear`, `ordinal` or `

<Chart>
<Settings theme={LIGHT_THEME} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -107,7 +107,7 @@ This chart now includes x and y axes. These axes can be `linear`, `ordinal` or `
```js
<Chart>
<Settings theme={LIGHT_THEME} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -136,7 +136,7 @@ This chart now includes x and y axes. These axes can be `linear`, `ordinal` or `
And below is an example of an `ordinal` x axis bar chart

<Chart>
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand All @@ -163,7 +163,7 @@ And below is an example of an `ordinal` x axis bar chart
```js

<Chart>
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -196,7 +196,7 @@ Here is an example of a `time` x axis
id={'bottom'}
position={Position.Bottom}
title={'Bottom axis'}
showOverlappingTicks={boolean('showOverlappingTicks bottom axis', false)}
ticksForCulledLabels={boolean('ticksForCulledLabels bottom axis', false)}
showOverlappingLabels={boolean('showOverlappingLabels bottom axis', false)}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
Expand Down Expand Up @@ -225,7 +225,7 @@ Here is an example of a `time` x axis
id={'bottom'}
position={Position.Bottom}
title={'Bottom axis'}
showOverlappingTicks={boolean('showOverlappingTicks bottom axis', false)}
ticksForCulledLabels={boolean('ticksForCulledLabels bottom axis', false)}
showOverlappingLabels={boolean('showOverlappingLabels bottom axis', false)}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
Expand Down
4 changes: 2 additions & 2 deletions docs/1-Typesofchart/1-Area.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here is the same chart including axes
id={'bottom'}
title={'timestamp per 1 minute'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter('HH:mm')}
/>
<Axis
Expand Down Expand Up @@ -96,7 +96,7 @@ To only have an area chart without axes, do not include the `<Axis/>` components
id={'bottom'}
title={'timestamp per 1 minute'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter('HH:mm')}
/>
<Axis
Expand Down
4 changes: 2 additions & 2 deletions docs/1-Typesofchart/2-Line.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Here is a `linear x axis` line chart
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down Expand Up @@ -94,7 +94,7 @@ Notice how the `<Axis position={Position.Left}/>` includes a tickFormat prop to
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down
18 changes: 9 additions & 9 deletions docs/1-Typesofchart/3-Stacked.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The stackAccessors prop is an array of fields that indicates the stack membershi
## Stacked bar chart examples
<Chart>
<Settings showLegend={true} legendPosition={Position.Right} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -62,7 +62,7 @@ The code for the chart above can be found below.
```js
<Chart>
<Settings showLegend={true} legendPosition={Position.Right} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -100,7 +100,7 @@ The code for the chart above can be found below.
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down Expand Up @@ -150,7 +150,7 @@ The code for the chart above can be found below.
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down Expand Up @@ -196,7 +196,7 @@ The code for the chart above can be found below.

<Chart>
<Settings showLegend />
<Axis id={'bottom'} title={'timestamp per 1 minute'} position={Position.Bottom} showOverlappingTicks={true} tickFormat={timeFormatter('HH:mm')}/>
<Axis id={'bottom'} title={'timestamp per 1 minute'} position={Position.Bottom} ticksForCulledLabels={true} tickFormat={timeFormatter('HH:mm')}/>
<Axis
id={'left'}
domain={{ fit: boolean('scale to extent', false) }}
Expand Down Expand Up @@ -230,7 +230,7 @@ The code for the chart above can be found below.
```js
<Chart>
<Settings showLegend />
<Axis id={'bottom'} title={'timestamp per 1 minute'} position={Position.Bottom} showOverlappingTicks={true} tickFormat={timeFormatter('HH:mm')}/>
<Axis id={'bottom'} title={'timestamp per 1 minute'} position={Position.Bottom} ticksForCulledLabels={true} tickFormat={timeFormatter('HH:mm')}/>
<Axis
id={'left'}
title={KIBANA_METRICS.metrics.kibana_os_load[0].metric.title}
Expand Down Expand Up @@ -410,7 +410,7 @@ This chart shows multiple line series with an axis and legend.
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
<Axis
Expand Down Expand Up @@ -455,7 +455,7 @@ Compare the above chart with the following below. The difference between the two
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
<Axis
Expand Down Expand Up @@ -504,7 +504,7 @@ Compare the above chart with the following below. The difference between the two
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
<Axis
Expand Down
4 changes: 2 additions & 2 deletions docs/1-Typesofchart/6-LegendsBars.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Here is a chart with a legend on the `right`

<Chart>
<Settings showLegend={true} legendPosition={Position.Right} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -56,7 +56,7 @@ What you should pay attention to:
```js
<Chart>
<Settings showLegend={true} legendPosition={Position.Right} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down
2 changes: 1 addition & 1 deletion docs/2-ChartPropTables/12-AxisProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The bar chart with axis example in the `Types of charts` section includes only s
| specType | `typeof SpecType.Axis` | SpecType.Axis | |
| groupId | GroupId | `__global__` | The ID of the axis group |
| hide | boolean | false | Hide this axis |
| showOverlappingTicks | boolean | false | Shows all ticks, also the one from the overlapping labels |
| ticksForCulledLabels | boolean | false | Shows all ticks, also the one from the overlapping labels |
| showOverlappingLabels | boolean | false | Shows all labels, also the overlapping ones |
| position | | Position.Left | Where the axis appear on the chart |
| tickSize | number | 10 | The length of the tick line |
Expand Down
12 changes: 6 additions & 6 deletions docs/2-ChartPropTables/8-ConsolidatedSnippets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Bar with axes
```js
<Chart>
<Settings theme={LIGHT_THEME} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand All @@ -67,7 +67,7 @@ Stacked bar chart
```js
<Chart>
<Settings showLegend={true} legendPosition={Position.Right} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} showOverlappingTicks={true} />
<Axis id={'bottom'} position={Position.Bottom} title={'Bottom axis'} ticksForCulledLabels={true} />
<Axis
id={'left2'}
title={'Left axis'}
Expand Down Expand Up @@ -117,7 +117,7 @@ Area chart with axes components
id={'bottom'}
title={'timestamp per 1 minute'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter('HH:mm')}
/>
<Axis
Expand All @@ -144,7 +144,7 @@ Stacked area chart
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down Expand Up @@ -207,7 +207,7 @@ Linear x axis line chart
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
title={'timestamp per 1 minute'}
/>
Expand Down Expand Up @@ -235,7 +235,7 @@ Stacked line chart
<Axis
id={'bottom'}
position={Position.Bottom}
showOverlappingTicks={true}
ticksForCulledLabels={true}
tickFormat={timeFormatter(niceTimeFormatByDay(1))}
/>
<Axis
Expand Down
3 changes: 1 addition & 2 deletions integration/tests/scales_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

import { LogBase } from '../../packages/charts/src/scales/scale_continuous';
import { common } from '../page_objects';

describe('Scales stories', () => {
Expand All @@ -15,7 +14,7 @@ describe('Scales stories', () => {
${'Negative'} | ${true}
${'Positive'} | ${false}
`('$polarity values', ({ value: negative }) => {
it.each(Object.values(LogBase))('should render proper ticks with %s base', async (base) => {
it.each(['common', 'binary', 'natural'])('should render proper ticks with %s base', async (base) => {
await common.expectChartAtUrlToMatchScreenshot(
`http://localhost:9001/?path=/story/scales--log-scale-options&knob-Use negative values_Y - Axis=${negative}&knob-Log base_Y - Axis=${base}&knob-Fit domain_Y - Axis=true&knob-Use default limit_Y - Axis=true`,
);
Expand Down
14 changes: 2 additions & 12 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ export interface AxisSpec extends Spec {
// @deprecated
showGridLines?: boolean;
showOverlappingLabels: boolean;
showOverlappingTicks: boolean;
// (undocumented)
specType: typeof SpecType.Axis;
style?: RecursivePartial<Omit<AxisStyle, 'gridLine'>>;
tickFormat?: TickFormatter;
ticks?: number;
ticksForCulledLabels: boolean;
title?: string;
}

Expand Down Expand Up @@ -1328,19 +1328,9 @@ export interface LineStyle {
visible: boolean;
}

// @public (undocumented)
export const LogBase: Readonly<{
Common: "common";
Binary: "binary";
Natural: "natural";
}>;

// @public
export type LogBase = $Values<typeof LogBase>;

// @public
export interface LogScaleOptions {
logBase?: LogBase;
logBase?: number;
logMinLimit?: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,23 @@ const mapConfigToTheme = ({
fontFamily,
}: RecursivePartial<Config> = {}): PartialTheme => ({
chartMargins: margin,
background: {
color: backgroundColor,
},
background: { color: backgroundColor },
goal: {
minFontSize,
maxFontSize,
tickLabel: {
fontFamily,
},
majorLabel: {
fontFamily,
},
minorLabel: {
fontFamily,
},
tickLabel: { fontFamily },
majorLabel: { fontFamily },
minorLabel: { fontFamily },
},
});
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved

/** @internal */
export function render(spec: GoalSpec, parentDimensions: Dimensions, theme: Theme): ShapeViewModel {
// override theme and spec with old deprecated config options
const mergedTheme: Theme = mergePartial(theme, mapConfigToTheme(spec.config), { mergeOptionalPartialValues: true });
const mergedTheme: Theme = mergePartial(theme, mapConfigToTheme(spec.config));
const mergedSpec: GoalSpec = mergePartial(spec, {
angleEnd: spec?.config?.angleEnd,
angleStart: spec?.config?.angleStart,
});

return shapeViewModel(mergedSpec, mergedTheme, parentDimensions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ function getValuesInRange(
return values.slice(startIndex, endIndex);
}

/**
* Resolves the maximum number of ticks based on the chart width and sample label based on formatter config.
*/
function getTicks(chartWidth: number, { formatter, padding, fontSize, fontFamily }: Config['xAxisLabel']): number {
function estimatedNonOverlappingTickCount(
chartWidth: number,
{ formatter, padding, fontSize, fontFamily }: Config['xAxisLabel'],
): number {
return withTextMeasure((textMeasure) => {
const labelSample = formatter(Date.now());
const { width } = textMeasure(labelSample, padding, fontSize, fontFamily);
const maxTicks = Math.floor(chartWidth / width);
const maxTicks = chartWidth / width;
// Dividing by 2 is a temp fix to make sure {@link ScaleContinuous} won't produce
// to many ticks creating nice rounded tick values
// TODO add support for limiting the number of tick in {@link ScaleContinuous}
return maxTicks / 2;
return Math.floor(maxTicks / 2);
});
}

Expand All @@ -89,13 +89,11 @@ export function shapeViewModel(
const { table, yValues, xDomain } = heatmapTable;

// measure the text width of all rows values to get the grid area width
const boxedYValues = yValues.map<Box & { value: NonNullable<PrimitiveValue> }>((value) => {
return {
text: config.yAxisLabel.formatter(value),
value,
...config.yAxisLabel,
};
});
const boxedYValues = yValues.map<Box & { value: NonNullable<PrimitiveValue> }>((value) => ({
text: config.yAxisLabel.formatter(value),
value,
...config.yAxisLabel,
}));

// compute the scale for the rows positions
const yScale = scaleBand<NonNullable<PrimitiveValue>>().domain(yValues).range([0, height]);
Expand All @@ -112,7 +110,7 @@ export function shapeViewModel(
nice: false,
},
{
desiredTickCount: getTicks(chartDimensions.width, config.xAxisLabel),
desiredTickCount: estimatedNonOverlappingTickCount(chartDimensions.width, config.xAxisLabel),
timeZone: config.timeZone,
},
)
Expand Down
Loading