Skip to content

Fix/axis types #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 18, 2025
Prev Previous commit
Next Next commit
fix more import declarations
  • Loading branch information
gka committed Jun 18, 2025
commit cdb82d0fea8b6fba6349c37079e92f72d5dac809
8 changes: 4 additions & 4 deletions src/lib/helpers/autoTimeFormat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Scale } from '$lib/classes/Scale.svelte.js';
import { isDate } from '$lib/helpers/typeChecks';
import type { PlotScale } from '$lib/types/index.js';
import { isDate } from '$lib/helpers/typeChecks.js';

const DATE_TIME: Intl.DateTimeFormatOptions = {
hour: 'numeric',
Expand Down Expand Up @@ -32,9 +32,9 @@ const autoFormatMonthYear = (locale: string) => {
return (date: Date) => format(date).replace(' ', '\n');
};

export default function autoTimeFormat(x: Scale, plotWidth: number, plotLocale: string) {
export default function autoTimeFormat(x: PlotScale, plotWidth: number, plotLocale: string) {
const daysPer100Px =
((toNumber(x.domain[1]) - toNumber(x.domain[0])) / plotWidth / 864e5) * 100;
((toNumber(x.domain[1] as Date) - toNumber(x.domain[0] as Date)) / plotWidth / 864e5) * 100;
const format =
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using inline as Date casts on x.domain, consider parameterizing PlotScale with a Date generic (e.g., PlotScale<Date>) to avoid type assertions and improve type safety.

Copilot uses AI. Check for mistakes.

daysPer100Px < 1
? autoFormatDateTime(plotLocale)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/group.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { groupFacetsAndZ } from './group';
import { groupFacetsAndZ } from './group.js';
import { describe, it, expect } from 'vitest';

describe('groupFacetsAndZ', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { coalesce, isObject, omit } from './index';
import { coalesce, isObject, omit } from './index.js';
import { describe, it, expect } from 'vitest';

describe('coalesce', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/marks/Area.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
ChannelAccessor,
ScaledDataRecord,
LinkableMarkProps,
PlotDefaults
PlotDefaults,
RawValue
} from '../types/index.js';
import type { RawValue } from 'svelteplot/types/index.js';
import type { StackOptions } from '$lib/transforms/stack.js';

let markProps: AreaMarkProps = $props();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/DifferenceY.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
PlotContext,
PlotDefaults
} from 'svelteplot/types/index.js';
import { Line, Area } from '$lib/marks';
import { Line, Area } from '$lib/marks/index.js';
import { randomId, coalesce } from '$lib/helpers/index.js';
import { getContext } from 'svelte';
import { extent, max, min } from 'd3-array';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/Geo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import { geoPath } from 'd3-geo';
import { resolveChannel, resolveProp, resolveStyles } from '$lib/helpers/resolve.js';
import callWithProps from '$lib/helpers/callWithProps.js';
import { sort } from '$lib/transforms';
import { sort } from '$lib/transforms/index.js';
import { addEventHandlers } from './helpers/events.js';
import GeoCanvas from './helpers/GeoCanvas.svelte';
import { recordize } from '$lib/transforms/recordize.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/RectX.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { intervalY, stackX, recordizeX } from 'svelteplot';
import type { DataRecord, PlotContext, PlotDefaults } from '../types/index.js';
import { getContext, type ComponentProps } from 'svelte';
import type { StackOptions } from '$lib/transforms/stack';
import type { StackOptions } from '$lib/transforms/stack.js';

let markProps: RectXMarkProps = $props();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/RectY.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { intervalX, stackY, recordizeY } from 'svelteplot';
import type { DataRecord, PlotContext, PlotDefaults } from '../types/index.js';
import { getContext, type ComponentProps } from 'svelte';
import type { StackOptions } from '$lib/transforms/stack';
import type { StackOptions } from '$lib/transforms/stack.js';

let markProps: RectYMarkProps = $props();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/Anchor.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { resolveProp } from '$lib/helpers/resolve';
import { resolveProp } from '$lib/helpers/resolve.js';

let { datum = {}, options = {}, children } = $props();

Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/AreaCanvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import CanvasLayer from './CanvasLayer.svelte';
import type { Attachment } from 'svelte/attachments';
import { devicePixelRatio } from 'svelte/reactivity/window';
import { resolveColor } from './canvas';
import { resolveColor } from './canvas.js';

let {
mark,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/DotCanvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import CanvasLayer from './CanvasLayer.svelte';
import { getContext } from 'svelte';
import { devicePixelRatio } from 'svelte/reactivity/window';
import { resolveColor } from './canvas';
import { resolveColor } from './canvas.js';

const { getPlotState } = getContext<PlotContext>('svelteplot');
const plot = $derived(getPlotState());
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/LineCanvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import CanvasLayer from './CanvasLayer.svelte';
import type { Attachment } from 'svelte/attachments';
import { devicePixelRatio } from 'svelte/reactivity/window';
import { resolveColor } from './canvas';
import { resolveColor } from './canvas.js';

let {
mark,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/RectPath.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Helper component for rendering rectangular marks in SVG
PlotContext,
DataRecord
} from 'svelteplot';
import { addEventHandlers } from './events';
import { addEventHandlers } from './events.js';
import { getContext } from 'svelte';
import Anchor from './Anchor.svelte';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/Regression.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import { resolveChannel } from '$lib/helpers/resolve.js';
import { confidenceInterval } from '$lib/helpers/math.js';
import callWithProps from '$lib/helpers/callWithProps.js';
import { isDate } from '$lib/helpers/typeChecks';
import { isDate } from '$lib/helpers/typeChecks.js';

const regressions = new Map<RegressionType, typeof regressionLinear>([
['linear', regressionLinear],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/bollinger.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { bollingerX, bollingerY } from './bollinger.js';
import type { TransformArg } from '../src/lib/types';
import type { TransformArg } from '../src/lib/types/index.js';

describe('bollinger transform', () => {
const mockData = [
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ScaleOptions,
XScaleOptions,
YScaleOptions
} from '.';
} from './index.js';
import type { Snippet } from 'svelte';

import type {
Expand Down Expand Up @@ -50,7 +50,7 @@ import type {
TickX,
TickY,
Vector
} from '../marks';
} from '../marks/index.js';

export type PlotState = {
width: number;
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy