|
|
@ -10,7 +10,7 @@ import { setBarScaleY, setBarScaleX } from './models/bar_state'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
BarSerie, BarOptions, DiscreteConfig, NonDiscreteConfig, |
|
|
|
BarSerie, BarOptions, DiscreteConfig, NonDiscreteConfig, |
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
ColorFormatter, OpacityFormatter, |
|
|
|
BarData, ColorFormatter, OpacityFormatter, |
|
|
|
Datapoint, ValueX, ValueY, |
|
|
|
Datapoint, ValueX, ValueY, |
|
|
|
} from './types'; |
|
|
|
} from './types'; |
|
|
|
|
|
|
|
|
|
|
@ -108,9 +108,19 @@ export class ChartwerkBarPod extends ChartwerkPod<BarSerie, BarOptions> { |
|
|
|
if(!this.series.isSeriesAvailable) { |
|
|
|
if(!this.series.isSeriesAvailable) { |
|
|
|
return undefined; |
|
|
|
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 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]; |
|
|
|
return this.dataProcessor.dataRows[idx]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -152,6 +162,6 @@ export { |
|
|
|
BarSerie, BarOptions, TimeFormat, AxisFormat, |
|
|
|
BarSerie, BarOptions, TimeFormat, AxisFormat, |
|
|
|
DiscreteConfig, NonDiscreteConfig, |
|
|
|
DiscreteConfig, NonDiscreteConfig, |
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
BarPodType, SizeType, CallbackEvent, Color, Opacity, |
|
|
|
ColorFormatter, OpacityFormatter, |
|
|
|
BarData, ColorFormatter, OpacityFormatter, |
|
|
|
Datapoint, ValueX, ValueY, DataItem, DataRow, |
|
|
|
Datapoint, ValueX, ValueY, DataItem, DataRow, |
|
|
|
}; |
|
|
|
}; |
|
|
|