GraphNG: always use "x" as scaleKey for x axis (#33884)

This commit is contained in:
Leon Sorokin 2021-05-10 20:43:44 -05:00 committed by GitHub
parent 2ff36fa47b
commit a67fe57e56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -12,7 +12,7 @@ Object {
"width": 1, "width": 1,
}, },
"labelFont": "12px \\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", "labelFont": "12px \\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif",
"scale": "time", "scale": "x",
"show": true, "show": true,
"side": 2, "side": 2,
"size": [Function], "size": [Function],
@ -89,7 +89,7 @@ Object {
[Function], [Function],
], ],
"scales": Array [ "scales": Array [
"time", "x",
"__fixed", "__fixed",
], ],
}, },
@ -105,7 +105,7 @@ Object {
"range": [Function], "range": [Function],
"time": undefined, "time": undefined,
}, },
"time": Object { "x": Object {
"auto": false, "auto": false,
"dir": 1, "dir": 1,
"ori": 0, "ori": 0,

View File

@ -48,11 +48,12 @@ export const preparePlotConfigBuilder: PrepConfig = ({ frame, theme, timeZone, g
let seriesIndex = 0; let seriesIndex = 0;
let xScaleKey = '_x'; const xScaleKey = 'x';
let xScaleUnit = '_x';
let yScaleKey = ''; let yScaleKey = '';
if (xField.type === FieldType.time) { if (xField.type === FieldType.time) {
xScaleKey = 'time'; xScaleUnit = 'time';
builder.addScale({ builder.addScale({
scaleKey: xScaleKey, scaleKey: xScaleKey,
orientation: ScaleOrientation.Horizontal, orientation: ScaleOrientation.Horizontal,
@ -74,7 +75,7 @@ export const preparePlotConfigBuilder: PrepConfig = ({ frame, theme, timeZone, g
} else { } else {
// Not time! // Not time!
if (xField.config.unit) { if (xField.config.unit) {
xScaleKey = xField.config.unit; xScaleUnit = xField.config.unit;
} }
builder.addScale({ builder.addScale({
@ -231,12 +232,12 @@ export const preparePlotConfigBuilder: PrepConfig = ({ frame, theme, timeZone, g
pub: (type: string, src: uPlot, x: number, y: number, w: number, h: number, dataIdx: number) => { pub: (type: string, src: uPlot, x: number, y: number, w: number, h: number, dataIdx: number) => {
payload.columnIndex = dataIdx; payload.columnIndex = dataIdx;
if (x < 0 && y < 0) { if (x < 0 && y < 0) {
payload.point[xScaleKey] = null; payload.point[xScaleUnit] = null;
payload.point[yScaleKey] = null; payload.point[yScaleKey] = null;
eventBus.publish(new DataHoverClearEvent(payload)); eventBus.publish(new DataHoverClearEvent(payload));
} else { } else {
// convert the points // convert the points
payload.point[xScaleKey] = src.posToVal(x, xScaleKey); payload.point[xScaleUnit] = src.posToVal(x, xScaleKey);
payload.point[yScaleKey] = src.posToVal(y, yScaleKey); payload.point[yScaleKey] = src.posToVal(y, yScaleKey);
eventBus.publish(hoverEvent); eventBus.publish(hoverEvent);
hoverEvent.payload.down = undefined; hoverEvent.payload.down = undefined;