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 ts imports
  • Loading branch information
gka committed Jun 18, 2025
commit 62fb6e46703872d013c90ca837fc1f11802fb2ae
2 changes: 1 addition & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ScaleName, ScaleType, ScaledChannelName } from './types.js';
import type { ScaleName, ScaleType, ScaledChannelName } from './types/index.js';

export const SCALE_TYPES: Record<ScaleName, symbol> = {
opacity: Symbol('opacity'),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/autoScales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
ScaleName,
ScaleOptions,
ScaleType
} from '../types.js';
} from '../types/index.js';
import {
categoricalSchemes,
isCategoricalScheme,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/autoTicks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RawValue, ScaleType } from '$lib/types.js';
import type { RawValue, ScaleType } from '$lib/types/index.js';
import { maybeTimeInterval } from './time.js';
import { extent, range as rangei } from 'd3-array';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/callWithProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RawValue } from '$lib/types.js';
import type { RawValue } from '$lib/types/index.js';

type Setter = (v: any) => void;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import {
} from 'd3-scale-chromatic';

import { quantize } from 'd3-interpolate';
import type { ColorScheme } from '$lib/types.js';
import type { ColorScheme } from '$lib/types/index.js';

const schemeObservable10 = [
'#4269d0',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/curves.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Curve } from '../types.js';
import type { Curve } from '../types/index.js';
import {
curveBasis,
curveBasisClosed,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/facets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GenericMarkOptions, Mark, RawValue } from '$lib/types.js';
import type { GenericMarkOptions, Mark, RawValue } from '$lib/types/index.js';
import { resolveChannel } from './resolve.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/lib/helpers/getBaseStyles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Channels } from '$lib/types.js';
import type { MarkStyleProps, DataRow } from '$lib/types.js';
import type { Channels } from '$lib/types/index.js';
import type { MarkStyleProps, DataRow } from '$lib/types/index.js';
import { resolveProp } from './resolve.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/group.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { ChannelName, Channels, DataRecord } from '$lib/types.js';
import type { ChannelName, Channels, DataRecord } from '$lib/types/index.js';
import { groups as d3Groups } from 'd3-array';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChannelAccessor, ChannelName, DataRecord, RawValue } from '$lib/types.js';
import type { ChannelAccessor, ChannelName, DataRecord, RawValue } from '$lib/types/index.js';
import type { Snippet } from 'svelte';
import { resolveProp } from './resolve.js';
import { isDate } from '$lib/helpers/typeChecks.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/isDataRecord.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DataRecord } from '../types.js';
import type { DataRecord } from '../types/index.js';

export default function (value: any): value is DataRecord {
if (typeof value !== 'object' || value === null) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/isRawValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RawValue } from '$lib/types.js';
import type { RawValue } from '$lib/types/index.js';
import { isDate } from '$lib/helpers/typeChecks.js';

export default function (value: any): value is RawValue {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/reduce.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { reduceOutputs, type ReducerName } from './reduce.js';
import type { ChannelAccessor, ChannelName } from '$lib/types.js';
import type { ChannelAccessor, ChannelName } from '$lib/types/index.js';

describe('reduceOutputs', () => {
it('should correctly reduce outputs', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/reduce.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChannelName, Channels, DataRecord, DataRow, RawValue } from '$lib/types.js';
import type { ChannelName, Channels, DataRecord, DataRow, RawValue } from '$lib/types/index.js';
import { min, max, mode, sum, mean, median, variance, deviation, quantile } from 'd3-array';
import { resolveChannel } from './resolve.js';
import { POSITION_CHANNELS } from './index.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/regressionLoess.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DataRow } from '$lib/types.js';
import type { DataRow } from '$lib/types/index.js';
import Loess from 'loess';

type AccessorFn = (d: any) => number;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/helpers/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CHANNEL_SCALE } from '$lib/constants.js';
import isDataRecord from '$lib/helpers/isDataRecord.js';
import isRawValue from '$lib/helpers/isRawValue.js';
import type { MarkStyleProps, PlotState, ScaledDataRecord } from '$lib/types.js';
import type { MarkStyleProps, PlotState, ScaledDataRecord } from '$lib/types/index.js';
import { isValid } from './isValid.js';

import type {
Expand All @@ -13,7 +13,7 @@ import type {
RawValue,
DataRecord,
ConstantAccessor
} from '../types.js';
} from '../types/index.js';
import { getBaseStylesObject } from './getBaseStyles.js';
import { RAW_VALUE } from 'svelteplot/transforms/recordize.js';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/scales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
ScaleType,
ScaledChannelName,
UsedScales
} from '../types.js';
} from '../types/index.js';
import isDataRecord from './isDataRecord.js';

import { createProjection } from './projection.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/typeChecks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RawValue } from '$lib/types.js';
import type { RawValue } from '$lib/types/index.js';
import { isSymbol } from './symbols.js';
import { color } from 'd3-color';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/marks/helpers/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BaseMarkProps, DataRecord, PlotScale, PlotState } from '$lib/types.js';
import type { BaseMarkProps, DataRecord, PlotScale, PlotState } from '$lib/types/index.js';
import type { MouseEventHandler } from 'svelte/elements';
import { pick } from 'es-toolkit';
import { RAW_VALUE } from '$lib/transforms/recordize.js';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/transforms/bin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { DataRecord, RawValue } from '$lib/types.js';
import type { TransformArg } from '$lib/types.js';
import type { DataRecord, RawValue } from '$lib/types/index.js';
import type { TransformArg } from '$lib/types/index.js';
import { maybeInterval } from '$lib/helpers/autoTicks.js';
import {
bin as d3Bin,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/bollinger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { DataRecord, TransformArg } from '$lib/types.js';
import type { DataRecord, TransformArg } from '$lib/types/index.js';

export type BollingerOptions = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/centroid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolveProp } from '$lib/helpers/resolve.js';
import type { DataRecord, TransformArg } from '$lib/types.js';
import type { DataRecord, TransformArg } from '$lib/types/index.js';
import { geoCentroid as d3GeoCentroid } from 'd3-geo';
import type { Channels } from 'svelteplot/types';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/facet.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import type { DataRecord, TransformArg } from '$lib/types.js';
import type { DataRecord, TransformArg } from '$lib/types/index.js';
2 changes: 1 addition & 1 deletion src/lib/transforms/filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testFilter } from '$lib/helpers/index.js';
import type { DataRecord, TransformArg } from '$lib/types.js';
import type { DataRecord, TransformArg } from '$lib/types/index.js';

export function filter({ data, ...channels }: TransformArg<DataRecord>): TransformArg<DataRecord> {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/group.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { group, groupX, groupY, groupZ } from './group.js';
import type { DataRecord } from '$lib/types.js';
import type { DataRecord } from '$lib/types/index.js';
import { csvParse } from 'd3-dsv';
import { readFileSync } from 'fs';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { groupFacetsAndZ } from '$lib/helpers/group.js';
import { testFilter } from '$lib/helpers/index.js';
import { reduceOutputs, type ReducerName } from '$lib/helpers/reduce.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { DataRecord, DataRow, RawValue, TransformArg } from '$lib/types.js';
import type { DataRecord, DataRow, RawValue, TransformArg } from '$lib/types/index.js';
import { groups as d3Groups } from 'd3-array';
import { omit } from '$lib/helpers/index.js';
import { maybeInterval } from '$lib/helpers/autoTicks.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/interval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { maybeInterval } from '$lib/helpers/autoTicks.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { PlotState, TransformArg } from '$lib/types.js';
import type { PlotState, TransformArg } from '$lib/types/index.js';

export function intervalX<T>(args: TransformArg<T>, { plot }: { plot: PlotState }) {
return interval('x', plot, args);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/jitter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Channels, DataRecord, TransformArg } from '$lib/types.js';
import type { Channels, DataRecord, TransformArg } from '$lib/types/index.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import { randomUniform, randomNormal } from 'd3-random';
import { isDate } from '$lib/helpers/typeChecks.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
MapMethod,
DataRecord,
Channels
} from '$lib/types.js';
} from '$lib/types/index.js';
import { count, rank } from 'd3-array';
import { groupFacetsAndZ } from '$lib/helpers/group.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mapX, mapY } from './map.js';
import type { TransformArg, RawValue, MapIndexObject } from '$lib/types.js';
import type { TransformArg, RawValue, MapIndexObject } from '$lib/types/index.js';
import { min, max, mean, median, sum, deviation, extent } from 'd3-array';

type NormalizeBasis =
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/recordize.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { recordizeXY, RAW_VALUE } from './recordize.js';
import type { RawValue } from '$lib/types.js';
import type { RawValue } from '$lib/types/index.js';

const coordsArray: [RawValue, RawValue][] = [
[0, 4],
Expand Down
7 changes: 6 additions & 1 deletion src/lib/transforms/recordize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import isDataRecord from '$lib/helpers/isDataRecord.js';
import type { DataRecord, TransformArgsRow, TransformArgsRecord, RawValue } from '$lib/types.js';
import type {
DataRecord,
TransformArgsRow,
TransformArgsRecord,
RawValue
} from '$lib/types/index.js';

export const INDEX = Symbol('index');
export const RAW_VALUE = Symbol('originalValue');
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/rename.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { renameChannels } from './rename.js';
import type { DataRecord } from '$lib/types.js';
import type { DataRecord } from '$lib/types/index.js';

const inputData: DataRecord[] = [
{ year: 2000, facet: 'A', value: 10 },
Expand Down
4 changes: 2 additions & 2 deletions src/lib/transforms/rename.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DataRecord } from '$lib/types.js';
import type { ScaledChannelName, TransformArg } from '$lib/types.js';
import type { DataRecord } from '$lib/types/index.js';
import type { ScaledChannelName, TransformArg } from '$lib/types/index.js';

type RenameChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName>>;
type ReplaceChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName[]>>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/select.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { groupFacetsAndZ } from '$lib/helpers/group.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { ChannelName, DataRecord, TransformArg } from '$lib/types.js';
import type { ChannelName, DataRecord, TransformArg } from '$lib/types/index.js';

type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> & U[keyof U];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/shift.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { shiftX, shiftY } from './shift.js';
import type { DataRecord } from '$lib/types.js';
import type { DataRecord } from '$lib/types/index.js';

describe('shiftX', () => {
it('should shift the x values by a number', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/shift.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolveChannel } from '$lib/helpers/resolve.js';
import { maybeTimeInterval } from '$lib/helpers/time.js';
import type { DataRecord, TransformArg } from '$lib/types.js';
import type { DataRecord, TransformArg } from '$lib/types/index.js';

type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/sort.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { sort, shuffle } from './sort.js';
import type { DataRecord } from '$lib/types.js';
import type { DataRecord } from '$lib/types/index.js';

const data: DataRecord[] = [
{ A: 1, B: 7 },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/sort.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isDataRecord from '$lib/helpers/isDataRecord.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { DataRecord, DataRow, TransformArg } from '$lib/types.js';
import type { DataRecord, DataRow, TransformArg } from '$lib/types/index.js';
import { shuffler } from 'd3-array';
import { randomLcg } from 'd3-random';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
DataRecord,
TransformArg,
ChannelName
} from '$lib/types.js';
} from '$lib/types/index.js';
import {
stack,
stackOffsetExpand,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transforms/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { maybeInterval } from '$lib/helpers/autoTicks.js';
import { isValid } from '$lib/helpers/index.js';
import { mayberReducer, type ReducerName } from '$lib/helpers/reduce.js';
import { resolveChannel } from '$lib/helpers/resolve.js';
import type { DataRecord, ScaledChannelName, TransformArg } from '$lib/types.js';
import type { DataRecord, ScaledChannelName, TransformArg } from '$lib/types/index.js';
import { groups as d3Groups } from 'd3-array';

type WindowOptions = {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/features/markers/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Note that for the interpolation methods `basis`, `bundle`, and `step`, the marke
import { Plot, LineY, Dot } from 'svelteplot';
import Slider from '$lib/ui/Slider.svelte';
import Select from '$lib/ui/Select.svelte';
import type { CurveName } from '$lib/types.js';
import type { CurveName } from '$lib/types/index.js';

// curve demo
const numbers = [
Expand Down Expand Up @@ -134,7 +134,7 @@ You can also specify a custom marker icon using the `marker` snippet:
```svelte live
<script lang="ts">
import { Plot, Line } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand Down
6 changes: 3 additions & 3 deletions src/routes/marks/line/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ If the **x** and **y** options are not defined, the line mark assumes that the d
```svelte live
<script lang="ts">
import { Plot, Line, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand Down Expand Up @@ -243,7 +243,7 @@ BLS Demo:
```svelte live
<script lang="ts">
import { Plot, Line, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { bls } = $derived(page.data.data);
Expand Down Expand Up @@ -335,7 +335,7 @@ The [LineY constructor](/marks/line#LineY) provides default channel definitions
```svelte live
<script lang="ts">
import { Plot, LineY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';
import { randomNormal } from 'd3-random';
import { range, cumsum } from 'd3-array';
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/marks/rule/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Like most other marks, rules also accept data for displaying multiple lines at o
```svelte live
<script lang="ts">
import { Plot, Line, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tests/demos/bls/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BLS Demo:
```svelte live
<script lang="ts">
import { Plot, Line, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { bls } = $derived(page.data.data);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/transforms/interval/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ In contrast, a [rectY](/marks/rect) mark with the interval option and the day in
```svelte live
<script lang="ts">
import { Plot, RectY, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand Down Expand Up @@ -74,7 +74,7 @@ The meaning of the interval mark option depends on the associated mark, such as
```svelte live
<script lang="ts">
import { Plot, BarY, RuleY } from 'svelteplot';
import type { Datasets } from '$lib/types.js';
import type { Datasets } from '$lib/types/index.js';

import { page } from '$app/state';
let { aapl } = $derived(page.data.data);
Expand Down
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