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

View File

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