@bashem/rn-charts 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/module/skia/AreaChart/AreaChart.js +60 -51
- package/lib/module/skia/AreaChart/AreaChart.js.map +1 -1
- package/lib/module/skia/AreaChart/useAreaChart.js +18 -14
- package/lib/module/skia/AreaChart/useAreaChart.js.map +1 -1
- package/lib/module/skia/BarChart/BarChart.js +156 -69
- package/lib/module/skia/BarChart/BarChart.js.map +1 -1
- package/lib/module/skia/BarChart/useBarChart.js +53 -41
- package/lib/module/skia/BarChart/useBarChart.js.map +1 -1
- package/lib/module/skia/Common/HorizontalLabelView.js +121 -0
- package/lib/module/skia/Common/HorizontalLabelView.js.map +1 -0
- package/lib/module/skia/Common/VerticalLabelView.js +100 -0
- package/lib/module/skia/Common/VerticalLabelView.js.map +1 -0
- package/lib/module/skia/Common/useComponentLayout.js +13 -0
- package/lib/module/skia/Common/useComponentLayout.js.map +1 -0
- package/lib/module/skia/HeatMap/DateHeatMap.js +472 -0
- package/lib/module/skia/HeatMap/DateHeatMap.js.map +1 -0
- package/lib/module/skia/HeatMap/HeatMap.js +121 -33
- package/lib/module/skia/HeatMap/HeatMap.js.map +1 -1
- package/lib/module/skia/HeatMap/useHeatMap.js +132 -48
- package/lib/module/skia/HeatMap/useHeatMap.js.map +1 -1
- package/lib/module/skia/PieChart/PieChart.js +21 -17
- package/lib/module/skia/PieChart/PieChart.js.map +1 -1
- package/lib/module/skia/PieChart/usePieChart.js +241 -30
- package/lib/module/skia/PieChart/usePieChart.js.map +1 -1
- package/lib/module/skia/Popup.js +7 -5
- package/lib/module/skia/Popup.js.map +1 -1
- package/lib/module/skia/common.js +4 -41
- package/lib/module/skia/common.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts +15 -3
- package/lib/typescript/src/skia/AreaChart/AreaChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts +13 -14
- package/lib/typescript/src/skia/AreaChart/useAreaChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts +16 -2
- package/lib/typescript/src/skia/BarChart/BarChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts +17 -5
- package/lib/typescript/src/skia/BarChart/useBarChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/Common/HorizontalLabelView.d.ts +33 -0
- package/lib/typescript/src/skia/Common/HorizontalLabelView.d.ts.map +1 -0
- package/lib/typescript/src/skia/Common/VerticalLabelView.d.ts +24 -0
- package/lib/typescript/src/skia/Common/VerticalLabelView.d.ts.map +1 -0
- package/lib/typescript/src/skia/Common/useComponentLayout.d.ts +4 -0
- package/lib/typescript/src/skia/Common/useComponentLayout.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/DateHeatMap.d.ts +1 -0
- package/lib/typescript/src/skia/HeatMap/DateHeatMap.d.ts.map +1 -0
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts +28 -12
- package/lib/typescript/src/skia/HeatMap/HeatMap.d.ts.map +1 -1
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts +15 -4
- package/lib/typescript/src/skia/HeatMap/useHeatMap.d.ts.map +1 -1
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts +5 -1
- package/lib/typescript/src/skia/PieChart/PieChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts +6 -1
- package/lib/typescript/src/skia/PieChart/usePieChart.d.ts.map +1 -1
- package/lib/typescript/src/skia/Popup.d.ts.map +1 -1
- package/lib/typescript/src/skia/common.d.ts +3 -10
- package/lib/typescript/src/skia/common.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/index.tsx +6 -4
- package/src/skia/AreaChart/AreaChart.tsx +85 -62
- package/src/skia/AreaChart/useAreaChart.ts +25 -26
- package/src/skia/BarChart/BarChart.tsx +163 -95
- package/src/skia/BarChart/useBarChart.ts +55 -44
- package/src/skia/Common/HorizontalLabelView.tsx +153 -0
- package/src/skia/Common/VerticalLabelView.tsx +113 -0
- package/src/skia/Common/useComponentLayout.ts +14 -0
- package/src/skia/HeatMap/DateHeatMap.tsx +470 -0
- package/src/skia/HeatMap/HeatMap.tsx +168 -54
- package/src/skia/HeatMap/useHeatMap.ts +139 -65
- package/src/skia/PieChart/PieChart.tsx +16 -11
- package/src/skia/PieChart/usePieChart.ts +316 -66
- package/src/skia/Popup.tsx +38 -36
- package/src/skia/common.ts +8 -46
- package/lib/module/skia/Common/VerticalLabel.js +0 -73
- package/lib/module/skia/Common/VerticalLabel.js.map +0 -1
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts +0 -17
- package/lib/typescript/src/skia/Common/VerticalLabel.d.ts.map +0 -1
- package/src/skia/Common/VerticalLabel.tsx +0 -91
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
// import type { View } from "react-native-reanimated/lib/typescript/Animated";
|
|
2
|
+
// import type { DayData, HeatMapProps } from "./HeatMap";
|
|
3
|
+
// import { useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
// import { getPaddings } from "../common";
|
|
5
|
+
|
|
6
|
+
// function useHeatMap({
|
|
7
|
+
// rows
|
|
8
|
+
// style,
|
|
9
|
+
// minValue,
|
|
10
|
+
// maxValue,
|
|
11
|
+
// ref,
|
|
12
|
+
// popupStyle
|
|
13
|
+
// }: HeatMapProps) {
|
|
14
|
+
|
|
15
|
+
// const cellSize = style?.cellSize ?? 24;
|
|
16
|
+
// const cellGap = style?.cellGap ?? 4;
|
|
17
|
+
// const cellMaxColor = style?.cellMaxColor ?? '#50f555ff';
|
|
18
|
+
// const cellMinColor = style?.cellMinColor ?? '#ffffffff';
|
|
19
|
+
|
|
20
|
+
// const [verticalLabelWidth, setVerticalLabelWidth] = useState<number>(0);
|
|
21
|
+
// const [horizontalLabelHeight, setHorizontalLabelHeight] = useState<number>(0);
|
|
22
|
+
// const {
|
|
23
|
+
// paddingLeft,
|
|
24
|
+
// paddingRight,
|
|
25
|
+
// paddingTop,
|
|
26
|
+
// paddingBottom
|
|
27
|
+
// } = getPaddings(style);
|
|
28
|
+
|
|
29
|
+
// const numberOfDaysInWeek = 7;
|
|
30
|
+
// const numberOfRows = rows;
|
|
31
|
+
// const numberOfMsInDay = 1000 * 60 * 60 * 24;
|
|
32
|
+
// const xLabels = useMemo(() => {
|
|
33
|
+
// return (data ?? []).map(())
|
|
34
|
+
// }, [data])
|
|
35
|
+
|
|
36
|
+
// const [popupData, setPopupData] = useState<
|
|
37
|
+
// { x: number; y: number; day: DayData; } | undefined
|
|
38
|
+
// >(undefined);
|
|
39
|
+
|
|
40
|
+
// const [popupDimension, setPopupDimension] = useState({
|
|
41
|
+
// width: 0,
|
|
42
|
+
// height: 0,
|
|
43
|
+
// });
|
|
44
|
+
|
|
45
|
+
// const popupRef = useRef<View>(null);
|
|
46
|
+
|
|
47
|
+
// const formatDate = (date: Date) =>
|
|
48
|
+
// `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
|
|
49
|
+
// 2,
|
|
50
|
+
// '0'
|
|
51
|
+
// )}-${String(date.getDate()).padStart(2, '0')}`;
|
|
52
|
+
|
|
53
|
+
// const { daysInRange, computedMin, computedMax } = useMemo(() => {
|
|
54
|
+
// const start = new Date(startDate);
|
|
55
|
+
// const end = new Date(endDate);
|
|
56
|
+
|
|
57
|
+
// const output: DayData[] = [];
|
|
58
|
+
// let computedMax = Number.MIN_VALUE;
|
|
59
|
+
// let computedMin = Number.MAX_VALUE;
|
|
60
|
+
|
|
61
|
+
// const startDayOfWeek = start.getDay();
|
|
62
|
+
|
|
63
|
+
// for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
|
|
64
|
+
// const dateStr = formatDate(d);
|
|
65
|
+
// const value = data?.[dateStr] ?? 0;
|
|
66
|
+
|
|
67
|
+
// const dayOfWeek = d.getDay();
|
|
68
|
+
// const daysFromStart = Math.floor(
|
|
69
|
+
// (d.getTime() - start.getTime()) / numberOfMsInDay
|
|
70
|
+
// );
|
|
71
|
+
|
|
72
|
+
// const week = Math.floor(
|
|
73
|
+
// (startDayOfWeek + daysFromStart) / numberOfDaysInWeek
|
|
74
|
+
// );
|
|
75
|
+
|
|
76
|
+
// computedMax = Math.max(computedMax, value);
|
|
77
|
+
// computedMin = Math.min(computedMin, value);
|
|
78
|
+
|
|
79
|
+
// output.push({
|
|
80
|
+
// date: dateStr,
|
|
81
|
+
// value,
|
|
82
|
+
// dayOfWeek,
|
|
83
|
+
// week,
|
|
84
|
+
// x: week * (cellSize + cellGap),
|
|
85
|
+
// y: dayOfWeek * (cellSize + cellGap),
|
|
86
|
+
// });
|
|
87
|
+
// }
|
|
88
|
+
|
|
89
|
+
// return {
|
|
90
|
+
// daysInRange: output,
|
|
91
|
+
// computedMin: minValue !== undefined ? minValue : computedMin,
|
|
92
|
+
// computedMax: maxValue !== undefined ? maxValue : computedMax,
|
|
93
|
+
// };
|
|
94
|
+
// }, [startDate, endDate, data, minValue, maxValue, cellSize, cellGap]);
|
|
95
|
+
|
|
96
|
+
// // --- COLOR LOGIC ---
|
|
97
|
+
// const getColor = (value: number) => {
|
|
98
|
+
// if (value <= 0) return cellMinColor;
|
|
99
|
+
|
|
100
|
+
// const intensity = Math.min(
|
|
101
|
+
// 1,
|
|
102
|
+
// Math.max(0, (value - computedMin) / (computedMax - computedMin || 1))
|
|
103
|
+
// );
|
|
104
|
+
|
|
105
|
+
// const bigint = parseInt(cellMaxColor.replace('#', ''), 16);
|
|
106
|
+
// const r = (bigint >> 16) & 255;
|
|
107
|
+
// const g = (bigint >> 8) & 255;
|
|
108
|
+
// const b = bigint & 255;
|
|
109
|
+
|
|
110
|
+
// const mix = (base: number) => Math.round(255 - (255 - base) * intensity);
|
|
111
|
+
|
|
112
|
+
// return `rgb(${mix(r)}, ${mix(g)}, ${mix(b)})`;
|
|
113
|
+
// };
|
|
114
|
+
|
|
115
|
+
// // Heatmap size
|
|
116
|
+
// const numWeeks = Math.ceil(daysInRange.length / 7 + 1);
|
|
117
|
+
// const totalWidth = numWeeks * (cellSize + cellGap) + verticalLabelWidth;
|
|
118
|
+
// const totalHeight = 7 * (cellSize + cellGap);
|
|
119
|
+
|
|
120
|
+
// // --- POPUP MEASUREMENT ---
|
|
121
|
+
// useLayoutEffect(() => {
|
|
122
|
+
// if (popupRef.current) {
|
|
123
|
+
// popupRef.current.measure((x, y, width, height) => {
|
|
124
|
+
// setPopupDimension({ width, height });
|
|
125
|
+
// });
|
|
126
|
+
// }
|
|
127
|
+
// }, [popupData]);
|
|
128
|
+
|
|
129
|
+
// // --- TOUCH HANDLER ---
|
|
130
|
+
// const touchHandler = (x: number, y: number) => {
|
|
131
|
+
// if (!popupStyle?.renderPopup || (x < 0 || y < 0 || x >= totalWidth || y >= totalHeight)) {
|
|
132
|
+
// setPopupData(undefined);
|
|
133
|
+
// return;
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
// const col = Math.floor(x / (cellSize + cellGap));
|
|
137
|
+
// const row = Math.floor(y / (cellSize + cellGap));
|
|
138
|
+
|
|
139
|
+
// const start = new Date(startDate);
|
|
140
|
+
// const startDayOfWeek = start.getDay();
|
|
141
|
+
|
|
142
|
+
// const index = col * numberOfDaysInWeek + row;
|
|
143
|
+
|
|
144
|
+
// if (
|
|
145
|
+
// index >= startDayOfWeek &&
|
|
146
|
+
// index - startDayOfWeek < daysInRange.length
|
|
147
|
+
// ) {
|
|
148
|
+
// const day = daysInRange[index - startDayOfWeek];
|
|
149
|
+
// if (day) {
|
|
150
|
+
// setPopupData({
|
|
151
|
+
// x: col * (cellSize + cellGap),
|
|
152
|
+
// y: row * (cellSize + cellGap),
|
|
153
|
+
// day,
|
|
154
|
+
// });
|
|
155
|
+
// return;
|
|
156
|
+
// }
|
|
157
|
+
// }
|
|
158
|
+
|
|
159
|
+
// setPopupData(undefined);
|
|
160
|
+
// };
|
|
161
|
+
// const onTouchOutside = () => {
|
|
162
|
+
// setPopupData(undefined);
|
|
163
|
+
// };
|
|
164
|
+
|
|
165
|
+
// useImperativeHandle(ref, () => ({
|
|
166
|
+
// touchedOutside: () => {
|
|
167
|
+
// setPopupData(undefined);
|
|
168
|
+
// }
|
|
169
|
+
// }), [ref]);
|
|
170
|
+
|
|
171
|
+
// return {
|
|
172
|
+
// daysInRange,
|
|
173
|
+
// computedMin,
|
|
174
|
+
// computedMax,
|
|
175
|
+
// totalWidth,
|
|
176
|
+
// totalHeight,
|
|
177
|
+
// popupData,
|
|
178
|
+
// popupRef,
|
|
179
|
+
// popupDimension,
|
|
180
|
+
// touchHandler,
|
|
181
|
+
// getColor,
|
|
182
|
+
// cellSize,
|
|
183
|
+
// onTouchOutside,
|
|
184
|
+
// verticalLabelWidth,
|
|
185
|
+
// setVerticalLabelWidth,
|
|
186
|
+
// horizontalLabelHeight,
|
|
187
|
+
// setHorizontalLabelHeight,
|
|
188
|
+
// numberOfRows,
|
|
189
|
+
// paddingLeft,
|
|
190
|
+
// paddingRight,
|
|
191
|
+
// paddingTop,
|
|
192
|
+
// paddingBottom
|
|
193
|
+
// };
|
|
194
|
+
// }
|
|
195
|
+
|
|
196
|
+
// export default useHeatMap;
|
|
197
|
+
|
|
198
|
+
// import React, { type Ref } from 'react';
|
|
199
|
+
// import { View } from 'react-native';
|
|
200
|
+
// import { Canvas, Group, Rect, rect, type SkHostRect } from '@shopify/react-native-skia';
|
|
201
|
+
// import useHeatMap from './useHeatMap';
|
|
202
|
+
// import type { CommonStyle, HandleOutSideTouch } from '../common';
|
|
203
|
+
// import Popup, { type PopupStyle } from '../Popup';
|
|
204
|
+
// import VerticalLabelView, { type VerticalLabelStyle } from "../Common/VerticalLabelView";
|
|
205
|
+
// import HorizontalLabelView, { type HorizontalLabelStyleExtended } from "../Common/HorizontalLabelView";
|
|
206
|
+
|
|
207
|
+
// export type DayData = {
|
|
208
|
+
// date: string;
|
|
209
|
+
// value: number;
|
|
210
|
+
// dayOfWeek: number;
|
|
211
|
+
// week: number;
|
|
212
|
+
// x: number;
|
|
213
|
+
// y: number;
|
|
214
|
+
// };
|
|
215
|
+
|
|
216
|
+
// export interface HeatMapDataGroup {
|
|
217
|
+
// cols: number;
|
|
218
|
+
// data?: Record<string, number>;
|
|
219
|
+
// }
|
|
220
|
+
|
|
221
|
+
// export interface HeatMapStyle extends CommonStyle, VerticalLabelStyle {
|
|
222
|
+
// cellSize?: number;
|
|
223
|
+
// cellGap?: number;
|
|
224
|
+
// cellMaxColor?: string;
|
|
225
|
+
// cellMinColor?: string;
|
|
226
|
+
// horizontalLabelStyle?: HorizontalLabelStyleExtended;
|
|
227
|
+
// verticalLabelStyle?: VerticalLabelStyle;
|
|
228
|
+
// interGroupSpacing?: number;
|
|
229
|
+
// }
|
|
230
|
+
|
|
231
|
+
// export interface HeatMapProps {
|
|
232
|
+
// rows: number;
|
|
233
|
+
// data: HeatMapDataGroup[];
|
|
234
|
+
// // InterGroupSpacing is only applied when coalesceGroups is false
|
|
235
|
+
// coalesceGroups: boolean;
|
|
236
|
+
// style?: HeatMapStyle;
|
|
237
|
+
// minValue?: number;
|
|
238
|
+
// maxValue?: number;
|
|
239
|
+
// xLabelSkiaView?: (
|
|
240
|
+
// label: string,
|
|
241
|
+
// position: { x: number; y: number; }
|
|
242
|
+
// ) => React.JSX.Element | undefined;
|
|
243
|
+
// yLabelSkiaView?: (
|
|
244
|
+
// index: number,
|
|
245
|
+
// yPosition: number
|
|
246
|
+
// ) => React.JSX.Element | undefined;
|
|
247
|
+
|
|
248
|
+
// xLabelView?: (
|
|
249
|
+
// label: string
|
|
250
|
+
// ) => React.JSX.Element | undefined;
|
|
251
|
+
// yLabelView?: (
|
|
252
|
+
// index: number
|
|
253
|
+
// ) => React.JSX.Element | undefined;
|
|
254
|
+
|
|
255
|
+
// daySkiaView?: (
|
|
256
|
+
// rect: SkHostRect,
|
|
257
|
+
// day: DayData
|
|
258
|
+
// ) => React.JSX.Element | undefined;
|
|
259
|
+
|
|
260
|
+
// onSelectSkiaView?: (
|
|
261
|
+
// rect: SkHostRect,
|
|
262
|
+
// day: DayData
|
|
263
|
+
// ) => React.JSX.Element | undefined;
|
|
264
|
+
// onSelectView?: (
|
|
265
|
+
// rect: SkHostRect,
|
|
266
|
+
// day: DayData
|
|
267
|
+
// ) => React.JSX.Element | undefined;
|
|
268
|
+
// ref?: Ref<HandleOutSideTouch | undefined>;
|
|
269
|
+
// popupStyle?: PopupStyle<DayData>;
|
|
270
|
+
// }
|
|
271
|
+
|
|
272
|
+
// function HeatMap({ yLabelView, yLabelSkiaView, xLabelView, xLabelSkiaView, daySkiaView, onSelectView, onSelectSkiaView, ...props }: HeatMapProps) {
|
|
273
|
+
// const {
|
|
274
|
+
// daysInRange,
|
|
275
|
+
// totalWidth,
|
|
276
|
+
// totalHeight,
|
|
277
|
+
// popupData,
|
|
278
|
+
// popupRef,
|
|
279
|
+
// popupDimension,
|
|
280
|
+
// touchHandler,
|
|
281
|
+
// getColor,
|
|
282
|
+
// cellSize,
|
|
283
|
+
// onTouchOutside,
|
|
284
|
+
// horizontalLabelHeight,
|
|
285
|
+
// verticalLabelWidth,
|
|
286
|
+
// setHorizontalLabelHeight,
|
|
287
|
+
// setVerticalLabelWidth,
|
|
288
|
+
// numberOfRows,
|
|
289
|
+
// paddingTop,
|
|
290
|
+
// paddingBottom,
|
|
291
|
+
// paddingLeft,
|
|
292
|
+
// paddingRight
|
|
293
|
+
// } = useHeatMap(props);
|
|
294
|
+
|
|
295
|
+
// const [viewOffset, setViewOffset] = React.useState({ x: 0, y: 0 });
|
|
296
|
+
// const onSelectSkiaViewMemo = React.useMemo(() => {
|
|
297
|
+
// if (!popupData || !onSelectSkiaView) {
|
|
298
|
+
// return undefined;
|
|
299
|
+
// }
|
|
300
|
+
// return onSelectSkiaView?.(rect(popupData.x, popupData.y, cellSize, cellSize), popupData.day);
|
|
301
|
+
// }, [popupData, onSelectSkiaView, cellSize]);
|
|
302
|
+
|
|
303
|
+
// const onSelectViewMemo = React.useMemo(() => {
|
|
304
|
+
// if (!popupData || !onSelectView) {
|
|
305
|
+
// return undefined;
|
|
306
|
+
// }
|
|
307
|
+
// return onSelectView(rect(popupData.x, popupData.y, cellSize, cellSize), popupData.day);
|
|
308
|
+
// }, [popupData, onSelectView, cellSize]);
|
|
309
|
+
|
|
310
|
+
// return <View
|
|
311
|
+
// style={{ backgroundColor: props.style?.backgroundColor }}
|
|
312
|
+
// ref={(view) => {
|
|
313
|
+
// view?.measureInWindow((fx, fy) => {
|
|
314
|
+
// setViewOffset((prev) => {
|
|
315
|
+
// if (prev.x === fx && prev.y === fy) {
|
|
316
|
+
// return prev;
|
|
317
|
+
// }
|
|
318
|
+
// return { x: fx, y: fy };
|
|
319
|
+
// });
|
|
320
|
+
// });
|
|
321
|
+
// }}
|
|
322
|
+
// >
|
|
323
|
+
// <View style={{ flexDirection: "row" }}>
|
|
324
|
+
// {
|
|
325
|
+
// (yLabelView || yLabelSkiaView) && (<VerticalLabelView
|
|
326
|
+
// onLayout={(event) => {
|
|
327
|
+
// setVerticalLabelWidth(event.nativeEvent.layout.width);
|
|
328
|
+
// }}
|
|
329
|
+
// labelPercentages={Array.from({ length: numberOfRows }, (_, i) => (i + 1) / numberOfRows)}
|
|
330
|
+
// styles={{
|
|
331
|
+
// height: totalHeight,
|
|
332
|
+
// verticalLabelStyle: props.style?.verticalLabelStyle,
|
|
333
|
+
// }}
|
|
334
|
+
// labelSkiaView={(_percentage, yPosition, index) => yLabelSkiaView?.(index, yPosition)}
|
|
335
|
+
// >
|
|
336
|
+
// {(_percentage, index) => yLabelView?.(index)}
|
|
337
|
+
// </VerticalLabelView>)
|
|
338
|
+
// }
|
|
339
|
+
// <View style={{ width: totalWidth, height: totalHeight }}>
|
|
340
|
+
// {
|
|
341
|
+
// (xLabelView || xLabelSkiaView) &&
|
|
342
|
+
// <HorizontalLabelView
|
|
343
|
+
// labels={}
|
|
344
|
+
// positions={xLabelsData.map(labelData => labelData.xPosition)}
|
|
345
|
+
// style={{
|
|
346
|
+
// width: totalWidth,
|
|
347
|
+
// height: props.style?.x ?? 0
|
|
348
|
+
// }}
|
|
349
|
+
// onLayout={(event) => setHorizontalLabelHeight(event.nativeEvent.layout.height)}
|
|
350
|
+
// >
|
|
351
|
+
// {label => xLabelView(label)}
|
|
352
|
+
// </HorizontalLabelView>
|
|
353
|
+
// }
|
|
354
|
+
// <Canvas
|
|
355
|
+
// style={{ width: totalWidth, height: totalHeight }}
|
|
356
|
+
// onTouchStart={(event) =>
|
|
357
|
+
// touchHandler(event.nativeEvent.locationX, event.nativeEvent.locationY)
|
|
358
|
+
// }
|
|
359
|
+
// >
|
|
360
|
+
// <Group>
|
|
361
|
+
// {daysInRange.map((day) => {
|
|
362
|
+
// let skiaView = daySkiaView?.(rect(day.x, day.y, cellSize, cellSize), day);
|
|
363
|
+
// if (skiaView !== undefined) { return skiaView; }
|
|
364
|
+
|
|
365
|
+
// return (
|
|
366
|
+
// <Rect
|
|
367
|
+
// key={day.date}
|
|
368
|
+
// x={day.x}
|
|
369
|
+
// y={day.y}
|
|
370
|
+
// width={cellSize}
|
|
371
|
+
// height={cellSize}
|
|
372
|
+
// color={getColor(day.value)}
|
|
373
|
+
// />
|
|
374
|
+
// );
|
|
375
|
+
// })}
|
|
376
|
+
// {onSelectSkiaViewMemo}
|
|
377
|
+
// </Group>
|
|
378
|
+
// </Canvas>
|
|
379
|
+
// </View>
|
|
380
|
+
// </View>
|
|
381
|
+
|
|
382
|
+
// {
|
|
383
|
+
// popupData && (<>
|
|
384
|
+
// {onSelectViewMemo &&
|
|
385
|
+
// <View
|
|
386
|
+
// style={{
|
|
387
|
+
// position: "absolute",
|
|
388
|
+
// top: popupData.y + (props.style?.horizontalLabelStyle?.viewPosition === "bottom" ? 0 : horizontalLabelHeight),
|
|
389
|
+
// left: popupData.x + verticalLabelWidth
|
|
390
|
+
// }}
|
|
391
|
+
// >
|
|
392
|
+
// {onSelectViewMemo}
|
|
393
|
+
// </View>
|
|
394
|
+
// }
|
|
395
|
+
// <Popup
|
|
396
|
+
// popupData={{ x: popupData.x + verticalLabelWidth, y: popupData.y + (props.style?.horizontalLabelStyle?.viewPosition === "bottom" ? 0 : horizontalLabelHeight), data: popupData.day }}
|
|
397
|
+
// totalWidth={totalWidth}
|
|
398
|
+
// totalHeight={totalHeight}
|
|
399
|
+
// touchHandler={(x, y) => {
|
|
400
|
+
// touchHandler(x - verticalLabelWidth - paddingLeft, y - (props.style?.horizontalLabelStyle?.viewPosition === "bottom" ? 0 : horizontalLabelHeight));
|
|
401
|
+
// }}
|
|
402
|
+
// onTouchOutside={onTouchOutside}
|
|
403
|
+
// popupStyle={props.popupStyle}
|
|
404
|
+
// viewOffset={viewOffset}
|
|
405
|
+
// />
|
|
406
|
+
// </>
|
|
407
|
+
// )
|
|
408
|
+
// }
|
|
409
|
+
// </View >;
|
|
410
|
+
// }
|
|
411
|
+
|
|
412
|
+
// export default HeatMap;
|
|
413
|
+
|
|
414
|
+
// <HeatMap
|
|
415
|
+
// startDate="2020-10-22"
|
|
416
|
+
// endDate="2020-12-21"
|
|
417
|
+
// data={[{
|
|
418
|
+
// "2020-10-22": 50,
|
|
419
|
+
// "2020-10-23": 10,
|
|
420
|
+
// "2020-10-24": 15,
|
|
421
|
+
// "2020-10-25": 20,
|
|
422
|
+
// "2020-10-26": 25,
|
|
423
|
+
// "2020-10-27": 30,
|
|
424
|
+
// "2020-10-28": 35,
|
|
425
|
+
// "2020-10-29": 40,
|
|
426
|
+
// "2020-10-30": 45,
|
|
427
|
+
// "2020-10-31": 50,
|
|
428
|
+
// "2020-12-20": 50,
|
|
429
|
+
// "2020-12-21": 50,
|
|
430
|
+
// }]}
|
|
431
|
+
// style={{ verticalLabelStyle: { width: 70, strokeWidth: 0 } }}
|
|
432
|
+
// yLabelView={(index) => <View><Text>Hello - {index}</Text></View>}
|
|
433
|
+
// yLabelSkiaView={(index, yPosition) => <Rect x={0} y={yPosition} width={20} height={20} color={"red"} />}
|
|
434
|
+
// daySkiaView={(rect, day) => {
|
|
435
|
+
// if ((day.week + day.dayOfWeek) % 2 === 0) { return undefined; }
|
|
436
|
+
// return <Rect
|
|
437
|
+
// key={day.date}
|
|
438
|
+
// x={rect.x}
|
|
439
|
+
// y={rect.y}
|
|
440
|
+
// width={rect.width}
|
|
441
|
+
// height={rect.height}
|
|
442
|
+
// color={"green"}
|
|
443
|
+
// />;
|
|
444
|
+
// }}
|
|
445
|
+
// onSelectView={(rect, day) => {
|
|
446
|
+
// return <View style={{ backgroundColor: "yellow", opacity: 0.2, padding: 10 }}>
|
|
447
|
+
// <Text style={{ color: "green" }}>Selected {day.date}</Text>
|
|
448
|
+
// </View>;
|
|
449
|
+
// }}
|
|
450
|
+
// onSelectSkiaView={(rect, day) => {
|
|
451
|
+
// return <Rect
|
|
452
|
+
// key={day.date}
|
|
453
|
+
// x={rect.x}
|
|
454
|
+
// y={rect.y}
|
|
455
|
+
// width={rect.width}
|
|
456
|
+
// height={rect.height}
|
|
457
|
+
// color={"yellow"}
|
|
458
|
+
// />;
|
|
459
|
+
// }}
|
|
460
|
+
// popupStyle={{
|
|
461
|
+
// width: 10,
|
|
462
|
+
// height: 10,
|
|
463
|
+
// renderPopup: (day) => (
|
|
464
|
+
// <VStack style={{ padding: 8, backgroundColor: "black", borderRadius: 8 }}>
|
|
465
|
+
// <Text>{day.value}</Text>
|
|
466
|
+
// <Text>{day.date}</Text>
|
|
467
|
+
// </VStack>
|
|
468
|
+
// ),
|
|
469
|
+
// }}
|
|
470
|
+
// />
|