-
Notifications
You must be signed in to change notification settings - Fork 120
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: nice ticks everywhere #1087
Changes from 5 commits
fe47338
acee82b
521a15f
5aa72fc
6ec6b3e
5d2f1a8
c063d22
08527a0
5120ef8
b9db40c
38ca96f
e0416b5
cedf1bb
c0060d0
f0a9090
7062f47
2d16951
df26747
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,14 +74,6 @@ export const AnnotationType: Readonly<{ | |
// @public (undocumented) | ||
export type AnnotationType = $Values<typeof AnnotationType>; | ||
|
||
// @public (undocumented) | ||
export interface APIScale<T extends ScaleType> { | ||
// (undocumented) | ||
nice: boolean; | ||
// (undocumented) | ||
type: T; | ||
} | ||
|
||
// @public (undocumented) | ||
export interface ArcSeriesStyle { | ||
// (undocumented) | ||
|
@@ -1685,10 +1677,12 @@ export type SeriesNameFn = (series: XYChartSeriesIdentifier, isTooltip: boolean) | |
// @public (undocumented) | ||
export interface SeriesScales { | ||
timeZone?: string; | ||
xScaleType: XScaleType | APIScale<XScaleType>; | ||
xNice?: boolean; | ||
xScaleType: XScaleType; | ||
yNice?: boolean; | ||
// @deprecated | ||
yScaleToDataExtent?: boolean; | ||
yScaleType: ScaleContinuousType | APIScale<ScaleContinuousType>; | ||
yScaleType: ScaleContinuousType; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
|
||
// @public (undocumented) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ export function shapeViewModel( | |
nice: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the |
||
}, | ||
{ | ||
ticks: getTicks(chartDimensions.width, config.xAxisLabel), | ||
desiredTickCount: getTicks(chartDimensions.width, config.xAxisLabel), | ||
timeZone: config.timeZone, | ||
}, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ import { getChartIdSelector } from '../../../../state/selectors/get_chart_id'; | |
import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs'; | ||
import { getAccessorValue } from '../../../../utils/accessor'; | ||
import { mergeXDomain } from '../../../xy_chart/domains/x_domain'; | ||
import { getDefaultAPIScale } from '../../../xy_chart/scales/get_api_scales'; | ||
import { getXNiceFromSpec, getXScaleTypeFromSpec } from '../../../xy_chart/scales/get_api_scales'; | ||
import { X_SCALE_DEFAULT } from '../../specs/scale_defaults'; | ||
import { HeatmapTable } from './compute_chart_dimensions'; | ||
import { getHeatmapSpecSelector } from './get_heatmap_spec'; | ||
|
@@ -77,9 +77,10 @@ export const getHeatmapTableSelector = createCachedSelector( | |
|
||
resultData.xDomain = mergeXDomain( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
...getDefaultAPIScale(spec.xScaleType, X_SCALE_DEFAULT), | ||
type: getXScaleTypeFromSpec(spec.xScaleType), | ||
nice: getXNiceFromSpec(), | ||
isBandScale: false, | ||
ticks: X_SCALE_DEFAULT.ticks, | ||
desiredTickCount: X_SCALE_DEFAULT.desiredTickCount, | ||
customDomain: xDomain, | ||
}, | ||
resultData.xValues, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ import { MockXDomain } from '../../../mocks/xy/domains'; | |
import { ScaleType } from '../../../scales/constants'; | ||
import { SpecType } from '../../../specs/constants'; | ||
import { Dimensions } from '../../../utils/dimensions'; | ||
import { getAPIScaleConfigs } from '../state/selectors/get_api_scale_configs'; | ||
import { getScaleConfigsFromSpecs } from '../state/selectors/get_api_scale_configs'; | ||
import { computeSeriesDomains } from '../state/utils/utils'; | ||
import { computeXScale } from '../utils/scales'; | ||
import { BasicSeriesSpec, SeriesType } from '../utils/specs'; | ||
|
@@ -103,31 +103,31 @@ describe('Crosshair utils linear scale', () => { | |
const barSeries = [barSeries1]; | ||
const barSeriesDomains = computeSeriesDomains( | ||
barSeries, | ||
getAPIScaleConfigs([], barSeries, MockGlobalSpec.settings()), | ||
getScaleConfigsFromSpecs([], barSeries, MockGlobalSpec.settings()), | ||
); | ||
|
||
const multiBarSeries = [barSeries1, barSeries2]; | ||
const multiBarSeriesDomains = computeSeriesDomains( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with |
||
multiBarSeries, | ||
getAPIScaleConfigs([], multiBarSeries, MockGlobalSpec.settings()), | ||
getScaleConfigsFromSpecs([], multiBarSeries, MockGlobalSpec.settings()), | ||
); | ||
|
||
const lineSeries = [lineSeries1]; | ||
const lineSeriesDomains = computeSeriesDomains( | ||
lineSeries, | ||
getAPIScaleConfigs([], lineSeries, MockGlobalSpec.settings()), | ||
getScaleConfigsFromSpecs([], lineSeries, MockGlobalSpec.settings()), | ||
); | ||
|
||
const multiLineSeries = [lineSeries1, lineSeries2]; | ||
const multiLineSeriesDomains = computeSeriesDomains( | ||
multiLineSeries, | ||
getAPIScaleConfigs([], multiLineSeries, MockGlobalSpec.settings()), | ||
getScaleConfigsFromSpecs([], multiLineSeries, MockGlobalSpec.settings()), | ||
); | ||
|
||
const mixedLinesBars = [lineSeries1, lineSeries2, barSeries1, barSeries2]; | ||
const mixedLinesBarsSeriesDomains = computeSeriesDomains( | ||
mixedLinesBars, | ||
getAPIScaleConfigs([], mixedLinesBars, MockGlobalSpec.settings()), | ||
getScaleConfigsFromSpecs([], mixedLinesBars, MockGlobalSpec.settings()), | ||
); | ||
|
||
const barSeriesScale = computeXScale({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the PR:
SeriesScales
, we might eventually consider a more specific term, eg.ProjectionPair
orCartesianPlaneProjections
(or a shorter version), to express that it's not some set or array of scales, but it defines the Cartesian plane, with the orthogonal projection pairscale
at the moment;Projection
captures the linearity (or how it's non-linear) of a dimension, eg. currentScaleType
; whileScale
adds the multiplier and usually offset, for example, by using the data domain and the screen pixel range