tinybase 8.5.0-beta.3 → 8.5.0

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.
Files changed (163) hide show
  1. package/@types/ui-react-dom/index.d.ts +10 -10
  2. package/@types/ui-react-dom/with-schemas/index.d.ts +10 -10
  3. package/@types/ui-react-dom-charts/index.d.ts +177 -44
  4. package/@types/ui-react-dom-charts/with-schemas/index.d.ts +187 -48
  5. package/@types/ui-react-inspector/index.d.ts +1 -1
  6. package/@types/ui-react-inspector/with-schemas/index.d.ts +1 -1
  7. package/@types/ui-solid-dom/index.d.ts +10 -10
  8. package/@types/ui-solid-dom/with-schemas/index.d.ts +10 -10
  9. package/@types/ui-solid-inspector/index.d.ts +1 -1
  10. package/@types/ui-solid-inspector/with-schemas/index.d.ts +1 -1
  11. package/@types/ui-svelte-dom/index.d.ts +10 -10
  12. package/@types/ui-svelte-dom/with-schemas/index.d.ts +10 -10
  13. package/@types/ui-svelte-inspector/index.d.ts +1 -1
  14. package/@types/ui-svelte-inspector/with-schemas/index.d.ts +1 -1
  15. package/common/index.js +1 -1
  16. package/common/with-schemas/index.js +1 -1
  17. package/index.js +3 -2
  18. package/mergeable-store/index.js +3 -2
  19. package/mergeable-store/with-schemas/index.js +3 -2
  20. package/min/index.js +1 -1
  21. package/min/index.js.gz +0 -0
  22. package/min/mergeable-store/index.js +1 -1
  23. package/min/mergeable-store/index.js.gz +0 -0
  24. package/min/mergeable-store/with-schemas/index.js +1 -1
  25. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  26. package/min/omni/index.js +1 -1
  27. package/min/omni/index.js.gz +0 -0
  28. package/min/omni/with-schemas/index.js +1 -1
  29. package/min/omni/with-schemas/index.js.gz +0 -0
  30. package/min/persisters/index.js +1 -1
  31. package/min/persisters/index.js.gz +0 -0
  32. package/min/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  33. package/min/persisters/persister-cr-sqlite-wasm/index.js.gz +0 -0
  34. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  35. package/min/persisters/persister-cr-sqlite-wasm/with-schemas/index.js.gz +0 -0
  36. package/min/persisters/persister-durable-object-sql-storage/index.js +1 -1
  37. package/min/persisters/persister-durable-object-sql-storage/index.js.gz +0 -0
  38. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  39. package/min/persisters/persister-durable-object-sql-storage/with-schemas/index.js.gz +0 -0
  40. package/min/persisters/persister-electric-sql/index.js +1 -1
  41. package/min/persisters/persister-electric-sql/index.js.gz +0 -0
  42. package/min/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  43. package/min/persisters/persister-electric-sql/with-schemas/index.js.gz +0 -0
  44. package/min/persisters/persister-expo-sqlite/index.js +1 -1
  45. package/min/persisters/persister-expo-sqlite/index.js.gz +0 -0
  46. package/min/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  47. package/min/persisters/persister-expo-sqlite/with-schemas/index.js.gz +0 -0
  48. package/min/persisters/persister-libsql/index.js +1 -1
  49. package/min/persisters/persister-libsql/index.js.gz +0 -0
  50. package/min/persisters/persister-libsql/with-schemas/index.js +1 -1
  51. package/min/persisters/persister-libsql/with-schemas/index.js.gz +0 -0
  52. package/min/persisters/persister-pglite/index.js +1 -1
  53. package/min/persisters/persister-pglite/index.js.gz +0 -0
  54. package/min/persisters/persister-pglite/with-schemas/index.js +1 -1
  55. package/min/persisters/persister-pglite/with-schemas/index.js.gz +0 -0
  56. package/min/persisters/persister-postgres/index.js +1 -1
  57. package/min/persisters/persister-postgres/index.js.gz +0 -0
  58. package/min/persisters/persister-postgres/with-schemas/index.js +1 -1
  59. package/min/persisters/persister-postgres/with-schemas/index.js.gz +0 -0
  60. package/min/persisters/persister-powersync/index.js +1 -1
  61. package/min/persisters/persister-powersync/index.js.gz +0 -0
  62. package/min/persisters/persister-powersync/with-schemas/index.js +1 -1
  63. package/min/persisters/persister-powersync/with-schemas/index.js.gz +0 -0
  64. package/min/persisters/persister-react-native-sqlite/index.js +1 -1
  65. package/min/persisters/persister-react-native-sqlite/index.js.gz +0 -0
  66. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  67. package/min/persisters/persister-react-native-sqlite/with-schemas/index.js.gz +0 -0
  68. package/min/persisters/persister-remote/index.js +1 -1
  69. package/min/persisters/persister-remote/index.js.gz +0 -0
  70. package/min/persisters/persister-remote/with-schemas/index.js +1 -1
  71. package/min/persisters/persister-remote/with-schemas/index.js.gz +0 -0
  72. package/min/persisters/persister-sqlite-bun/index.js +1 -1
  73. package/min/persisters/persister-sqlite-bun/index.js.gz +0 -0
  74. package/min/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  75. package/min/persisters/persister-sqlite-bun/with-schemas/index.js.gz +0 -0
  76. package/min/persisters/persister-sqlite-wasm/index.js +1 -1
  77. package/min/persisters/persister-sqlite-wasm/index.js.gz +0 -0
  78. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  79. package/min/persisters/persister-sqlite-wasm/with-schemas/index.js.gz +0 -0
  80. package/min/persisters/persister-sqlite3/index.js +1 -1
  81. package/min/persisters/persister-sqlite3/index.js.gz +0 -0
  82. package/min/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  83. package/min/persisters/persister-sqlite3/with-schemas/index.js.gz +0 -0
  84. package/min/persisters/with-schemas/index.js +1 -1
  85. package/min/persisters/with-schemas/index.js.gz +0 -0
  86. package/min/synchronizers/index.js +1 -1
  87. package/min/synchronizers/index.js.gz +0 -0
  88. package/min/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
  89. package/min/synchronizers/synchronizer-broadcast-channel/index.js.gz +0 -0
  90. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
  91. package/min/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js.gz +0 -0
  92. package/min/synchronizers/synchronizer-local/index.js +1 -1
  93. package/min/synchronizers/synchronizer-local/index.js.gz +0 -0
  94. package/min/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  95. package/min/synchronizers/synchronizer-local/with-schemas/index.js.gz +0 -0
  96. package/min/synchronizers/synchronizer-ws-client/index.js +1 -1
  97. package/min/synchronizers/synchronizer-ws-client/index.js.gz +0 -0
  98. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  99. package/min/synchronizers/synchronizer-ws-client/with-schemas/index.js.gz +0 -0
  100. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  101. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  102. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  103. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  104. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  105. package/min/synchronizers/synchronizer-ws-server-durable-object/index.js.gz +0 -0
  106. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  107. package/min/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js.gz +0 -0
  108. package/min/synchronizers/with-schemas/index.js +1 -1
  109. package/min/synchronizers/with-schemas/index.js.gz +0 -0
  110. package/min/ui-react-dom-charts/index.js +1 -1
  111. package/min/ui-react-dom-charts/index.js.gz +0 -0
  112. package/min/ui-react-dom-charts/with-schemas/index.js +1 -1
  113. package/min/ui-react-dom-charts/with-schemas/index.js.gz +0 -0
  114. package/min/with-schemas/index.js +1 -1
  115. package/min/with-schemas/index.js.gz +0 -0
  116. package/omni/index.js +7 -6
  117. package/omni/with-schemas/index.js +7 -6
  118. package/package.json +4 -4
  119. package/persisters/index.js +1 -1
  120. package/persisters/persister-cr-sqlite-wasm/index.js +1 -1
  121. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +1 -1
  122. package/persisters/persister-durable-object-sql-storage/index.js +1 -1
  123. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +1 -1
  124. package/persisters/persister-electric-sql/index.js +1 -1
  125. package/persisters/persister-electric-sql/with-schemas/index.js +1 -1
  126. package/persisters/persister-expo-sqlite/index.js +1 -1
  127. package/persisters/persister-expo-sqlite/with-schemas/index.js +1 -1
  128. package/persisters/persister-libsql/index.js +1 -1
  129. package/persisters/persister-libsql/with-schemas/index.js +1 -1
  130. package/persisters/persister-pglite/index.js +1 -1
  131. package/persisters/persister-pglite/with-schemas/index.js +1 -1
  132. package/persisters/persister-postgres/index.js +1 -1
  133. package/persisters/persister-postgres/with-schemas/index.js +1 -1
  134. package/persisters/persister-powersync/index.js +1 -1
  135. package/persisters/persister-powersync/with-schemas/index.js +1 -1
  136. package/persisters/persister-react-native-sqlite/index.js +1 -1
  137. package/persisters/persister-react-native-sqlite/with-schemas/index.js +1 -1
  138. package/persisters/persister-remote/index.js +3 -3
  139. package/persisters/persister-remote/with-schemas/index.js +3 -3
  140. package/persisters/persister-sqlite-bun/index.js +1 -1
  141. package/persisters/persister-sqlite-bun/with-schemas/index.js +1 -1
  142. package/persisters/persister-sqlite-wasm/index.js +1 -1
  143. package/persisters/persister-sqlite-wasm/with-schemas/index.js +1 -1
  144. package/persisters/persister-sqlite3/index.js +1 -1
  145. package/persisters/persister-sqlite3/with-schemas/index.js +1 -1
  146. package/persisters/with-schemas/index.js +1 -1
  147. package/readme.md +14 -14
  148. package/releases.md +57 -57
  149. package/synchronizers/index.js +2 -1
  150. package/synchronizers/synchronizer-broadcast-channel/index.js +2 -1
  151. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +2 -1
  152. package/synchronizers/synchronizer-local/index.js +2 -1
  153. package/synchronizers/synchronizer-local/with-schemas/index.js +2 -1
  154. package/synchronizers/synchronizer-ws-client/index.js +2 -1
  155. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +2 -1
  156. package/synchronizers/synchronizer-ws-server/index.js +2 -1
  157. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +2 -1
  158. package/synchronizers/synchronizer-ws-server-durable-object/index.js +2 -1
  159. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +2 -1
  160. package/synchronizers/with-schemas/index.js +2 -1
  161. package/ui-react-dom-charts/index.js +688 -324
  162. package/ui-react-dom-charts/with-schemas/index.js +688 -324
  163. package/with-schemas/index.js +3 -2
@@ -6,6 +6,7 @@ const TINYBASE = 'tinybase';
6
6
  const EMPTY_STRING = '';
7
7
  const STRING = getTypeOf(EMPTY_STRING);
8
8
  const NUMBER = getTypeOf(0);
9
+ const FUNCTION = getTypeOf(getTypeOf);
9
10
  const LISTENER = 'Listener';
10
11
  const RESULT = 'Result';
11
12
  const GET = 'get';
@@ -16,6 +17,7 @@ const SORTED_ROW_IDS = 'Sorted' + ROW + IDS;
16
17
  const CELL = 'Cell';
17
18
 
18
19
  const math = Math;
20
+ const date = Date;
19
21
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
20
22
  predicate(value)
21
23
  ? /* istanbul ignore next */
@@ -32,12 +34,21 @@ const mathPow = math.pow;
32
34
  const mathRound = math.round;
33
35
  const mathAbs = math.abs;
34
36
  const mathLog10 = math.log10;
37
+ const dateUtc = date.UTC;
35
38
  const infinity = Infinity;
36
39
  const epsilon = Number.EPSILON;
37
40
  const isFiniteNumber = isFinite;
38
41
  const isInteger = number.isInteger;
39
42
  const isNullish = (thing) => thing == null;
40
43
  const isUndefined = (thing) => thing === void 0;
44
+ const dateNew = (value) => (isUndefined(value) ? new date() : new date(value));
45
+ const dateGetUTCFullYear = (dateObj) => dateObj.getUTCFullYear();
46
+ const dateGetUTCMonth = (dateObj) => dateObj.getUTCMonth();
47
+ const dateGetUTCDate = (dateObj) => dateObj.getUTCDate();
48
+ const dateGetUTCDay = (dateObj) => dateObj.getUTCDay();
49
+ const dateGetUTCHours = (dateObj) => dateObj.getUTCHours();
50
+ const dateGetUTCMinutes = (dateObj) => dateObj.getUTCMinutes();
51
+ const dateGetUTCSeconds = (dateObj) => dateObj.getUTCSeconds();
41
52
  const isNull = (thing) => thing === null;
42
53
  const isTrue = (thing) => thing === true;
43
54
  const isFalse = (thing) => thing === false;
@@ -45,9 +56,34 @@ const ifNotNullish = getIfNotFunction(isNullish);
45
56
  const ifNotUndefined = getIfNotFunction(isUndefined);
46
57
  const isString = (thing) => getTypeOf(thing) == STRING;
47
58
  const isNumber = (thing) => getTypeOf(thing) == NUMBER;
59
+ const isFunction = (thing) => getTypeOf(thing) == FUNCTION;
48
60
  const isArray = (thing) => Array.isArray(thing);
49
61
  const size = (arrayOrString) => arrayOrString.length;
50
62
  const test = (regex, subject) => regex.test(subject);
63
+ const errorNew = (message) => {
64
+ throw new Error(message);
65
+ };
66
+
67
+ const arrayNew = (size2, cb) =>
68
+ arrayMap(new Array(size2).fill(0), (_, index) => cb(index));
69
+ const arrayHas = (array, value) => array.includes(value);
70
+ const arrayIndexOf = (array, value) => array.indexOf(value);
71
+ const arrayEvery = (array, cb) => array.every(cb);
72
+ const arrayIsEqual = (array1, array2) =>
73
+ size(array1) === size(array2) &&
74
+ arrayEvery(array1, (value1, index) => array2[index] === value1);
75
+ const arrayOrValueEqual = (value1, value2) =>
76
+ isArray(value1) && isArray(value2)
77
+ ? arrayIsEqual(value1, value2)
78
+ : value1 === value2;
79
+ const arraySort = (array, sorter) => array.sort(sorter);
80
+ const arrayForEach = (array, cb) => array.forEach(cb);
81
+ const arrayJoin = (array, sep = EMPTY_STRING) => array.join(sep);
82
+ const arrayMap = (array, cb) => array.map(cb);
83
+ const arrayIsEmpty = (array) => size(array) == 0;
84
+ const arrayFilter = (array, cb) => array.filter(cb);
85
+ const arrayPush = (array, ...values) => array.push(...values);
86
+ const arrayShift = (array) => array.shift();
51
87
 
52
88
  const {
53
89
  Children,
@@ -65,55 +101,136 @@ const {
65
101
  useSyncExternalStore,
66
102
  } = React;
67
103
 
104
+ const CATEGORY = 'category';
105
+ const LINEAR = 'linear';
106
+ const TIME = 'time';
107
+ const MILLISECOND = 'millisecond';
108
+ const SECOND_UNIT = 'second';
109
+ const BAR = 'bar';
110
+ const LINE = 'line';
111
+ const CURRENT_COLOR = 'currentColor';
112
+ const SERIES = '_tinybaseChartSeries';
113
+ const X_AXIS = '_tinybaseChartXAxis';
114
+ const Y_AXIS = '_tinybaseChartYAxis';
115
+
68
116
  var SourceType = /* @__PURE__ */ ((SourceType2) => {
69
117
  SourceType2[(SourceType2['None'] = 0)] = 'None';
70
118
  SourceType2[(SourceType2['Query'] = 1)] = 'Query';
71
119
  SourceType2[(SourceType2['Table'] = 2)] = 'Table';
72
120
  return SourceType2;
73
121
  })(SourceType || {});
74
- const SERIES = '_tinybaseChartSeries';
75
- const X_AXIS = '_tinybaseChartXAxis';
76
- const Y_AXIS = '_tinybaseChartYAxis';
77
122
  const isSeriesComponent = (component) =>
78
- typeof component == 'function' && component[SERIES] === true;
123
+ isFunction(component) && component[SERIES] === true;
79
124
  const isXAxisComponent = (component) =>
80
- typeof component == 'function' && component[X_AXIS] === true;
125
+ isFunction(component) && component[X_AXIS] === true;
81
126
  const isYAxisComponent = (component) =>
82
- typeof component == 'function' && component[Y_AXIS] === true;
127
+ isFunction(component) && component[Y_AXIS] === true;
83
128
  const CartesianChartContext = createContext(null);
84
129
  const useCartesianChartContext = () => {
85
130
  const context = useContext(CartesianChartContext);
86
- if (context == null) {
87
- throw new Error('Series components must be used inside a CartesianChart');
131
+ if (isNullish(context)) {
132
+ errorNew('Series components must be used inside a CartesianChart');
88
133
  }
89
134
  return context;
90
135
  };
91
136
 
92
- const arrayNew = (size2, cb) =>
93
- arrayMap(new Array(size2).fill(0), (_, index) => cb(index));
94
- const arrayHas = (array, value) => array.includes(value);
95
- const arrayIndexOf = (array, value) => array.indexOf(value);
96
- const arrayEvery = (array, cb) => array.every(cb);
97
- const arrayIsEqual = (array1, array2) =>
98
- size(array1) === size(array2) &&
99
- arrayEvery(array1, (value1, index) => array2[index] === value1);
100
- const arrayOrValueEqual = (value1, value2) =>
101
- isArray(value1) && isArray(value2)
102
- ? arrayIsEqual(value1, value2)
103
- : value1 === value2;
104
- const arraySort = (array, sorter) => array.sort(sorter);
105
- const arrayForEach = (array, cb) => array.forEach(cb);
106
- const arrayJoin = (array, sep = EMPTY_STRING) => array.join(sep);
107
- const arrayMap = (array, cb) => array.map(cb);
108
- const arrayIsEmpty = (array) => size(array) == 0;
109
- const arrayFilter = (array, cb) => array.filter(cb);
110
- const arrayPush = (array, ...values) => array.push(...values);
111
- const arrayShift = (array) => array.shift();
112
-
113
137
  const collSize = (coll) => coll?.size ?? 0;
138
+ const collHas = (coll, keyOrValue) => coll?.has(keyOrValue) ?? false;
139
+ const collDel = (coll, keyOrValue) => coll?.delete(keyOrValue);
140
+
141
+ const object = Object;
142
+ const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
143
+ const objEntries = object.entries;
144
+ const isObject = (obj) =>
145
+ !isNullish(obj) &&
146
+ ifNotNullish(
147
+ getPrototypeOf(obj),
148
+ (objPrototype) =>
149
+ objPrototype == object.prototype ||
150
+ isNullish(getPrototypeOf(objPrototype)),
151
+
152
+ /* istanbul ignore next */
153
+ () => true,
154
+ );
155
+ const objIds = object.keys;
156
+ const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
157
+ const objValues = (obj) => object.values(obj);
158
+ const objSize = (obj) => size(objIds(obj));
159
+
160
+ /* istanbul ignore next */
161
+ const objIsEqual = (
162
+ obj1,
163
+ obj2,
164
+ isEqual = (value1, value2) => value1 === value2,
165
+ ) => {
166
+ const entries1 = objEntries(obj1);
167
+ return (
168
+ size(entries1) === objSize(obj2) &&
169
+ arrayEvery(entries1, ([index, value1]) =>
170
+ isObject(value1)
171
+ ? /* istanbul ignore next */
172
+ isObject(obj2[index])
173
+ ? objIsEqual(obj2[index], value1, isEqual)
174
+ : false
175
+ : isEqual(value1, obj2[index]),
176
+ )
177
+ );
178
+ };
179
+
180
+ const map = Map;
181
+ const mapNew = (entries) => new map(entries);
182
+ const mapGet = (map2, key) => map2?.get(key);
183
+ const mapSet = (map2, key, value) =>
184
+ isUndefined(value) ? (collDel(map2, key), map2) : map2?.set(key, value);
114
185
 
186
+ const TARGET_TICKS = 10;
115
187
  const NICE_NUMBERS = [1, 5, 2, 2.5, 4, 3];
116
188
  const WEIGHTS = [0.25, 0.2, 0.5, 0.05];
189
+ const SECOND = 1e3;
190
+ const MINUTE = 60 * SECOND;
191
+ const HOUR = 60 * MINUTE;
192
+ const DAY = 24 * HOUR;
193
+ const MONTH = 30 * DAY;
194
+ const YEAR = 365 * DAY;
195
+ const MINUTE_UNIT = 'minute';
196
+ const HOUR_UNIT = 'hour';
197
+ const DAY_UNIT = 'day';
198
+ const WEEK_UNIT = 'week';
199
+ const MONTH_UNIT = 'month';
200
+ const QUARTER_UNIT = 'quarter';
201
+ const YEAR_UNIT = 'year';
202
+ const TIME_INTERVALS = [
203
+ [SECOND_UNIT, 1],
204
+ [SECOND_UNIT, 5],
205
+ [SECOND_UNIT, 10],
206
+ [SECOND_UNIT, 15],
207
+ [SECOND_UNIT, 30],
208
+ [MINUTE_UNIT, 1],
209
+ [MINUTE_UNIT, 5],
210
+ [MINUTE_UNIT, 10],
211
+ [MINUTE_UNIT, 15],
212
+ [MINUTE_UNIT, 30],
213
+ [HOUR_UNIT, 1],
214
+ [HOUR_UNIT, 3],
215
+ [HOUR_UNIT, 6],
216
+ [HOUR_UNIT, 12],
217
+ [DAY_UNIT, 1],
218
+ [DAY_UNIT, 2],
219
+ [WEEK_UNIT, 1],
220
+ [MONTH_UNIT, 1],
221
+ [MONTH_UNIT, 2],
222
+ [QUARTER_UNIT, 1],
223
+ [MONTH_UNIT, 6],
224
+ [YEAR_UNIT, 1],
225
+ [YEAR_UNIT, 2],
226
+ [YEAR_UNIT, 5],
227
+ [YEAR_UNIT, 10],
228
+ [YEAR_UNIT, 25],
229
+ [YEAR_UNIT, 50],
230
+ [YEAR_UNIT, 100],
231
+ ];
232
+ const getTickCount = (tickCount = TARGET_TICKS) =>
233
+ isFiniteNumber(tickCount) ? mathMax(mathRound(tickCount), 1) : TARGET_TICKS;
117
234
  const getTicks = (
118
235
  min,
119
236
  max,
@@ -235,8 +352,129 @@ const getTicks = (
235
352
  }
236
353
  return bestTicks;
237
354
  };
355
+ const getTimeTicks = (
356
+ minTimestamp,
357
+ maxTimestamp,
358
+ targetTickCount,
359
+ labelSize,
360
+ axisSize,
361
+ ) => {
362
+ const min = mathMin(minTimestamp, maxTimestamp);
363
+ const max = mathMax(minTimestamp, maxTimestamp);
364
+ let bestTicks = [min, max];
365
+ let bestScore = -infinity;
366
+ arrayForEach(TIME_INTERVALS, (interval, index) => {
367
+ const ticks = [];
368
+ for (
369
+ let tick = floorTime(min, interval), count = 0;
370
+ tick <= max && count < 1e3;
371
+ tick = addTime(tick, interval), count++
372
+ ) {
373
+ arrayPush(ticks, tick);
374
+ }
375
+ const lastTick = ticks[size(ticks) - 1];
376
+ if (!isFiniteNumber(lastTick) || lastTick < max) {
377
+ arrayPush(ticks, addTime(lastTick ?? floorTime(min, interval), interval));
378
+ }
379
+ const tickCount = size(ticks);
380
+ const tickMin = ticks[0];
381
+ const tickMax = ticks[tickCount - 1];
382
+ const range = max - min;
383
+ const target = mathMax(targetTickCount, 2);
384
+ const spacing = axisSize / (tickCount - 1);
385
+ const score =
386
+ tickCount < 2
387
+ ? -infinity
388
+ : WEIGHTS[0] * (1 - index / mathMax(size(TIME_INTERVALS) - 1, 1)) +
389
+ WEIGHTS[1] *
390
+ (1 - (mathAbs(min - tickMin) + mathAbs(tickMax - max)) / range) +
391
+ WEIGHTS[2] * (2 - mathMax(tickCount / target, target / tickCount)) +
392
+ WEIGHTS[3] *
393
+ (spacing < labelSize * 1.2
394
+ ? -infinity
395
+ : mathMin(spacing / labelSize, 1));
396
+ if (score > bestScore) {
397
+ bestTicks = ticks;
398
+ bestScore = score;
399
+ }
400
+ });
401
+ return bestTicks;
402
+ };
403
+ const getTimeTickLabel = (timestamp, ticks) => {
404
+ const date = dateNew(timestamp);
405
+ const year = dateGetUTCFullYear(date) + EMPTY_STRING;
406
+ const month = getPadded(dateGetUTCMonth(date) + 1);
407
+ const day = getPadded(dateGetUTCDate(date));
408
+ const hour = getPadded(dateGetUTCHours(date));
409
+ const minute = getPadded(dateGetUTCMinutes(date));
410
+ const second = getPadded(dateGetUTCSeconds(date));
411
+ const dateLabel = `${year}-${month}-${day}`;
412
+ let minDiff = infinity;
413
+ arrayForEach(ticks, (tick, index) => {
414
+ if (index > 0) {
415
+ minDiff = mathMin(minDiff, tick - ticks[index - 1]);
416
+ }
417
+ });
418
+ minDiff =
419
+ minDiff == infinity
420
+ ? dateGetUTCHours(date) == 0 &&
421
+ dateGetUTCMinutes(date) == 0 &&
422
+ dateGetUTCSeconds(date) == 0
423
+ ? DAY
424
+ : dateGetUTCSeconds(date) == 0
425
+ ? HOUR
426
+ : SECOND
427
+ : minDiff;
428
+ return minDiff < MINUTE
429
+ ? `${dateLabel} ${hour}:${minute}:${second}`
430
+ : minDiff < DAY
431
+ ? `${dateLabel} ${hour}:${minute}`
432
+ : minDiff < MONTH
433
+ ? dateLabel
434
+ : minDiff < YEAR
435
+ ? `${year}-${month}`
436
+ : year;
437
+ };
438
+ const floorTime = (timestamp, [unit, step]) => {
439
+ const date = dateNew(timestamp);
440
+ const year = dateGetUTCFullYear(date);
441
+ const month = dateGetUTCMonth(date);
442
+ const monthStep = unit == QUARTER_UNIT ? step * 3 : step;
443
+ const monthIndex = year * 12 + month;
444
+ const flooredMonthIndex = mathFloor(monthIndex / monthStep) * monthStep;
445
+ const fixedInterval = getFixedInterval(unit, step);
446
+ return unit == YEAR_UNIT
447
+ ? dateUtc(mathFloor(year / step) * step, 0, 1)
448
+ : unit == QUARTER_UNIT || unit == MONTH_UNIT
449
+ ? dateUtc(mathFloor(flooredMonthIndex / 12), flooredMonthIndex % 12, 1)
450
+ : unit == WEEK_UNIT
451
+ ? dateUtc(year, month, dateGetUTCDate(date)) -
452
+ ((dateGetUTCDay(date) + 6) % 7) * DAY
453
+ : mathFloor(timestamp / fixedInterval) * fixedInterval;
454
+ };
455
+ const addTime = (timestamp, [unit, step]) => {
456
+ const date = dateNew(timestamp);
457
+ return unit == YEAR_UNIT
458
+ ? dateUtc(dateGetUTCFullYear(date) + step, 0, 1)
459
+ : unit == QUARTER_UNIT
460
+ ? dateUtc(dateGetUTCFullYear(date), dateGetUTCMonth(date) + step * 3, 1)
461
+ : unit == MONTH_UNIT
462
+ ? dateUtc(dateGetUTCFullYear(date), dateGetUTCMonth(date) + step, 1)
463
+ : timestamp + getFixedInterval(unit, step);
464
+ };
465
+ const getFixedInterval = (unit, step) =>
466
+ unit == WEEK_UNIT
467
+ ? step * 7 * DAY
468
+ : unit == DAY_UNIT
469
+ ? step * DAY
470
+ : unit == HOUR_UNIT
471
+ ? step * HOUR
472
+ : unit == MINUTE_UNIT
473
+ ? step * MINUTE
474
+ : step * SECOND;
475
+ const getPadded = (value) => (value < 10 ? `0${value}` : value + EMPTY_STRING);
238
476
 
239
- const TARGET_TICKS = 10;
477
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}(?:$|T)/;
240
478
  const getDataPoints = (rowIds, getPoint) =>
241
479
  arrayFilter(arrayMap(rowIds, getPoint), (point) => !isUndefined(point));
242
480
  const getDataPoint = (rowId, xCell, yCell) => {
@@ -252,50 +490,78 @@ const getScaledPoints = (
252
490
  [xMin, xMax, yMin, yMax],
253
491
  [width, height],
254
492
  xValues,
493
+ xScale = CATEGORY,
494
+ timestampUnit = MILLISECOND,
255
495
  xTitle,
256
496
  yTitle,
257
497
  ) => {
258
- const numericX =
259
- kind == 'line' &&
260
- arrayIsEmpty(arrayFilter(points, ([, xValue]) => !isNumber(xValue)));
261
- const xDomain = numericX ? [xMin, xMax] : [0, 0];
498
+ const continuousX = xScale != CATEGORY;
499
+ const xDomain = continuousX ? [xMin, xMax] : [0, 0];
262
500
  const yDomain = [yMin ?? 0, yMax ?? 0];
263
- const xCategories = /* @__PURE__ */ new Map();
501
+ const xCategories = mapNew();
264
502
  arrayForEach(
265
- xValues == null || arrayIsEmpty(xValues)
503
+ isNullish(xValues) || arrayIsEmpty(xValues)
266
504
  ? arrayMap(points, ([, xValue]) => xValue)
267
505
  : xValues,
268
- (xValue) => {
269
- if (!xCategories.has(xValue)) {
270
- xCategories.set(xValue, collSize(xCategories));
271
- }
272
- },
506
+ (xValue) =>
507
+ collHas(xCategories, xValue)
508
+ ? 0
509
+ : mapSet(xCategories, xValue, collSize(xCategories)),
510
+ );
511
+ return arrayFilter(
512
+ arrayMap(points, ([rowId, xValue, yValue]) => {
513
+ const x = getX(
514
+ xValue,
515
+ xScale,
516
+ timestampUnit,
517
+ xDomain,
518
+ xCategories,
519
+ width,
520
+ kind,
521
+ );
522
+ return isUndefined(x)
523
+ ? void 0
524
+ : [
525
+ rowId,
526
+ xValue,
527
+ yValue,
528
+ x,
529
+ height - getScale(yValue, yDomain[0], yDomain[1], height),
530
+ xTitle,
531
+ yTitle,
532
+ ];
533
+ }),
534
+ (point) => !isUndefined(point),
273
535
  );
274
- return arrayMap(points, ([rowId, xValue, yValue]) => [
275
- rowId,
276
- xValue,
277
- yValue,
278
- getX(xValue, numericX, xDomain, xCategories, width, kind),
279
- getY(yValue, yDomain, height),
280
- xTitle,
281
- yTitle,
282
- ]);
283
536
  };
284
- const getX = (xValue, numericX, [xMin, xMax], xCategories, width, kind) =>
285
- numericX
286
- ? getScale(xValue, xMin, xMax, width)
287
- : kind == 'bar'
288
- ? (width * ((xCategories.get(xValue) ?? 0) + 0.5)) / collSize(xCategories)
537
+ const getX = (
538
+ xValue,
539
+ xScale,
540
+ timestampUnit,
541
+ [xMin, xMax],
542
+ xCategories,
543
+ width,
544
+ kind,
545
+ ) => {
546
+ const continuousValue = getContinuousXValue(xValue, xScale, timestampUnit);
547
+ return xScale != CATEGORY
548
+ ? isUndefined(continuousValue)
549
+ ? void 0
550
+ : getScale(continuousValue, xMin, xMax, width)
551
+ : kind == BAR
552
+ ? (width * ((mapGet(xCategories, xValue) ?? 0) + 0.5)) /
553
+ collSize(xCategories)
289
554
  : getScale(
290
- xCategories.get(xValue) ?? 0,
555
+ mapGet(xCategories, xValue) ?? 0,
291
556
  0,
292
557
  collSize(xCategories) - 1,
293
558
  width,
294
559
  );
295
- const getY = (yValue, [yMin, yMax], height) =>
296
- height - getScale(yValue, yMin, yMax, height);
560
+ };
297
561
  const getScale = (value, min, max, size2) =>
298
- min == max ? size2 / 2 : getRounded((size2 * (value - min)) / (max - min));
562
+ min == max
563
+ ? size2 / 2
564
+ : mathRound(((size2 * (value - min)) / (max - min)) * 1e6) / 1e6;
299
565
  const getBounds = (kind, points) => {
300
566
  if (arrayIsEmpty(points)) {
301
567
  return [];
@@ -324,7 +590,7 @@ const getYTicks = ([, , yMin, yMax], [, height], labelSize, tickCount) => {
324
590
  );
325
591
  };
326
592
  const getXTicks = (kind, [xMin, xMax], [width], labelSize, tickCount) =>
327
- kind == 'line' && isNumber(xMin) && isNumber(xMax) && xMin != xMax
593
+ kind == LINE && isNumber(xMin) && isNumber(xMax) && xMin != xMax
328
594
  ? getTicks(
329
595
  xMin,
330
596
  xMax,
@@ -334,9 +600,61 @@ const getXTicks = (kind, [xMin, xMax], [width], labelSize, tickCount) =>
334
600
  isInteger(xMin) && isInteger(xMax),
335
601
  )
336
602
  : [];
603
+ const getResolvedXScale = (
604
+ xAxisScale,
605
+ {continuousX, xValues},
606
+ hasLinearAxisDefinition,
607
+ ) =>
608
+ xAxisScale == CATEGORY || xAxisScale == LINEAR || xAxisScale == TIME
609
+ ? xAxisScale
610
+ : continuousX || (arrayIsEmpty(xValues) && hasLinearAxisDefinition)
611
+ ? LINEAR
612
+ : !arrayIsEmpty(xValues) &&
613
+ arrayEvery(
614
+ xValues,
615
+ (xValue) =>
616
+ isString(xValue) &&
617
+ isFiniteNumber(normalizeTimeValue(xValue, MILLISECOND)),
618
+ )
619
+ ? TIME
620
+ : CATEGORY;
621
+ const getXScaleDomain = ([xMin, xMax], xValues, xScale, timestampUnit) => {
622
+ const timestamps = [];
623
+ return xScale == LINEAR
624
+ ? [isNumber(xMin) ? xMin : void 0, isNumber(xMax) ? xMax : void 0]
625
+ : xScale == TIME
626
+ ? (arrayForEach(xValues, (xValue) => {
627
+ const timestamp = normalizeTimeValue(xValue, timestampUnit);
628
+ if (isFiniteNumber(timestamp)) {
629
+ arrayPush(timestamps, timestamp);
630
+ }
631
+ }),
632
+ arrayIsEmpty(timestamps) ? [] : getDomain(timestamps))
633
+ : [xMin, xMax];
634
+ };
635
+ const normalizeTimeValue = (value, timestampUnit) => {
636
+ const timestamp = isNumber(value)
637
+ ? timestampUnit == SECOND_UNIT
638
+ ? value * 1e3
639
+ : value
640
+ : isString(value) && ISO_DATE.test(value)
641
+ ? getTime(value)
642
+ : value instanceof Date
643
+ ? getTime(value)
644
+ : void 0;
645
+ return isFiniteNumber(timestamp) ? timestamp : void 0;
646
+ };
337
647
  const getTickBounds = ([xMin, xMax, yMin, yMax], xTicks, yTicks) => [
338
- arrayIsEmpty(xTicks) ? xMin : getMinTickBound(xMin, xTicks[0]),
339
- arrayIsEmpty(xTicks) ? xMax : getMaxTickBound(xMax, xTicks[size(xTicks) - 1]),
648
+ arrayIsEmpty(xTicks)
649
+ ? xMin
650
+ : isNumber(xMin)
651
+ ? mathMin(xMin, xTicks[0])
652
+ : xTicks[0],
653
+ arrayIsEmpty(xTicks)
654
+ ? xMax
655
+ : isNumber(xMax)
656
+ ? mathMax(xMax, xTicks[size(xTicks) - 1])
657
+ : xTicks[size(xTicks) - 1],
340
658
  arrayIsEmpty(yTicks) ? yMin : mathMin(yMin ?? infinity, yTicks[0]),
341
659
  arrayIsEmpty(yTicks)
342
660
  ? yMax
@@ -346,7 +664,7 @@ const getSeriesSummary = (kind, points, xCellId, yCellId, yLabel) => {
346
664
  const [xMin, xMax, yMin, yMax] = getBounds(kind, points);
347
665
  const xValues = [];
348
666
  const continuousX =
349
- kind == 'line' &&
667
+ kind == LINE &&
350
668
  arrayIsEmpty(arrayFilter(points, ([, xValue]) => !isNumber(xValue)));
351
669
  arrayForEach(points, ([, xValue]) => {
352
670
  if (!arrayHas(xValues, xValue)) {
@@ -382,17 +700,17 @@ const getDomainState = (summaries) => {
382
700
  }
383
701
  });
384
702
  if (isNumber(summary.xMin) && isNumber(summary.xMax)) {
385
- xMins.push(summary.xMin);
386
- xMaxes.push(summary.xMax);
703
+ arrayPush(xMins, summary.xMin);
704
+ arrayPush(xMaxes, summary.xMax);
387
705
  } else {
388
706
  xMin ??= summary.xMin;
389
707
  xMax = summary.xMax ?? xMax;
390
708
  }
391
709
  if (!isUndefined(summary.yMin)) {
392
- yMins.push(summary.yMin);
710
+ arrayPush(yMins, summary.yMin);
393
711
  }
394
712
  if (!isUndefined(summary.yMax)) {
395
- yMaxes.push(summary.yMax);
713
+ arrayPush(yMaxes, summary.yMax);
396
714
  }
397
715
  });
398
716
  return {
@@ -406,22 +724,27 @@ const getDomainState = (summaries) => {
406
724
  xValues,
407
725
  };
408
726
  };
409
- const getYDomain = (points, kind = 'bar') =>
727
+ const getYDomain = (points, kind = BAR) =>
410
728
  getDomain([
411
- ...(kind == 'bar' ? [0] : []),
729
+ ...(kind == BAR ? [0] : []),
412
730
  ...arrayMap(points, ([, , yValue]) => yValue),
413
731
  ]);
414
732
  const getDomain = (values) => {
415
733
  const min = mathMin(...values);
416
734
  return min == infinity ? [0, 0] : [min, mathMax(...values)];
417
735
  };
418
- const getMinTickBound = (bound, tick) =>
419
- isNumber(bound) ? mathMin(bound, tick) : tick;
420
- const getMaxTickBound = (bound, tick) =>
421
- isNumber(bound) ? mathMax(bound, tick) : tick;
422
- const getTickCount = (tickCount = TARGET_TICKS) =>
423
- isFiniteNumber(tickCount) ? mathMax(mathRound(tickCount), 1) : TARGET_TICKS;
424
- const getRounded = (value) => mathRound(value * 1e6) / 1e6;
736
+ const getContinuousXValue = (xValue, xScale, timestampUnit) =>
737
+ xScale == LINEAR
738
+ ? isNumber(xValue)
739
+ ? xValue
740
+ : void 0
741
+ : xScale == TIME
742
+ ? normalizeTimeValue(xValue, timestampUnit)
743
+ : void 0;
744
+ const getTime = (value) => {
745
+ const time = +dateNew(value);
746
+ return isFiniteNumber(time) ? mathFloor(time) : void 0;
747
+ };
425
748
  const getXValue = (cell) =>
426
749
  isNumber(cell)
427
750
  ? isFiniteNumber(cell)
@@ -435,14 +758,13 @@ const getXValue = (cell) =>
435
758
  const getYValue = (cell) =>
436
759
  isNumber(cell) && isFiniteNumber(cell) ? cell : void 0;
437
760
 
438
- const CURRENT_COLOR = 'currentColor';
439
-
440
761
  const Bars = ({
441
762
  points,
442
763
  plotFrame,
443
764
  barGap,
444
765
  barSeriesCount,
445
766
  barSeriesIndex,
767
+ fullBarWidth,
446
768
  setTooltipPoint,
447
769
  yMin = 0,
448
770
  yMax = 0,
@@ -450,10 +772,11 @@ const Bars = ({
450
772
  const [plotX, plotY, width, height] = plotFrame;
451
773
  const baselineY = height - getScale(0, yMin, yMax, height);
452
774
  const pointsSize = size(points);
453
- const fullBarWidth = arrayIsEmpty(points) ? 0 : width / pointsSize;
775
+ const resolvedFullBarWidth =
776
+ fullBarWidth ?? (arrayIsEmpty(points) ? 0 : width / pointsSize);
454
777
  const barCount = mathMax(barSeriesCount, 1);
455
778
  const barIndex = mathMax(barSeriesIndex, 0);
456
- const barGroupWidth = mathMax(fullBarWidth - barGap, 0);
779
+ const barGroupWidth = mathMax(resolvedFullBarWidth - barGap, 0);
457
780
  const barWidth = mathMax(
458
781
  (barGroupWidth - barGap * (barCount - 1)) / barCount,
459
782
  0,
@@ -476,44 +799,18 @@ const Bars = ({
476
799
  );
477
800
  });
478
801
  };
479
-
480
- const object = Object;
481
- const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
482
- const objEntries = object.entries;
483
- const isObject = (obj) =>
484
- !isNullish(obj) &&
485
- ifNotNullish(
486
- getPrototypeOf(obj),
487
- (objPrototype) =>
488
- objPrototype == object.prototype ||
489
- isNullish(getPrototypeOf(objPrototype)),
490
-
491
- /* istanbul ignore next */
492
- () => true,
493
- );
494
- const objIds = object.keys;
495
- const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
496
- const objValues = (obj) => object.values(obj);
497
- const objSize = (obj) => size(objIds(obj));
498
-
499
- /* istanbul ignore next */
500
- const objIsEqual = (
501
- obj1,
502
- obj2,
503
- isEqual = (value1, value2) => value1 === value2,
504
- ) => {
505
- const entries1 = objEntries(obj1);
506
- return (
507
- size(entries1) === objSize(obj2) &&
508
- arrayEvery(entries1, ([index, value1]) =>
509
- isObject(value1)
510
- ? /* istanbul ignore next */
511
- isObject(obj2[index])
512
- ? objIsEqual(obj2[index], value1, isEqual)
513
- : false
514
- : isEqual(value1, obj2[index]),
515
- )
802
+ const getContinuousBarWidth = (points, fallbackWidth) => {
803
+ const xs = arraySort(
804
+ arrayMap(points, ([, , , x]) => x),
805
+ (x1, x2) => x1 - x2,
516
806
  );
807
+ let barWidth = infinity;
808
+ arrayForEach(xs, (x, index) => {
809
+ if (index > 0 && x > xs[index - 1]) {
810
+ barWidth = mathMin(barWidth, x - xs[index - 1]);
811
+ }
812
+ });
813
+ return barWidth == infinity ? fallbackWidth : barWidth;
517
814
  };
518
815
 
519
816
  const jsonString = JSON.stringify;
@@ -706,7 +1003,6 @@ const useResultCellListener = (
706
1003
  [queryId, rowId, cellId],
707
1004
  );
708
1005
 
709
- const EMPTY_ID = '';
710
1006
  const useSeriesData = ({
711
1007
  descending,
712
1008
  limit,
@@ -731,7 +1027,7 @@ const useSeriesData = ({
731
1027
  const [seriesId] = useState(getSeriesId);
732
1028
  const handleChange = useCallback(() => rerender([]), [rerender]);
733
1029
  const tableRowIds = useSortedRowIds(
734
- tableId ?? EMPTY_ID,
1030
+ tableId ?? EMPTY_STRING,
735
1031
  sortCellId ?? xCellId,
736
1032
  descending,
737
1033
  offset,
@@ -739,7 +1035,7 @@ const useSeriesData = ({
739
1035
  storeOrStoreId,
740
1036
  );
741
1037
  const queryRowIds = useResultSortedRowIds(
742
- queryId ?? EMPTY_ID,
1038
+ queryId ?? EMPTY_STRING,
743
1039
  sortCellId ?? xCellId,
744
1040
  descending,
745
1041
  offset,
@@ -747,32 +1043,15 @@ const useSeriesData = ({
747
1043
  queriesOrQueriesId,
748
1044
  );
749
1045
  const rowIds = sourceType == SourceType.Table ? tableRowIds : queryRowIds;
750
- const points =
751
- yCellId == null
752
- ? []
753
- : getDataPoints(rowIds, (rowId) =>
754
- getDataPoint(
755
- rowId,
756
- getCell(
757
- sourceType,
758
- store,
759
- queries,
760
- tableId,
761
- queryId,
762
- rowId,
763
- xCellId,
764
- ),
765
- getCell(
766
- sourceType,
767
- store,
768
- queries,
769
- tableId,
770
- queryId,
771
- rowId,
772
- yCellId,
773
- ),
774
- ),
775
- );
1046
+ const points = isNullish(yCellId)
1047
+ ? []
1048
+ : getDataPoints(rowIds, (rowId) =>
1049
+ getDataPoint(
1050
+ rowId,
1051
+ getCell(sourceType, store, queries, tableId, queryId, rowId, xCellId),
1052
+ getCell(sourceType, store, queries, tableId, queryId, rowId, yCellId),
1053
+ ),
1054
+ );
776
1055
  useCellListener(
777
1056
  sourceType == SourceType.Table ? (tableId ?? null) : null,
778
1057
  null,
@@ -814,7 +1093,7 @@ const useSeriesData = ({
814
1093
  return [seriesId, points];
815
1094
  };
816
1095
  const getSeriesClassName = (baseClassName, className) =>
817
- className == null ? baseClassName : `${baseClassName} ${className}`;
1096
+ isNullish(className) ? baseClassName : `${baseClassName} ${className}`;
818
1097
  const getCell = (
819
1098
  sourceType,
820
1099
  store,
@@ -840,25 +1119,41 @@ const BarSeries = (props) => {
840
1119
  releaseBarSeries,
841
1120
  setSeriesSummary,
842
1121
  setTooltipPoint,
1122
+ timestampUnit,
1123
+ xScale,
843
1124
  xValues,
844
1125
  } = useCartesianChartContext();
845
1126
  const {className, label, xCellId, yCellId} = props;
846
1127
  const [seriesId, rawPoints] = useSeriesData(props);
847
1128
  const barSeriesIndex = getBarSeriesIndex(seriesId);
848
1129
  const [, , yMin, yMax] = bounds;
1130
+ const axisPoints =
1131
+ xScale == CATEGORY
1132
+ ? void 0
1133
+ : getScaledPoints(
1134
+ LINE,
1135
+ arrayMap(xValues, (xValue, index) => [`${index}`, xValue, 0]),
1136
+ bounds,
1137
+ plotSize,
1138
+ xValues,
1139
+ xScale,
1140
+ timestampUnit,
1141
+ );
849
1142
  const points = getScaledPoints(
850
- 'bar',
1143
+ BAR,
851
1144
  rawPoints,
852
1145
  bounds,
853
1146
  plotSize,
854
1147
  xValues,
1148
+ xScale,
1149
+ timestampUnit,
855
1150
  xCellId,
856
1151
  label ?? yCellId,
857
1152
  );
858
1153
  useLayoutEffect(() => {
859
1154
  setSeriesSummary(
860
1155
  seriesId,
861
- getSeriesSummary('bar', rawPoints, xCellId, yCellId, label),
1156
+ getSeriesSummary(BAR, rawPoints, xCellId, yCellId, label),
862
1157
  );
863
1158
  });
864
1159
  useLayoutEffect(() => {
@@ -872,6 +1167,9 @@ const BarSeries = (props) => {
872
1167
  barGap,
873
1168
  barSeriesCount,
874
1169
  barSeriesIndex,
1170
+ fullBarWidth: isNullish(axisPoints)
1171
+ ? void 0
1172
+ : getContinuousBarWidth(axisPoints, plotSize[0]),
875
1173
  plotFrame,
876
1174
  points,
877
1175
  setTooltipPoint,
@@ -882,6 +1180,28 @@ const BarSeries = (props) => {
882
1180
  };
883
1181
  BarSeries[SERIES] = true;
884
1182
 
1183
+ const getConvenienceChartProps = (props) => [
1184
+ isNullish(props.tableId)
1185
+ ? {
1186
+ className: props.className,
1187
+ queries: props.queries,
1188
+ queryId: props.queryId,
1189
+ }
1190
+ : {
1191
+ className: props.className,
1192
+ store: props.store,
1193
+ tableId: props.tableId,
1194
+ },
1195
+ {
1196
+ descending: props.descending,
1197
+ limit: props.limit,
1198
+ offset: props.offset,
1199
+ sortCellId: props.sortCellId,
1200
+ xCellId: props.xCellId,
1201
+ yCellId: props.yCellId,
1202
+ },
1203
+ ];
1204
+
885
1205
  const INTEGER = /^\d+$/;
886
1206
  const getPoolFunctions = () => {
887
1207
  const pool = [];
@@ -952,7 +1272,7 @@ const getPlotFrame = (
952
1272
  const getDefaultStyle = (fontSize) =>
953
1273
  arrayMap(DEFAULT_STYLE, (value) => value * fontSize);
954
1274
  const getStyle = (style) => {
955
- const fontSize = parseFloat(style?.fontSize ?? '');
1275
+ const fontSize = parseFloat(style?.fontSize ?? EMPTY_STRING);
956
1276
  return getDefaultStyle(
957
1277
  isFiniteNumber(fontSize) ? fontSize : DEFAULT_FONT_SIZE,
958
1278
  );
@@ -978,11 +1298,13 @@ const XAxis$1 = ({
978
1298
  tickGap,
979
1299
  axisHeight,
980
1300
  fontSize,
1301
+ timestampUnit,
1302
+ xScale,
981
1303
  }) => {
982
1304
  const [plotX, plotY, plotWidth, plotHeight] = plotFrame;
983
1305
  const titleGap = mathMax(axisHeight - tickSize - tickGap - 2 * fontSize, 0);
984
1306
  return /* @__PURE__ */ jsxs('g', {
985
- className: getAxisClassName$1('x', className),
1307
+ className: isNullish(className) ? 'x' : `x ${className}`,
986
1308
  dominantBaseline: 'hanging',
987
1309
  textAnchor: 'middle',
988
1310
  children: [
@@ -1004,7 +1326,12 @@ const XAxis$1 = ({
1004
1326
  {
1005
1327
  x: plotX + x,
1006
1328
  y: plotY + plotHeight + tickSize + tickGap,
1007
- children: getTickLabel(xValue, tickFormatter),
1329
+ children: getTickLabel(
1330
+ xValue,
1331
+ tickFormatter,
1332
+ xScale,
1333
+ timestampUnit,
1334
+ ),
1008
1335
  },
1009
1336
  rowId,
1010
1337
  ),
@@ -1016,7 +1343,13 @@ const XAxis$1 = ({
1016
1343
  {
1017
1344
  x: plotX + x,
1018
1345
  y: plotY + plotHeight + tickSize + tickGap,
1019
- children: getTickLabel(tick, tickFormatter),
1346
+ children: getTickLabel(
1347
+ tick,
1348
+ tickFormatter,
1349
+ xScale,
1350
+ MILLISECOND,
1351
+ xTicks,
1352
+ ),
1020
1353
  },
1021
1354
  tick,
1022
1355
  );
@@ -1031,10 +1364,20 @@ const XAxis$1 = ({
1031
1364
  ],
1032
1365
  });
1033
1366
  };
1034
- const getAxisClassName$1 = (baseClassName, className) =>
1035
- className == null ? baseClassName : `${baseClassName} ${className}`;
1036
- const getTickLabel = (tick, tickFormatter) =>
1037
- tickFormatter?.(tick) ?? string(tick);
1367
+ const getTickLabel = (
1368
+ tick,
1369
+ tickFormatter,
1370
+ xScale,
1371
+ timestampUnit,
1372
+ ticks = [],
1373
+ ) => {
1374
+ const timestamp =
1375
+ xScale == TIME ? normalizeTimeValue(tick, timestampUnit) : void 0;
1376
+ return isNumber(timestamp)
1377
+ ? (tickFormatter?.(dateNew(timestamp), timestamp) ??
1378
+ getTimeTickLabel(timestamp, ticks))
1379
+ : (tickFormatter?.(tick, void 0) ?? string(tick));
1380
+ };
1038
1381
 
1039
1382
  const YAxis$1 = ({
1040
1383
  className,
@@ -1052,7 +1395,7 @@ const YAxis$1 = ({
1052
1395
  return isNullish(yMin) || isNullish(yMax)
1053
1396
  ? null
1054
1397
  : /* @__PURE__ */ jsxs('g', {
1055
- className: getAxisClassName('y', className),
1398
+ className: isNullish(className) ? 'y' : `y ${className}`,
1056
1399
  children: [
1057
1400
  /* @__PURE__ */ jsx('path', {
1058
1401
  className: 'line',
@@ -1089,8 +1432,6 @@ const YAxis$1 = ({
1089
1432
  ],
1090
1433
  });
1091
1434
  };
1092
- const getAxisClassName = (baseClassName, className) =>
1093
- className == null ? baseClassName : `${baseClassName} ${className}`;
1094
1435
 
1095
1436
  const Axes = ({
1096
1437
  xAxis,
@@ -1103,6 +1444,8 @@ const Axes = ({
1103
1444
  xAxisHeight,
1104
1445
  yAxisWidth,
1105
1446
  fontSize,
1447
+ timestampUnit,
1448
+ xScale,
1106
1449
  ...sharedProps
1107
1450
  }) => {
1108
1451
  return /* @__PURE__ */ jsxs('g', {
@@ -1131,6 +1474,8 @@ const Axes = ({
1131
1474
  xTitle,
1132
1475
  axisHeight: xAxisHeight,
1133
1476
  fontSize,
1477
+ timestampUnit,
1478
+ xScale,
1134
1479
  }),
1135
1480
  ],
1136
1481
  });
@@ -1269,6 +1614,7 @@ const EMPTY_DOMAIN_STATE = {
1269
1614
  continuousX: false,
1270
1615
  xValues: [],
1271
1616
  };
1617
+ const TITLE_SEPARATOR = ' & ';
1272
1618
  const CartesianChart = ({
1273
1619
  children,
1274
1620
  className,
@@ -1286,17 +1632,15 @@ const CartesianChart = ({
1286
1632
  const labelSize = getLabelSize(layout);
1287
1633
  const storeObject = useStoreOrStoreById(store);
1288
1634
  const queriesObject = useQueriesOrQueriesById(queries);
1289
- const sourceType =
1290
- tableId == null
1291
- ? queryId == null
1292
- ? SourceType.None
1293
- : SourceType.Query
1294
- : SourceType.Table;
1295
- const initialSummaries = initialSummary == null ? {} : {0: initialSummary};
1296
- const initialDomainState =
1297
- initialSummary == null
1298
- ? EMPTY_DOMAIN_STATE
1299
- : getDomainState(objValues(initialSummaries));
1635
+ const sourceType = isNullish(tableId)
1636
+ ? isNullish(queryId)
1637
+ ? SourceType.None
1638
+ : SourceType.Query
1639
+ : SourceType.Table;
1640
+ const initialSummaries = isNullish(initialSummary) ? {} : {0: initialSummary};
1641
+ const initialDomainState = isNullish(initialSummary)
1642
+ ? EMPTY_DOMAIN_STATE
1643
+ : getDomainState(objValues(initialSummaries));
1300
1644
  const initialXTitle = getTitle(initialSummaries, 'xCellId');
1301
1645
  const initialYTitle = getTitle(initialSummaries, 'yCellId');
1302
1646
  const summariesRef = useRef(initialSummaries);
@@ -1313,26 +1657,61 @@ const CartesianChart = ({
1313
1657
  const [tooltipPoint, setTooltipPoint] = useState();
1314
1658
  const [chartChildren, xAxis, yAxis] = getParsedChildren(children);
1315
1659
  const xValues = domainState.xValues;
1316
- const numericX =
1317
- domainState.continuousX ||
1318
- (arrayIsEmpty(xValues) && hasNumericXAxisDefinition(xAxis));
1319
- const dataBounds = getAxisBounds(domainState.bounds, numericX, xAxis, yAxis);
1320
- const axisKind = numericX || arrayIsEmpty(barSeriesIds) ? 'line' : 'bar';
1660
+ const timestampUnit =
1661
+ xAxis?.scale == TIME && xAxis.timestampUnit == SECOND_UNIT
1662
+ ? SECOND_UNIT
1663
+ : MILLISECOND;
1664
+ const xScale = getResolvedXScale(
1665
+ xAxis?.scale,
1666
+ domainState,
1667
+ isFiniteNumber(xAxis?.min) ||
1668
+ isFiniteNumber(xAxis?.max) ||
1669
+ !isNullish(xAxis?.ticks),
1670
+ );
1671
+ const continuousX = xScale != CATEGORY;
1672
+ const dataBounds = getAxisBounds(
1673
+ domainState.bounds,
1674
+ xValues,
1675
+ xScale,
1676
+ timestampUnit,
1677
+ xAxis,
1678
+ yAxis,
1679
+ );
1680
+ const [dataXMin, dataXMax] = dataBounds;
1681
+ const axisKind = continuousX || arrayIsEmpty(barSeriesIds) ? LINE : BAR;
1321
1682
  const xTicks =
1322
- numericX && xAxis?.ticks != null
1323
- ? getAxisTicks(xAxis.ticks)
1324
- : getXTicks(axisKind, dataBounds, plotSize, labelSize, xAxis?.tickCount);
1325
- const yTicks =
1326
- yAxis?.ticks == null
1327
- ? getYTicks(dataBounds, plotSize, labelSize, yAxis?.tickCount)
1328
- : getAxisTicks(yAxis.ticks);
1683
+ continuousX && !isNullish(xAxis?.ticks)
1684
+ ? getAxisTicks(xAxis.ticks, xScale, timestampUnit)
1685
+ : xScale == TIME &&
1686
+ isNumber(dataXMin) &&
1687
+ isNumber(dataXMax) &&
1688
+ dataXMin != dataXMax
1689
+ ? getTimeTicks(
1690
+ dataXMin,
1691
+ dataXMax,
1692
+ getTickCount(xAxis?.tickCount),
1693
+ labelSize,
1694
+ plotSize[0],
1695
+ )
1696
+ : getXTicks(
1697
+ axisKind,
1698
+ dataBounds,
1699
+ plotSize,
1700
+ labelSize,
1701
+ xAxis?.tickCount,
1702
+ );
1703
+ const yTicks = isNullish(yAxis?.ticks)
1704
+ ? getYTicks(dataBounds, plotSize, labelSize, yAxis?.tickCount)
1705
+ : getAxisTicks(yAxis.ticks);
1329
1706
  const tickBounds = getTickBounds(dataBounds, xTicks, yTicks);
1330
1707
  const axisPoints = getScaledPoints(
1331
1708
  axisKind,
1332
- xValues.map((xValue, index) => [`${index}`, xValue, 0]),
1709
+ arrayMap(xValues, (xValue, index) => [`${index}`, xValue, 0]),
1333
1710
  tickBounds,
1334
1711
  plotSize,
1335
1712
  xValues,
1713
+ xScale,
1714
+ timestampUnit,
1336
1715
  );
1337
1716
  const setNextDomainState = useCallback((summaryById) => {
1338
1717
  const nextDomainState = getDomainState(objValues(summaryById));
@@ -1360,11 +1739,21 @@ const CartesianChart = ({
1360
1739
  }, []);
1361
1740
  const setIncrementalDomainState = useCallback((summary) => {
1362
1741
  const currentBounds = boundsRef.current;
1742
+ const [currentXMin, currentXMax, currentYMin, currentYMax] = currentBounds;
1743
+ const {xMin, xMax, yMin, yMax} = summary;
1363
1744
  const nextBounds = [
1364
- getMin(currentBounds[0], summary.xMin),
1365
- getMax(currentBounds[1], summary.xMax),
1366
- getNumberMin(currentBounds[2], summary.yMin),
1367
- getNumberMax(currentBounds[3], summary.yMax),
1745
+ isNumber(currentXMin) && isNumber(xMin)
1746
+ ? mathMin(currentXMin, xMin)
1747
+ : (currentXMin ?? xMin),
1748
+ isNumber(currentXMax) && isNumber(xMax)
1749
+ ? mathMax(currentXMax, xMax)
1750
+ : (currentXMax ?? xMax),
1751
+ isNullish(currentYMin) || isNullish(yMin)
1752
+ ? (currentYMin ?? yMin)
1753
+ : mathMin(currentYMin, yMin),
1754
+ isNullish(currentYMax) || isNullish(yMax)
1755
+ ? (currentYMax ?? yMax)
1756
+ : mathMax(currentYMax, yMax),
1368
1757
  ];
1369
1758
  if (!boundsAreEqual(currentBounds, nextBounds)) {
1370
1759
  boundsRef.current = nextBounds;
@@ -1380,8 +1769,8 @@ const CartesianChart = ({
1380
1769
  (seriesId, summary) => {
1381
1770
  const currentSummaries = summariesRef.current;
1382
1771
  const currentSummary = currentSummaries[seriesId];
1383
- if (summary == null) {
1384
- if (currentSummary == null) {
1772
+ if (isNullish(summary)) {
1773
+ if (isNullish(currentSummary)) {
1385
1774
  return;
1386
1775
  }
1387
1776
  delete currentSummaries[seriesId];
@@ -1392,9 +1781,10 @@ const CartesianChart = ({
1392
1781
  currentSummaries[seriesId] = summary;
1393
1782
  setNextTitles(currentSummaries);
1394
1783
  if (
1395
- currentSummary == null
1396
- ? addsXValues(summary.xValues, domainStateRef.current.xValues) ||
1397
- summary.continuousX != domainStateRef.current.continuousX
1784
+ isNullish(currentSummary)
1785
+ ? !arrayEvery(summary.xValues, (xValue) =>
1786
+ arrayHas(domainStateRef.current.xValues, xValue),
1787
+ ) || summary.continuousX != domainStateRef.current.continuousX
1398
1788
  : ownsBound(currentSummary, boundsRef.current) ||
1399
1789
  currentSummary.continuousX != summary.continuousX ||
1400
1790
  !arrayIsEqual(currentSummary.xValues, summary.xValues)
@@ -1459,7 +1849,9 @@ const CartesianChart = ({
1459
1849
  store: storeObject,
1460
1850
  storeOrStoreId: store,
1461
1851
  tableId,
1852
+ timestampUnit,
1462
1853
  xTicks,
1854
+ xScale,
1463
1855
  xValues,
1464
1856
  yTicks,
1465
1857
  }),
@@ -1482,8 +1874,10 @@ const CartesianChart = ({
1482
1874
  store,
1483
1875
  storeObject,
1484
1876
  tableId,
1877
+ timestampUnit,
1485
1878
  tickBounds,
1486
1879
  xTicks,
1880
+ xScale,
1487
1881
  xValues,
1488
1882
  yTicks,
1489
1883
  ],
@@ -1512,8 +1906,10 @@ const CartesianChart = ({
1512
1906
  tickGap,
1513
1907
  tickSize,
1514
1908
  titles: [xAxis?.title ?? xTitle, yAxis?.title ?? yTitle],
1909
+ timestampUnit,
1515
1910
  xAxis,
1516
1911
  xAxisHeight,
1912
+ xScale,
1517
1913
  xTicks,
1518
1914
  yAxis,
1519
1915
  yAxisWidth,
@@ -1544,31 +1940,6 @@ const ownsBound = (
1544
1940
  xMax === boundXMax ||
1545
1941
  yMin === boundYMin ||
1546
1942
  yMax === boundYMax;
1547
- const addsXValues = (xValues, currentXValues) => {
1548
- let adds = false;
1549
- arrayForEach(xValues, (xValue) => {
1550
- if (!arrayHas(currentXValues, xValue)) {
1551
- adds = true;
1552
- }
1553
- });
1554
- return adds;
1555
- };
1556
- const getMin = (value1, value2) =>
1557
- isNumber(value1) && isNumber(value2)
1558
- ? mathMin(value1, value2)
1559
- : (value1 ?? value2);
1560
- const getMax = (value1, value2) =>
1561
- isNumber(value1) && isNumber(value2)
1562
- ? mathMax(value1, value2)
1563
- : (value1 ?? value2);
1564
- const getNumberMin = (value1, value2) =>
1565
- value1 == null || value2 == null
1566
- ? (value1 ?? value2)
1567
- : mathMin(value1, value2);
1568
- const getNumberMax = (value1, value2) =>
1569
- value1 == null || value2 == null
1570
- ? (value1 ?? value2)
1571
- : mathMax(value1, value2);
1572
1943
  const getTitle = (summaryById, cellIdType) => {
1573
1944
  const titles = [];
1574
1945
  arrayForEach(objValues(summaryById), (summary) => {
@@ -1576,29 +1947,56 @@ const getTitle = (summaryById, cellIdType) => {
1576
1947
  cellIdType == 'yCellId'
1577
1948
  ? (summary.yLabel ?? summary.yCellId)
1578
1949
  : summary.xCellId;
1579
- if (title != null && !arrayHas(titles, title)) {
1950
+ if (!isNullish(title) && !arrayHas(titles, title)) {
1580
1951
  arrayPush(titles, title);
1581
1952
  }
1582
1953
  });
1583
- return arrayIsEmpty(titles) ? '' : titles.join(' & ');
1954
+ return arrayIsEmpty(titles) ? '' : arrayJoin(titles, TITLE_SEPARATOR);
1955
+ };
1956
+ const getAxisBounds = (
1957
+ [xMin, xMax, yMin, yMax],
1958
+ xValues,
1959
+ xScale,
1960
+ timestampUnit,
1961
+ xAxis,
1962
+ yAxis,
1963
+ ) => {
1964
+ const [xDomainMin, xDomainMax] = getXScaleDomain(
1965
+ [xMin, xMax],
1966
+ xValues,
1967
+ xScale,
1968
+ timestampUnit,
1969
+ );
1970
+ return [
1971
+ xScale == CATEGORY
1972
+ ? xDomainMin
1973
+ : getAxisBound(xAxis?.min, xDomainMin, xScale, timestampUnit),
1974
+ xScale == CATEGORY
1975
+ ? xDomainMax
1976
+ : getAxisBound(xAxis?.max, xDomainMax, xScale, timestampUnit),
1977
+ getNumberAxisBound(yAxis?.min, yMin),
1978
+ getNumberAxisBound(yAxis?.max, yMax),
1979
+ ];
1980
+ };
1981
+ const getAxisBound = (value, bound, xScale, timestampUnit) => {
1982
+ const axisBound =
1983
+ xScale == TIME ? normalizeTimeValue(value, timestampUnit) : value;
1984
+ return isFiniteNumber(axisBound) ? axisBound : bound;
1584
1985
  };
1585
- const getAxisBounds = ([xMin, xMax, yMin, yMax], numericX, xAxis, yAxis) => [
1586
- numericX ? getAxisBound(xAxis?.min, xMin) : xMin,
1587
- numericX ? getAxisBound(xAxis?.max, xMax) : xMax,
1588
- getNumberAxisBound(yAxis?.min, yMin),
1589
- getNumberAxisBound(yAxis?.max, yMax),
1590
- ];
1591
- const getAxisBound = (value, bound) => (isFiniteNumber(value) ? value : bound);
1592
1986
  const getNumberAxisBound = (value, bound) =>
1593
1987
  isFiniteNumber(value) ? value : bound;
1594
- const getAxisTicks = (ticks) =>
1595
- arraySort(arrayFilter([...ticks], isFiniteNumber), (tick1, tick2) => {
1596
- return tick1 - tick2;
1597
- });
1598
- const hasNumericXAxisDefinition = (xAxis) =>
1599
- isFiniteNumber(xAxis?.min) ||
1600
- isFiniteNumber(xAxis?.max) ||
1601
- xAxis?.ticks != null;
1988
+ const getAxisTicks = (ticks, xScale = LINEAR, timestampUnit = MILLISECOND) =>
1989
+ arraySort(
1990
+ arrayFilter(
1991
+ arrayMap([...ticks], (tick) =>
1992
+ xScale == TIME ? normalizeTimeValue(tick, timestampUnit) : tick,
1993
+ ),
1994
+ (tick) => isFiniteNumber(tick),
1995
+ ),
1996
+ (tick1, tick2) => {
1997
+ return tick1 - tick2;
1998
+ },
1999
+ );
1602
2000
  const getParsedChildren = (children) => {
1603
2001
  const chartChildren = [];
1604
2002
  let xAxis;
@@ -1616,9 +2014,9 @@ const getParsedChildren = (children) => {
1616
2014
  yAxis ??= childYAxis;
1617
2015
  } else if (isSeriesComponent(child.type)) {
1618
2016
  arrayPush(chartChildren, child);
1619
- } else if (xAxis == null && isXAxisComponent(child.type)) {
2017
+ } else if (isNullish(xAxis) && isXAxisComponent(child.type)) {
1620
2018
  xAxis = child.props;
1621
- } else if (yAxis == null && isYAxisComponent(child.type)) {
2019
+ } else if (isNullish(yAxis) && isYAxisComponent(child.type)) {
1622
2020
  yAxis = child.props;
1623
2021
  }
1624
2022
  }
@@ -1644,38 +2042,45 @@ const useInitialSeriesSummary = (
1644
2042
  const storeObject = useStoreOrStoreById(store);
1645
2043
  const queriesObject = useQueriesOrQueriesById(queries);
1646
2044
  return useMemo(() => {
1647
- const points =
1648
- tableId == null
1649
- ? getDataPoints(
1650
- queriesObject?.getResultSortedRowIds(
1651
- queryId ?? '',
1652
- sortCellId ?? xCellId,
1653
- descending,
1654
- offset,
1655
- limit,
1656
- ) ?? [],
1657
- (rowId) =>
1658
- getDataPoint(
2045
+ const points = isNullish(tableId)
2046
+ ? getDataPoints(
2047
+ queriesObject?.getResultSortedRowIds(
2048
+ queryId ?? EMPTY_STRING,
2049
+ sortCellId ?? xCellId,
2050
+ descending,
2051
+ offset,
2052
+ limit,
2053
+ ) ?? [],
2054
+ (rowId) =>
2055
+ getDataPoint(
2056
+ rowId,
2057
+ queriesObject?.getResultCell(
2058
+ queryId ?? EMPTY_STRING,
1659
2059
  rowId,
1660
- queriesObject?.getResultCell(queryId ?? '', rowId, xCellId),
1661
- queriesObject?.getResultCell(queryId ?? '', rowId, yCellId),
2060
+ xCellId,
1662
2061
  ),
1663
- )
1664
- : getDataPoints(
1665
- storeObject?.getSortedRowIds(
1666
- tableId,
1667
- sortCellId ?? xCellId,
1668
- descending,
1669
- offset,
1670
- limit,
1671
- ) ?? [],
1672
- (rowId) =>
1673
- getDataPoint(
2062
+ queriesObject?.getResultCell(
2063
+ queryId ?? EMPTY_STRING,
1674
2064
  rowId,
1675
- storeObject?.getCell(tableId, rowId, xCellId),
1676
- storeObject?.getCell(tableId, rowId, yCellId),
2065
+ yCellId,
1677
2066
  ),
1678
- );
2067
+ ),
2068
+ )
2069
+ : getDataPoints(
2070
+ storeObject?.getSortedRowIds(
2071
+ tableId,
2072
+ sortCellId ?? xCellId,
2073
+ descending,
2074
+ offset,
2075
+ limit,
2076
+ ) ?? [],
2077
+ (rowId) =>
2078
+ getDataPoint(
2079
+ rowId,
2080
+ storeObject?.getCell(tableId, rowId, xCellId),
2081
+ storeObject?.getCell(tableId, rowId, yCellId),
2082
+ ),
2083
+ );
1679
2084
  return getSeriesSummary(kind, points, xCellId, yCellId);
1680
2085
  }, [
1681
2086
  descending,
@@ -1692,37 +2097,15 @@ const useInitialSeriesSummary = (
1692
2097
  ]);
1693
2098
  };
1694
2099
 
1695
- const BarChart = (props) => {
1696
- const initialSummary = useInitialSeriesSummary('bar', props);
1697
- return /* @__PURE__ */ jsx(CartesianChart, {
1698
- ...getSourceProps$1(props),
2100
+ const BarChart = ({children, ...props}) => {
2101
+ const initialSummary = useInitialSeriesSummary(BAR, props);
2102
+ const [sourceProps, seriesProps] = getConvenienceChartProps(props);
2103
+ return /* @__PURE__ */ jsxs(CartesianChart, {
2104
+ ...sourceProps,
1699
2105
  initialSummary,
1700
- children: /* @__PURE__ */ jsx(BarSeries, {...getSeriesProps$1(props)}),
2106
+ children: [/* @__PURE__ */ jsx(BarSeries, {...seriesProps}), children],
1701
2107
  });
1702
2108
  };
1703
- const getSourceProps$1 = (props) =>
1704
- props.tableId == null
1705
- ? {
1706
- className: props.className,
1707
- queries: props.queries,
1708
- queryId: props.queryId,
1709
- }
1710
- : {className: props.className, store: props.store, tableId: props.tableId};
1711
- const getSeriesProps$1 = ({
1712
- descending,
1713
- limit,
1714
- offset,
1715
- sortCellId,
1716
- xCellId,
1717
- yCellId,
1718
- }) => ({
1719
- descending,
1720
- limit,
1721
- offset,
1722
- sortCellId,
1723
- xCellId,
1724
- yCellId,
1725
- });
1726
2109
 
1727
2110
  const Line = ({plotFrame, points, setTooltipPoint}) => {
1728
2111
  const [plotX, plotY, , height] = plotFrame;
@@ -1782,28 +2165,31 @@ const LineSeries = (props) => {
1782
2165
  const {
1783
2166
  barSeriesCount,
1784
2167
  bounds,
1785
- domainState,
1786
2168
  plotFrame,
1787
2169
  plotSize,
1788
2170
  setSeriesSummary,
1789
2171
  setTooltipPoint,
2172
+ timestampUnit,
2173
+ xScale,
1790
2174
  xValues,
1791
2175
  } = useCartesianChartContext();
1792
2176
  const {className, label, xCellId, yCellId} = props;
1793
2177
  const [seriesId, rawPoints] = useSeriesData(props);
1794
2178
  const points = getScaledPoints(
1795
- domainState.continuousX || barSeriesCount == 0 ? 'line' : 'bar',
2179
+ xScale != CATEGORY || !barSeriesCount ? LINE : BAR,
1796
2180
  rawPoints,
1797
2181
  bounds,
1798
2182
  plotSize,
1799
2183
  xValues,
2184
+ xScale,
2185
+ timestampUnit,
1800
2186
  xCellId,
1801
2187
  label ?? yCellId,
1802
2188
  );
1803
2189
  useLayoutEffect(() => {
1804
2190
  setSeriesSummary(
1805
2191
  seriesId,
1806
- getSeriesSummary('line', rawPoints, xCellId, yCellId, label),
2192
+ getSeriesSummary(LINE, rawPoints, xCellId, yCellId, label),
1807
2193
  );
1808
2194
  });
1809
2195
  return /* @__PURE__ */ jsx('g', {
@@ -1817,37 +2203,15 @@ const LineSeries = (props) => {
1817
2203
  };
1818
2204
  LineSeries[SERIES] = true;
1819
2205
 
1820
- const LineChart = (props) => {
1821
- const initialSummary = useInitialSeriesSummary('line', props);
1822
- return /* @__PURE__ */ jsx(CartesianChart, {
1823
- ...getSourceProps(props),
2206
+ const LineChart = ({children, ...props}) => {
2207
+ const initialSummary = useInitialSeriesSummary(LINE, props);
2208
+ const [sourceProps, seriesProps] = getConvenienceChartProps(props);
2209
+ return /* @__PURE__ */ jsxs(CartesianChart, {
2210
+ ...sourceProps,
1824
2211
  initialSummary,
1825
- children: /* @__PURE__ */ jsx(LineSeries, {...getSeriesProps(props)}),
2212
+ children: [/* @__PURE__ */ jsx(LineSeries, {...seriesProps}), children],
1826
2213
  });
1827
2214
  };
1828
- const getSourceProps = (props) =>
1829
- props.tableId == null
1830
- ? {
1831
- className: props.className,
1832
- queries: props.queries,
1833
- queryId: props.queryId,
1834
- }
1835
- : {className: props.className, store: props.store, tableId: props.tableId};
1836
- const getSeriesProps = ({
1837
- descending,
1838
- limit,
1839
- offset,
1840
- sortCellId,
1841
- xCellId,
1842
- yCellId,
1843
- }) => ({
1844
- descending,
1845
- limit,
1846
- offset,
1847
- sortCellId,
1848
- xCellId,
1849
- yCellId,
1850
- });
1851
2215
 
1852
2216
  const XAxis = () => null;
1853
2217
  XAxis[X_AXIS] = true;