-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(interaction.tooltip): add crosshairs, crosshairsX, crosshairsY s…
…etting (#6229) * fix: loca bugs * feat: finish crosshairx crosshairsy features * feat: finish features develop * fix: fix test error * fix: fix test error * fix: remove unused code * fix: fix ci error * fix: flatting configure * fix: change remove judge * fix: crosshairsX default is close
- Loading branch information
Showing
14 changed files
with
1,651 additions
and
26 deletions.
There are no files selected for viewing
428 changes: 428 additions & 0 deletions
428
...__/integration/snapshots/interaction/change-size-polar-crosshairs-x-y/step0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
428 changes: 428 additions & 0 deletions
428
...__/integration/snapshots/interaction/change-size-polar-crosshairs-x-y/step1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
212 changes: 212 additions & 0 deletions
212
__tests__/integration/snapshots/interaction/indices-line-crosshairs-x-y/step0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
212 changes: 212 additions & 0 deletions
212
__tests__/integration/snapshots/interaction/indices-line-crosshairs-x-y/step1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 107 additions & 0 deletions
107
__tests__/plots/interaction/change-size-polar-crosshairs-xy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { G2Spec, PLOT_CLASS_NAME } from '../../../src'; | ||
import { step } from './utils'; | ||
|
||
export async function changeSizePolarCrosshairsXY(): Promise<G2Spec> { | ||
const data = [ | ||
{ item: 'Design', type: 'a', score: 70 }, | ||
{ item: 'Design', type: 'b', score: 30 }, | ||
{ item: 'Development', type: 'a', score: 60 }, | ||
{ item: 'Development', type: 'b', score: 70 }, | ||
{ item: 'Marketing', type: 'a', score: 50 }, | ||
{ item: 'Marketing', type: 'b', score: 60 }, | ||
{ item: 'Users', type: 'a', score: 40 }, | ||
{ item: 'Users', type: 'b', score: 50 }, | ||
{ item: 'Test', type: 'a', score: 60 }, | ||
{ item: 'Test', type: 'b', score: 70 }, | ||
{ item: 'Language', type: 'a', score: 70 }, | ||
{ item: 'Language', type: 'b', score: 50 }, | ||
{ item: 'Technology', type: 'a', score: 50 }, | ||
{ item: 'Technology', type: 'b', score: 40 }, | ||
{ item: 'Support', type: 'a', score: 30 }, | ||
{ item: 'Support', type: 'b', score: 40 }, | ||
{ item: 'Sales', type: 'a', score: 60 }, | ||
{ item: 'Sales', type: 'b', score: 40 }, | ||
{ item: 'UX', type: 'a', score: 50 }, | ||
{ item: 'UX', type: 'b', score: 60 }, | ||
]; | ||
|
||
return { | ||
type: 'view', | ||
coordinate: { | ||
type: 'polar', | ||
}, | ||
scale: { | ||
x: { padding: 0.5, align: 0 }, | ||
y: { tickCount: 5, domainMax: 80 }, | ||
}, | ||
autoFit: true, | ||
data, | ||
interaction: { | ||
legendFilter: false, | ||
elementPointMove: true, | ||
tooltip: { | ||
crosshairs: true, | ||
crosshairsStroke: 'red', | ||
crosshairsLineDash: [4, 4], | ||
}, | ||
}, | ||
axis: { | ||
x: { | ||
grid: true, | ||
gridStrokeWidth: 1, | ||
tick: false, | ||
gridLineDash: [0, 0], | ||
}, | ||
y: { | ||
zIndex: 1, | ||
title: false, | ||
gridConnect: 'line', | ||
gridStrokeWidth: 1, | ||
gridLineDash: [0, 0], | ||
}, | ||
}, | ||
children: [ | ||
{ | ||
type: 'area', | ||
encode: { | ||
x: 'item', | ||
y: 'score', | ||
color: 'type', | ||
key: 'type', | ||
}, | ||
style: { | ||
fillOpacity: 0.5, | ||
}, | ||
}, | ||
{ | ||
type: 'line', | ||
encode: { | ||
x: 'item', | ||
y: 'score', | ||
color: 'type', | ||
key: 'type', | ||
}, | ||
style: { | ||
lineWidth: 2, | ||
}, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
changeSizePolarCrosshairsXY.tooltip = true; | ||
|
||
changeSizePolarCrosshairsXY.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const [plot] = document.getElementsByClassName(PLOT_CLASS_NAME); | ||
return [ | ||
step(plot, 'pointermove', { | ||
offsetX: 100, | ||
offsetY: 350, | ||
}), | ||
step(plot, 'pointermove', { | ||
offsetX: 176, | ||
offsetY: 350, | ||
}), | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { csv } from 'd3-fetch'; | ||
import { autoType } from 'd3-dsv'; | ||
import { G2Spec, PLOT_CLASS_NAME } from '../../../src'; | ||
import { step } from './utils'; | ||
|
||
export async function indicesLineCrosshairsXY(): Promise<G2Spec> { | ||
const data = await csv('data/indices.csv', autoType); | ||
return { | ||
type: 'view', | ||
children: [ | ||
{ | ||
type: 'line', | ||
data, | ||
axis: { | ||
y: { labelAutoRotate: false }, | ||
}, | ||
transform: [{ type: 'normalizeY', basis: 'first', groupBy: 'color' }], | ||
legend: false, | ||
encode: { | ||
x: 'Date', | ||
y: 'Close', | ||
color: 'Symbol', | ||
key: 'Symbol', | ||
}, | ||
state: { | ||
active: { stroke: 'red' }, | ||
}, | ||
}, | ||
], | ||
interaction: { | ||
tooltip: { | ||
crosshairs: true, | ||
crosshairsXStroke: 'red', | ||
crosshairsYStroke: 'blue', | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
indicesLineCrosshairsXY.tooltip = true; | ||
|
||
indicesLineCrosshairsXY.steps = ({ canvas }) => { | ||
const { document } = canvas; | ||
const [plot] = document.getElementsByClassName(PLOT_CLASS_NAME); | ||
return [ | ||
step(plot, 'pointermove', { | ||
offsetX: 100, | ||
offsetY: 350, | ||
}), | ||
step(plot, 'pointermove', { | ||
offsetX: 176, | ||
offsetY: 350, | ||
}), | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.