-
-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hello and thanks for providing such a crafty library.
I set up layerchart by way of shadcn-svelte and followed the instructions at: https://next.layerchart.com, but I am having an issue customising labels.
Version: "layerchart": "^2.0.0-next.27"
A simple dataset:
const data = [
{ macro: 'Proteins', current: 100, target: 200 },
{ macro: 'Carbs', current: 230, target: 200 }
];I would like to display labels only for the "current" keys. And this was my failed attempt:
<BarChart
{data}
y="macro"
axis={false}
c="macro"
cDomain={["Proteins", "Carbs"]}
cRange={["var(--color-macro-proteins)", "var(--color-macro-carbs)"]}
orientation="horizontal"
series={[
{
key: 'target',
props: { fillOpacity: 0.2 }
},
{
key: 'current',
props: { insets: { y: 8 } }
}
]}
renderContext="svg"
>
{#snippet labels({ visibleSeries, getLabelsProps })}
{@const currentSeries = visibleSeries.filter(s => s.key === 'current')}
{#each currentSeries as s, i}
<Labels {...getLabelsProps(s, i)} placement="inside" fill="white" class="text-base" />
{/each}
{/snippet}
</BarChart>The code above yields:
The goal is to elide the 200 in the first bar. Is this my issue or one with the library?
Metadata
Metadata
Assignees
Labels
No labels