Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<script lang="ts">
import {
Bar,
Axis,
Chart,
Highlight,
Layer,
Tooltip,
defaultChartPadding,
groupStackData
} from 'layerchart';
import { fruitColors } from '$lib/utils/fruitColors';
import { scaleBand } from 'd3-scale';
import { sum } from 'd3-array';
import { Bar, Axis, Chart, Highlight, Layer, Tooltip, groupStackData } from 'layerchart';
import GroupedStackedComboControls from '$lib/components/controls/BarsControls.svelte';
import { longData } from '$lib/utils/data.js';
import { unique } from '@layerstack/utils';
import { cubicInOut } from 'svelte/easing';

const colorKeys = [...new Set(longData.map((x) => x.fruit))];
const keyColors = [
'var(--color-info)',
'var(--color-success)',
'var(--color-warning)',
'var(--color-danger)'
];

let chartMode = $state<'group' | 'stack' | 'groupStack'>('group');

Expand Down Expand Up @@ -63,12 +67,12 @@
yScale={scaleBand().paddingInner(0.2).paddingOuter(0.1)}
c="fruit"
cDomain={colorKeys}
cRange={keyColors}
cRange={fruitColors}
y1={groupBy}
y1Scale={groupBy ? scaleBand().padding(0.1) : undefined}
y1Domain={groupBy ? unique(data.map((d) => d[groupBy])) : undefined}
y1Range={({ yScale }) => [0, yScale.bandwidth()]}
padding={{ left: 32, bottom: 20, right: 8 }}
padding={{ ...defaultChartPadding, left: 30, right: 15, bottom: 20 }}
tooltip={{ mode: 'band' }}
height={400}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<script lang="ts">
import {
Bar,
Axis,
Chart,
Layer,
Tooltip,
defaultChartPadding,
groupStackData
} from 'layerchart';
import { fruitColors } from '$lib/utils/fruitColors';
import { scaleBand } from 'd3-scale';
import { Bar, Axis, Chart, Layer, Tooltip, groupStackData } from 'layerchart';
import GroupedStackedComboControls from '$lib/components/controls/BarsControls.svelte';
import { longData } from '$lib/utils/data.js';
import { unique } from '@layerstack/utils';
import { cubicInOut } from 'svelte/easing';

const colorKeys = [...new Set(longData.map((x) => x.fruit))];
const keyColors = [
'var(--color-info)',
'var(--color-success)',
'var(--color-warning)',
'var(--color-danger)'
];

let chartMode = $state<'group' | 'stack' | 'groupStack'>('group');

Expand Down Expand Up @@ -63,12 +66,12 @@
yScale={scaleBand().paddingInner(0.2).paddingOuter(0.1)}
c="fruit"
cDomain={colorKeys}
cRange={keyColors}
cRange={fruitColors}
y1={groupBy}
y1Scale={groupBy ? scaleBand().padding(0.1) : undefined}
y1Domain={groupBy ? unique(data.map((d) => d[groupBy])) : undefined}
y1Range={({ yScale }) => [0, yScale.bandwidth()]}
padding={{ left: 32, bottom: 20, right: 8 }}
padding={{ ...defaultChartPadding, left: 30, right: 15, bottom: 20 }}
height={400}
>
{#snippet children({ context })}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<script lang="ts">
import {
Axis,
Bar,
Chart,
Layer,
Tooltip,
defaultChartPadding,
groupStackData
} from 'layerchart';
import { fruitColors } from '$lib/utils/fruitColors';
import { scaleBand } from 'd3-scale';
import { Axis, Bar, Chart, Layer, Tooltip, groupStackData } from 'layerchart';
import { longData } from '$lib/utils/data.js';
import { cubicInOut } from 'svelte/easing';
import { unique } from '@layerstack/utils';
import GroupedStackedComboField from '$lib/components/controls/fields/GroupedStackedComboField.svelte';

const colorKeys = [...new Set(longData.map((x) => x.fruit))];
const keyColors = [
'var(--color-info)',
'var(--color-success)',
'var(--color-warning)',
'var(--color-danger)'
];

let chartMode = $state<'group' | 'stack' | 'groupStack'>('group');

Expand Down Expand Up @@ -63,7 +66,7 @@
yNice
c="fruit"
cDomain={colorKeys}
cRange={keyColors}
cRange={fruitColors}
x1={groupBy}
x1Scale={groupBy ? scaleBand().padding(0.1) : undefined}
x1Domain={groupBy ? unique(data.map((d) => d[groupBy])) : undefined}
Expand Down
Loading