Files
grafana/packages/grafana-ui/src/components/uPlot/config/UPlotScaleBuilder.ts
Dominik Prokop 7e21863982 GraphNG: Init refactorings and fixes (#29275)
* When comparing field config, shallowly compare custom config

* Refactoring plot init and data update (WIP)

* GraphNG: Fixed points mode

* Fixed min & max from frame config

* Fixed axis left / right auto logic

* Minor tweak to cursor color

* Fixed time axis now that uPlot deals in milliseconds as well

* fixed ts issue

* Updated test

* Fixed axis placement logic again

* Added new unit test for axis placement logic

* Removed unused props

* Fixed zoom issue due to uPlot time resolution change

* Add back millisecond time tick support

* Comment out GraphNG test

* Fixed being able to switch legend on/off

* Updated unit tests

* GraphNG: Fixed hiding axis

* Frame comparison: allow skipping properties

* Update y-axis ranges without reinitializing uPlot

* update snap

* GraphNG: Fixed axis label placement and spacing issues

* update snaps

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-11-23 19:07:02 +01:00

24 lines
555 B
TypeScript

import isNumber from 'lodash/isNumber';
import { Scale } from 'uplot';
import { PlotConfigBuilder } from '../types';
export interface ScaleProps {
scaleKey: string;
isTime?: boolean;
min?: number | null;
max?: number | null;
}
export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
getConfig() {
const { isTime, scaleKey, min, max } = this.props;
const range = isNumber(min) && isNumber(max) ? [min, max] : undefined;
return {
[scaleKey]: {
time: !!isTime,
range,
},
};
}
}