import React from 'react'; import * as shape from 'd3-shape'; import { View } from 'react-native'; import { LineChart, XAxis, YAxis } from 'react-native-svg-charts'; import { useGraphData } from '../use-graph-data'; import { CustomGrid } from '../custom-grid'; import { graphStyles } from '../chart-styles'; import ChartView from '../chart-view'; import { CommonProps } from '../graph-types'; // TODO: separate PR will update useGraphData to take into account useCommonScale // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars const LineGraph: React.FC = ({ data, useCommonScale = false, testID, ...props }) => { if (!data || typeof data !== 'object') { return null }; // TODO:#38 const { xValues, yData, yAxisLeftLabels, yAxisRightLabels, defaultProps: { height, contentInset, min, numberOfTicks, lineStrokeWidth, yAxisProps: { maxLeftYAxisValue, maxRightYAxisValue, formatLeftYAxisLabel, formatRightYAxisLabel } } // Proper error/loading handling from useQueryHandler can work with this rule #38 // eslint-disable-next-line react-hooks/rules-of-hooks } = useGraphData(data, props); return ( (item as unknown as { value: number }).value} xAccessor={({ index }) => xValues[index] as number} gridMin={min} contentInset={contentInset} numberOfTicks={numberOfTicks} > index)} // TODO: update when useGraphHook returns explicit display values style={[graphStyles.xAxisMarginTop]} svg={graphStyles.xAxisFontStyle} numberOfTicks={numberOfTicks} contentInset={graphStyles.horizontalInset} /> ); }; export default LineGraph;