react-native-chart-kit
Version:
Beautiful React Native charts for dashboards, reports, and data-rich mobile apps.
27 lines (26 loc) • 933 B
JavaScript
import { getLineChartActiveDotConfig } from "./options";
export const getSelectedLineSeries = ({ activeDot, formatYLabel, geometries, selectedDataIndex }) => {
if (selectedDataIndex === undefined) {
return [];
}
return geometries.flatMap(({ geometry, style }) => {
const point = geometry.points.find((item) => item.dataIndex === selectedDataIndex);
if (!point || !point.defined) {
return [];
}
return [
{
key: geometry.key,
label: geometry.label,
color: style.color,
value: point.value,
formattedValue: typeof point.value === "number" ? formatYLabel(point.value) : "—",
point,
activeDot: getLineChartActiveDotConfig({
activeDot,
baseDot: style.dot
})
}
];
});
};