MCPcopy Index your code
hub / github.com/tinyplex/tinybase / useSeriesData

Function useSeriesData

src/ui-react-dom-charts/components/series.ts:18–109  ·  view source on GitHub ↗
({
  descending,
  limit,
  offset,
  sortCellId,
  xCellId,
  yCellId,
}: SeriesProps)

Source from the content-addressed store, hash-verified

16import type {DataPoint} from '../common/types.ts';
17
18export const useSeriesData = ({
19 descending,
20 limit,
21 offset,
22 sortCellId,
23 xCellId,
24 yCellId,
25}: SeriesProps): readonly [Id, DataPoint[]] => {
26 const [, rerender] = useState<[]>();
27 const context = useCartesianChartContext();
28 const {
29 getSeriesId,
30 queries,
31 queriesOrQueriesId,
32 queryId,
33 releaseSeriesId,
34 sourceType,
35 store,
36 storeOrStoreId,
37 tableId,
38 } = context;
39 const [seriesId] = useState(getSeriesId);
40 const handleChange = useCallback(() => rerender([]), [rerender]);
41 const tableRowIds = useSortedRowIds(
42 tableId ?? EMPTY_STRING,
43 sortCellId ?? xCellId,
44 descending,
45 offset,
46 limit,
47 storeOrStoreId,
48 );
49 const queryRowIds = useResultSortedRowIds(
50 queryId ?? EMPTY_STRING,
51 sortCellId ?? xCellId,
52 descending,
53 offset,
54 limit,
55 queriesOrQueriesId,
56 );
57 const rowIds = sourceType == SourceType.Table ? tableRowIds : queryRowIds;
58 const points = isNullish(yCellId)
59 ? []
60 : getDataPoints(rowIds, (rowId) =>
61 getDataPoint(
62 rowId,
63 getCell(sourceType, store, queries, tableId, queryId, rowId, xCellId),
64 getCell(sourceType, store, queries, tableId, queryId, rowId, yCellId),
65 ),
66 );
67
68 useCellListener(
69 sourceType == SourceType.Table ? (tableId ?? null) : null,
70 null,
71 xCellId,
72 handleChange,
73 [handleChange],
74 false,
75 storeOrStoreId,

Callers 2

LineSeries.tsxFile · 0.90
BarSeries.tsxFile · 0.90

Calls 9

useCartesianChartContextFunction · 0.90
useSortedRowIdsFunction · 0.90
useResultSortedRowIdsFunction · 0.90
isNullishFunction · 0.90
getDataPointsFunction · 0.90
getDataPointFunction · 0.90
useCellListenerFunction · 0.90
useResultCellListenerFunction · 0.90
getCellFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…