|
|
|
@ -10,7 +10,7 @@ import { setBarScaleY, setBarScaleX } from './models/bar_state';
|
|
|
|
|
import { |
|
|
|
|
BarSerie, BarOptions, DiscreteConfig, NonDiscreteConfig, |
|
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
|
ColorFormatter, OpacityFormatter, |
|
|
|
|
BarData, ColorFormatter, OpacityFormatter, |
|
|
|
|
Datapoint, ValueX, ValueY, |
|
|
|
|
} from './types'; |
|
|
|
|
|
|
|
|
@ -108,9 +108,19 @@ export class ChartwerkBarPod extends ChartwerkPod<BarSerie, BarOptions> {
|
|
|
|
|
if(!this.series.isSeriesAvailable) { |
|
|
|
|
return undefined; |
|
|
|
|
} |
|
|
|
|
const mousePoisitionKey = Math.ceil(this.state.xScale.invert(eventX)); |
|
|
|
|
const mousePositionKey = this.state.xScale.invert(eventX); |
|
|
|
|
const keys = _.map(this.dataProcessor.dataRows, (dataRow: DataRow) => dataRow.key); |
|
|
|
|
const idx = findClosest(keys, mousePoisitionKey); |
|
|
|
|
let idx: number; |
|
|
|
|
switch(this.options.barType) { |
|
|
|
|
case BarPodType.DISCRETE: |
|
|
|
|
idx = Math.floor(mousePositionKey); |
|
|
|
|
break; |
|
|
|
|
case BarPodType.NON_DISCRETE: |
|
|
|
|
idx = findClosest(keys, mousePositionKey); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return this.dataProcessor.dataRows[idx]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -152,6 +162,6 @@ export {
|
|
|
|
|
BarSerie, BarOptions, TimeFormat, AxisFormat, |
|
|
|
|
DiscreteConfig, NonDiscreteConfig, |
|
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
|
ColorFormatter, OpacityFormatter, |
|
|
|
|
BarData, ColorFormatter, OpacityFormatter, |
|
|
|
|
Datapoint, ValueX, ValueY, DataItem, DataRow, |
|
|
|
|
}; |
|
|
|
|