layerchart 2.0.0-next.42 → 2.0.0-next.43

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.
@@ -251,7 +251,7 @@
251
251
  const ctx = getChartContext();
252
252
 
253
253
  const endAngle = $derived(
254
- endAngleProp ?? degreesToRadians(ctx.config.xRange ? max(ctx.xRange) : max(range))
254
+ endAngleProp ?? degreesToRadians(ctx.xRange ? max(ctx.xRange) : max(range))
255
255
  );
256
256
 
257
257
  const motionEndAngle = createMotion(initialValue, () => value, motion);
@@ -125,15 +125,7 @@
125
125
 
126
126
  import { extent } from 'd3-array';
127
127
  import { pointRadial } from 'd3-shape';
128
- import {
129
- timeDay,
130
- timeHour,
131
- timeMillisecond,
132
- timeMinute,
133
- timeMonth,
134
- timeSecond,
135
- timeYear,
136
- } from 'd3-time';
128
+ import { timeDay, timeHour, timeMillisecond, timeMinute, timeSecond, timeYear } from 'd3-time';
137
129
 
138
130
  import { type FormatType, type FormatConfig, unique, PeriodType } from '@layerstack/utils';
139
131
  import { cls } from '@layerstack/tailwind';
@@ -55,7 +55,7 @@
55
55
 
56
56
  <script lang="ts">
57
57
  import { type ComponentProps, type Snippet } from 'svelte';
58
- import { timeDays, timeMonths, timeWeek, timeYear } from 'd3-time';
58
+ import { timeDays, timeMonths, timeWeek } from 'd3-time';
59
59
  import { index } from 'd3-array';
60
60
  import { format } from '@layerstack/utils';
61
61
 
@@ -264,6 +264,11 @@
264
264
  tmpArea.width = max(xCoord) - min(xCoord); // Use first/last values for width
265
265
  } else if (isScaleBand(ctx.xScale)) {
266
266
  tmpArea.width = ctx.xScale.step();
267
+ } else if (ctx.xInterval) {
268
+ // x-axis time scale with interval
269
+ const start = ctx.xInterval.floor(xValue);
270
+ const end = ctx.xInterval.offset(start);
271
+ tmpArea.width = ctx.xScale(end) - ctx.xScale(start);
267
272
  } else {
268
273
  // Find width to next data point
269
274
  const index = ctx.flatData.findIndex((d) => Number(x(d)) === Number(x(highlightData)));
@@ -290,6 +295,11 @@
290
295
  tmpArea.height = max(yCoord) - min(yCoord); // Use first/last values for width
291
296
  } else if (isScaleBand(ctx.yScale)) {
292
297
  tmpArea.height = ctx.yScale.step();
298
+ } else if (ctx.yInterval) {
299
+ // y-axis time scale with interval
300
+ const start = ctx.yInterval.floor(yValue);
301
+ const end = ctx.yInterval.offset(start);
302
+ tmpArea.height = ctx.yScale(end) - ctx.yScale(start);
293
303
  } else {
294
304
  // Find width to next data point
295
305
  const index = ctx.flatData.findIndex((d) => Number(y(d)) === Number(y(highlightData)));
@@ -35,7 +35,7 @@
35
35
  </script>
36
36
 
37
37
  <script lang="ts">
38
- import { timeWeek, timeYear } from 'd3-time';
38
+ import { timeWeek } from 'd3-time';
39
39
  import { cls } from '@layerstack/tailwind';
40
40
  import { endOfInterval } from '@layerstack/utils';
41
41
  import Spline, { type SplinePropsWithoutHTML } from './Spline.svelte';
@@ -518,6 +518,32 @@
518
518
  height: ctx.yScale.step(),
519
519
  data: d,
520
520
  };
521
+ } else if (ctx.xInterval) {
522
+ // x-axis time scale with interval
523
+ const xVal = ctx.x(d);
524
+ const start = ctx.xInterval.floor(xVal);
525
+ const end = ctx.xInterval.offset(start);
526
+
527
+ return {
528
+ x: ctx.xScale(start),
529
+ y: isScaleBand(ctx.yScale) ? y - yOffset : min(ctx.yRange),
530
+ width: ctx.xScale(end) - ctx.xScale(start),
531
+ height: isScaleBand(ctx.yScale) ? ctx.yScale.step() : fullHeight,
532
+ data: d,
533
+ };
534
+ } else if (ctx.yInterval) {
535
+ // y-axis time scale with interval
536
+ const yVal = ctx.y(d);
537
+ const start = ctx.yInterval.floor(yVal);
538
+ const end = ctx.yInterval.offset(start);
539
+
540
+ return {
541
+ x: isScaleBand(ctx.xScale) ? x - xOffset : min(ctx.xRange),
542
+ y: ctx.yScale(start),
543
+ width: isScaleBand(ctx.xScale) ? ctx.xScale.step() : fullWidth,
544
+ height: ctx.yScale(end) - ctx.yScale(start),
545
+ data: d,
546
+ };
521
547
  } else if (isScaleTime(ctx.xScale)) {
522
548
  // Find width to next data point
523
549
  const index = ctx.flatData.findIndex(
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { ComponentProps } from 'svelte';
3
3
  import { Button, Dialog, Toggle, Tooltip } from 'svelte-ux';
4
- import LucideGithub from '~icons/lucide/github.svelte';
4
+ import LucideGithub from '~icons/lucide/github';
5
5
 
6
6
  import Code from './Code.svelte';
7
7
 
@@ -1,4 +1,4 @@
1
- import { timeYear, timeMonth, timeDay, timeTicks } from 'd3-time';
1
+ import { timeYear, timeDay, timeTicks } from 'd3-time';
2
2
  import { format, Duration, isLiteralObject, DateToken, } from '@layerstack/utils';
3
3
  import { isScaleBand, isScaleTime } from './scales.svelte.js';
4
4
  export function getDurationFormat(duration, options = {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
7
  "homepage": "https://layerchart.com",
8
- "version": "2.0.0-next.42",
8
+ "version": "2.0.0-next.43",
9
9
  "devDependencies": {
10
10
  "@changesets/cli": "^2.29.6",
11
11
  "@iconify-json/lucide": "^1.2.62",