Skip to content

[BarChart] Support fixed width bars #360

@techniq

Description

@techniq

Currently you can use this workaround

<BarChart {data} x="date" y="value">
  <svelte:fragment slot="marks" let:xScale>
    {@const barWidth = 10}
    {@const xShift = xScale.bandwidth() / 2 - barWidth / 2}
    <Group x={xShift}>
      <Bars radius={5} strokeWidth={0} width={barWidth} />
    </Group>
  </svelte:fragment>
</BarChart>
<BarChart {data} x="date" y="value">
  {#snippet marks({ context })}
    {@const barWidth = 10}
    {@const xShift = context.xScale.bandwidth() / 2 - barWidth / 2}
    <Group x={xShift}>
      <Bars radius={5} strokeWidth={0} width={barWidth} />
    </Group>
  {/snippet}
</BarChart>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions