|
|
@ -1,5 +1,5 @@ |
|
|
|
import { ChartwerkPod, VueChartwerkPodMixin, TimeFormat, CrosshairOrientation, BrushOrientation, yAxisOrientation } from '@chartwerk/core'; |
|
|
|
import { ChartwerkPod, VueChartwerkPodMixin, TimeFormat, CrosshairOrientation, BrushOrientation, yAxisOrientation } from '@chartwerk/core'; |
|
|
|
import { LineTimeSerie, LineOptions } from './types'; |
|
|
|
import { LineTimeSerie, LineOptions, MouseObj } from './types'; |
|
|
|
import { Markers } from './components/markers'; |
|
|
|
import { Markers } from './components/markers'; |
|
|
|
import { Segments } from './components/segments'; |
|
|
|
import { Segments } from './components/segments'; |
|
|
|
|
|
|
|
|
|
|
@ -290,18 +290,17 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
|
|
|
return _.max(intervals); |
|
|
|
return _.max(intervals); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMouseMove(): void { |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
// TDOO: is shift key pressed
|
|
|
|
// TODO: is shift key pressed
|
|
|
|
// TODO: need to refactor this object
|
|
|
|
// TODO: need to refactor this object
|
|
|
|
this.options.callbackMouseMove({ |
|
|
|
return { |
|
|
|
x: d3.event.pageX, |
|
|
|
x: d3.event.pageX, |
|
|
|
y: d3.event.pageY, |
|
|
|
y: d3.event.pageY, |
|
|
|
xVal: xValue, |
|
|
|
xVal: xValue, |
|
|
@ -309,7 +308,21 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
|
|
|
series: datapoints, |
|
|
|
series: datapoints, |
|
|
|
chartX: eventX, |
|
|
|
chartX: eventX, |
|
|
|
chartWidth: this.width |
|
|
|
chartWidth: this.width |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override onMouseMove(): void { |
|
|
|
|
|
|
|
const obj = this.getMouseObj(); |
|
|
|
|
|
|
|
this.moveCrosshairLine(obj.x, obj.y); |
|
|
|
|
|
|
|
// TODO: is shift key pressed
|
|
|
|
|
|
|
|
// TODO: need to refactor this object
|
|
|
|
|
|
|
|
this.options.callbackMouseMove(obj); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: add override
|
|
|
|
|
|
|
|
onMouseClick(): void { |
|
|
|
|
|
|
|
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 }[] { |
|
|
@ -341,14 +354,14 @@ class LinePod extends ChartwerkPod<LineTimeSerie, LineOptions> { |
|
|
|
return points; |
|
|
|
return points; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMouseOver(): void { |
|
|
|
override onMouseOver(): void { |
|
|
|
this.onMouseMove(); |
|
|
|
this.onMouseMove(); |
|
|
|
this.crosshair.style('display', null); |
|
|
|
this.crosshair.style('display', null); |
|
|
|
this.crosshair.selectAll('.crosshair-circle') |
|
|
|
this.crosshair.selectAll('.crosshair-circle') |
|
|
|
.style('display', null); |
|
|
|
.style('display', null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMouseOut(): void { |
|
|
|
override onMouseOut(): void { |
|
|
|
this.options.callbackMouseOut(); |
|
|
|
this.options.callbackMouseOut(); |
|
|
|
this.crosshair.style('display', 'none'); |
|
|
|
this.crosshair.style('display', 'none'); |
|
|
|
} |
|
|
|
} |
|
|
|