Menu

Scatter (html)Edit

1980
1985
1990
1995
2000
2005
2010
2015
4
5
6
7
<script>
  import { LayerCake, Html } from 'layercake';

  import Scatter from './components/Scatter.html.svelte';
  import AxisX from './components/AxisX.html.svelte';
  import AxisY from './components/AxisY.html.svelte';

  import data from './data/points.csv';

  const xKey = 'myX';
  const yKey = 'myY';

  data.forEach(d => {
    d[yKey] = +d[yKey];
  });

  const r = 4.5;
  const padding = 2.5;
  const fill = '#fff';
  const stroke = '#0cf';
  const strokeWidth = 1.5;
</script>

<style>
  .chart-container {
    width: 100%;
    height: 100%;
  }
</style>

<div class="chart-container">
  <LayerCake
    ssr={true}
    percentRange={true}
    padding={{ top: 10, right: 5, bottom: 20, left: 25 }}
    x={xKey}
    y={yKey}
    xPadding={[padding, padding]}
    yPadding={[padding, padding]}
    data={data}
  >

    <Html>
      <AxisX/>
      <AxisY/>
      <Scatter
        {r}
        {fill}
        {stroke}
        {strokeWidth}
      />
    </Html>

  </LayerCake>
</div>