|
|
@ -291,10 +291,12 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getMouseObj(): MouseObj { |
|
|
|
getMouseObj(): MouseObj { |
|
|
|
|
|
|
|
|
|
|
|
const eventX = d3.mouse(this.chartContainer.node())[0]; |
|
|
|
const eventX = d3.mouse(this.chartContainer.node())[0]; |
|
|
|
const eventY = d3.mouse(this.chartContainer.node())[1]; |
|
|
|
const eventY = d3.mouse(this.chartContainer.node())[1]; |
|
|
|
const xValue = this.state.xScale.invert(eventX); // mouse x position in xScale
|
|
|
|
const xValue = this.state.xScale.invert(eventX); // mouse x position in xScale
|
|
|
|
const yValue = this.state.yScale.invert(eventY); |
|
|
|
const yValue = this.state.yScale.invert(eventY); |
|
|
|
|
|
|
|
this.moveCrosshairLine(eventX, eventY); |
|
|
|
|
|
|
|
|
|
|
|
const datapoints = this.findAndHighlightDatapoints(xValue, yValue); |
|
|
|
const datapoints = this.findAndHighlightDatapoints(xValue, yValue); |
|
|
|
|
|
|
|
|
|
|
@ -309,20 +311,21 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
|
|
|
chartX: eventX, |
|
|
|
chartX: eventX, |
|
|
|
chartWidth: this.width |
|
|
|
chartWidth: this.width |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override onMouseMove(): void { |
|
|
|
override onMouseMove(): void { |
|
|
|
const obj = this.getMouseObj(); |
|
|
|
const obj = this.getMouseObj(); |
|
|
|
this.moveCrosshairLine(obj.x, obj.y); |
|
|
|
const eventX = d3.mouse(this.chartContainer.node())[0]; |
|
|
|
|
|
|
|
const eventY = d3.mouse(this.chartContainer.node())[1]; |
|
|
|
|
|
|
|
this.moveCrosshairLine(eventX, eventY); |
|
|
|
// TODO: is shift key pressed
|
|
|
|
// TODO: is shift key pressed
|
|
|
|
// TODO: need to refactor this object
|
|
|
|
// TODO: need to refactor this object
|
|
|
|
this.options.callbackMouseMove(obj); |
|
|
|
this.options.callbackMouseMove(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: add override
|
|
|
|
override onMouseClick(): void { |
|
|
|
onMouseClick(): void { |
|
|
|
this.options.callbackMouseClick(this.getMouseObj()); |
|
|
|
const obj = this.getMouseObj(); |
|
|
|
|
|
|
|
console.log(obj); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
findAndHighlightDatapoints(xValue: number, yValue: number): { value: [number, number], color: string, label: string }[] { |
|
|
|
findAndHighlightDatapoints(xValue: number, yValue: number): { value: [number, number], color: string, label: string }[] { |
|
|
|