Skip to content

some chart stylings to match the old version #351

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 6 commits into from
Feb 10, 2025
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
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"clsx": "^2.1.1",
"d3": "^7.9.0",
"dotenv": "^16.4.7",
"layerchart": "^0.93.9",
"layerchart": "^0.95.0",
"lodash": "^4.17.21",
"tailwind-merge": "^2.6.0",
"tailwind-variants": "^0.3.0"
Expand Down
22 changes: 20 additions & 2 deletions frontend/src/lib/components/charts/FeaturesLineChart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@
};
})}
padding={{ left: 24, bottom: 48 }}
legend={{ placement: 'bottom-left', classes: { root: 'right-0 overflow-auto scrollbar-none' } }}
legend={{
placement: 'bottom-left',
classes: {
root: 'right-0 overflow-auto scrollbar-none',
swatch: 'h-2 w-2 rounded-full',
label: 'text-sm',
item: () => 'flex items-center gap-2'
}
}}
renderContext="canvas"
{...lineChartProps}
{...restProps}
brush={{ onbrushend }}
tooltip={{ hideDelay: 150 }}
>
<svelte:fragment slot="aboveMarks" let:xScale let:yScale>
{#if markPoint}
Expand All @@ -72,7 +81,14 @@
{/if}
</svelte:fragment>

<svelte:fragment slot="tooltip" let:x let:y let:height let:visibleSeries>
<svelte:fragment
slot="tooltip"
let:x
let:y
let:height
let:visibleSeries
let:setHighlightSeriesKey
>
<Tooltip.Root {...tooltipProps.root} x="data" y={height + 24} pointerEvents let:data>
<Tooltip.Header {...tooltipProps.header}>
{formatDate(x(data))}
Expand All @@ -87,6 +103,8 @@
<button
class="col-span-full grid grid-cols-[1fr,auto] gap-6 hover:bg-neutral-400 py-2 px-3 rounded"
onclick={() => onitemclick?.({ series: s, data: seriesTooltipData, value })}
onmouseenter={() => setHighlightSeriesKey(s.key)}
onmouseleave={() => setHighlightSeriesKey(null)}
>
<Tooltip.Item
label={s.label ?? (s.key !== 'default' ? s.key : 'value')}
Expand Down
24 changes: 22 additions & 2 deletions frontend/src/lib/components/charts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ export const colors = [
'#CB5587'
];

export const xAxisProps = {
placement: 'bottom' as const,
classes: {
tickLabel: 'fill-neutral-700 text-xs'
}
};

export const yAxisProps = {
placement: 'left' as const,
classes: {
tickLabel: 'fill-neutral-700 text-xs'
}
};

export const tooltipProps = {
root: {
variant: 'none',
Expand All @@ -44,7 +58,11 @@ export const tooltipProps = {
} satisfies NonNullable<ComponentProps<typeof LineChart>['props']>['tooltip'];

export const highlightProps = {
motion: false
motion: false,
points: {
r: 8,
strokeWidth: 4
}
} satisfies NonNullable<ComponentProps<typeof LineChart>['props']>['highlight'];

export const barChartProps = {
Expand All @@ -60,7 +78,9 @@ export const lineChartProps = {
},
props: {
tooltip: tooltipProps,
highlight: highlightProps
highlight: highlightProps,
xAxis: xAxisProps,
yAxis: yAxisProps
}
} satisfies NonNullable<ComponentProps<typeof LineChart>>;

Expand Down