layerchart 0.99.5 → 1.0.1

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.
@@ -124,7 +124,10 @@
124
124
 
125
125
  /** Provide initial `0` horizontal baseline and initially hide/untrack scale changes so not reactive (only set on initial mount) */
126
126
  function defaultPathData() {
127
- if (pathData) {
127
+ if (!tweenedOptions) {
128
+ // If not tweened, return empty string (faster initial render)
129
+ return '';
130
+ } else if (pathData) {
128
131
  // Flatten all `y` coordinates of pre-defined `pathData`
129
132
  return flattenPathData(pathData, Math.min($yScale(0), $yRange[0]));
130
133
  } else if ($config.x) {
@@ -52,6 +52,10 @@
52
52
  export let value: Accessor<TData> = 'value';
53
53
  $: valueAccessor = accessor(value);
54
54
 
55
+ /** Color accessor*/
56
+ export let c: Accessor<TData> = key;
57
+ $: cAccessor = accessor(c);
58
+
55
59
  /** Maximum possible value, useful when `data` is single item */
56
60
  export let maxValue: number | undefined = undefined;
57
61
 
@@ -169,18 +173,20 @@
169
173
  data={visibleData}
170
174
  x={value}
171
175
  y={key}
172
- c={key}
176
+ {c}
173
177
  cDomain={chartData.map(keyAccessor)}
174
178
  cRange={seriesColors.length
175
179
  ? seriesColors
176
- : [
177
- 'hsl(var(--color-primary))',
178
- 'hsl(var(--color-secondary))',
179
- 'hsl(var(--color-info))',
180
- 'hsl(var(--color-success))',
181
- 'hsl(var(--color-warning))',
182
- 'hsl(var(--color-danger))',
183
- ]}
180
+ : c !== key
181
+ ? chartData.map((d) => cAccessor(d))
182
+ : [
183
+ 'hsl(var(--color-primary))',
184
+ 'hsl(var(--color-secondary))',
185
+ 'hsl(var(--color-info))',
186
+ 'hsl(var(--color-success))',
187
+ 'hsl(var(--color-warning))',
188
+ 'hsl(var(--color-danger))',
189
+ ]}
184
190
  padding={{ bottom: legend === true ? 32 : 0 }}
185
191
  {...$$restProps}
186
192
  tooltip={props.tooltip?.context}
@@ -118,19 +118,17 @@
118
118
  activeCanvas = true;
119
119
  const component = getPointerComponent(e);
120
120
 
121
- if (lastActiveComponent == null) {
122
- // TODO: Should these be handled differently
121
+ if (component != lastActiveComponent) {
122
+ // TODO: Should `pointerleave`/`pointerout` and `pointerenter`/`pointerover` be handled differently?
123
+ if (lastActiveComponent) {
124
+ lastActiveComponent.events?.pointerleave?.(e);
125
+ lastActiveComponent.events?.pointerout?.(e);
126
+ }
127
+
123
128
  component?.events?.pointerenter?.(e);
124
129
  component?.events?.pointerover?.(e);
125
- } else if (lastActiveComponent != component) {
126
- // TODO: Should these be handled differently
127
- lastActiveComponent?.events?.pointerleave?.(e);
128
- lastActiveComponent?.events?.pointerout?.(e);
129
-
130
- component?.events?.pointermove?.(e);
131
- } else {
132
- component?.events?.pointermove?.(e);
133
130
  }
131
+ component?.events?.pointermove?.(e);
134
132
 
135
133
  lastActiveComponent = component;
136
134
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.99.5",
7
+ "version": "1.0.1",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.28.1",
10
10
  "@mdi/js": "^7.4.47",