Column annotated
1979
1980
1981
1982
1983
0
5
10
15
Example text...
Since we want an ordinal x-axis and Layer Cake defaults to a linear scale, pass in a custom scale to xScale
with a few formatting options. Set the y-scale to always start at 0
so you don't show misleading differences between groups.
Since it's tricky to server-side render circles in SVG, this example uses a second <LayerCake>
component for the arrow, which renders client-side and uses the position='absolute'
prop to make sure the two cakes are super-imposed on one another.
For the annotation arrowhead, note that you may need to provide an explicit link to your SVG marker id, such as in ./_components/Arrows.svelte
using window.location.href
.
- +page.svelte
- ./_components/Column.svelte
- ./_components/AxisX.percent-range.html.svelte
- ./_components/AxisY.percent-range.html.svelte
- ./_components/AnnotationsData.html.svelte
- ./_components/Arrows.svelte
- ./_components/ArrowheadMarker.svelte
- ./_modules/arrowUtils.js
- ./_data/groups.csv
<script>
import { LayerCake, Svg, ScaledSvg, Html } from 'layercake';
import { scaleBand } from 'd3-scale';
import Column from './_components/Column.svelte';
import AxisX from './_components/AxisX.percent-range.html.svelte';
import AxisY from './_components/AxisY.percent-range.html.svelte';
import Annotations from './_components/AnnotationsData.html.svelte';
import Arrows from './_components/Arrows.svelte';
import ArrowheadMarker from './_components/ArrowheadMarker.svelte';
// This example loads csv data as json using @rollup/plugin-dsv
import data from './_data/groups.csv';
const xKey = 'year';
const yKey = 'value';
const annotations = [
{
text: 'Example text...',
[xKey]: '1980',
[yKey]: 14,
dx: 15, // Optional pixel values
dy: -5,
arrows: [
{
clockwise: false, // true or false, defaults to true
source: {
anchor: 'left-bottom', // can be `{left, middle, right},{top-middle-bottom}`
dx: -2,
dy: -7
},
target: {
// These can be expressed in our data units if passed under the data keys
[xKey]: '1980',
[yKey]: 4.5,
// Optional adjustments
dx: 2,
dy: 5
}
},
{
source: {
anchor: 'right-bottom',
dy: -7,
dx: 5
},
target: {
// Or if they are percentage strings they can be passed directly
x: '68%',
y: '48%'
}
}
]
}
];
data.forEach(d => {
d[yKey] = +d[yKey];
});
</script>
<div class="chart-container">
<LayerCake
ssr
percentRange
position="absolute"
padding={{ top: 0, right: 0, bottom: 20, left: 20 }}
x={xKey}
y={yKey}
xScale={scaleBand().paddingInner(0.028).round(true)}
xDomain={['1979', '1980', '1981', '1982', '1983']}
yDomain={[0, null]}
{data}
>
<ScaledSvg>
<Column />
</ScaledSvg>
<Html>
<AxisX gridlines={false} />
<AxisY gridlines={false} snapBaselineLabel />
<Annotations {annotations} />
</Html>
</LayerCake>
<!--
Add a second cake for the arrows that is rendered once the page is loaded
since the arrows are hard to draw within the viewbox
-->
<LayerCake
position="absolute"
padding={{ top: 0, right: 0, bottom: 20, left: 20 }}
x={xKey}
y={yKey}
xScale={scaleBand().paddingInner(0.028).round(true)}
xDomain={['1979', '1980', '1981', '1982', '1983']}
yDomain={[0, null]}
{data}
>
<Svg>
{#snippet defs()}
<ArrowheadMarker />
{/snippet}
<Arrows {annotations} />
</Svg>
</LayerCake>
</div>
<style>
.chart-container {
width: 100%;
height: 400px;
position: relative;
}
</style>
<!--
@component
Generates an SVG column chart.
-->
<script>
import { getContext } from 'svelte';
const { data, xGet, yGet, x, yRange, xScale, y, height } = getContext('LayerCake');
/**
* @typedef {Object} Props
* @property {string} [fill='#00e047'] - The shape's fill color.
* @property {string} [stroke='#000'] - The shape's stroke color.
* @property {number} [strokeWidth=0] - The shape's stroke width.
* @property {boolean} [showLabels=false] - Show the numbers for each column
*/
/** @type {Props} */
let { fill = '#00e047', stroke = '#000', strokeWidth = 0, showLabels = false } = $props();
let columnWidth = $derived(d => {
const vals = $xGet(d);
return Math.abs(vals[1] - vals[0]);
});
let columnHeight = $derived(d => {
return $yRange[0] - $yGet(d);
});
</script>
<g class="column-group">
{#each $data as d, i}
{@const colHeight = columnHeight(d)}
{@const xGot = $xGet(d)}
{@const xPos = Array.isArray(xGot) ? xGot[0] : xGot}
{@const colWidth = $xScale.bandwidth ? $xScale.bandwidth() : columnWidth(d)}
{@const yValue = $y(d)}
<rect
class="group-rect"
data-id={i}
data-range={$x(d)}
data-count={yValue}
x={xPos}
y={$yGet(d)}
width={colWidth}
height={colHeight}
{fill}
{stroke}
stroke-width={strokeWidth}
/>
{#if showLabels && yValue}
<text x={xPos + colWidth / 2} y={$height - colHeight - 5} text-anchor="middle">{yValue}</text>
{/if}
{/each}
</g>
<style>
text {
font-size: 12px;
}
</style>
<!--
@component
Generates an HTML x-axis, useful for server-side rendered charts. This component is also configured to detect if your x-scale is an ordinal scale. If so, it will place the markers in the middle of the bandwidth.
Although this is marked as a percent-range component, you can also use it with a normal scale with no configuration needed. By default, if you have `percentRange={true}` it will use percentages, otherwise it will use pixels. This makes this component compatible with server-side and client-side rendered charts. Set the `units` prop to either `'%'` or `'px'` to override the default behavior.
-->
<script>
import { getContext } from 'svelte';
const { xScale, percentRange } = getContext('LayerCake');
/**
* @typedef {Object} Props
* @property {boolean} [tickMarks=false] - Show a vertical mark for each tick.
* @property {boolean} [gridlines=true] - Show gridlines extending into the chart area.
* @property {number} [tickMarkLength=6] - The length of the tick mark.
* @property {boolean} [baseline=false] - Show a solid line at the bottom.
* @property {boolean} [snapLabels=false] - Instead of centering the text labels on the first and the last items, align them to the edges of the chart.
* @property {(d: any) => string} [format=d => d] - A function that passes the current tick value and expects a nicely formatted value in return.
* @property {number|Array<any>|Function} [ticks] - If this is a number, it passes that along to the [d3Scale.ticks](https://github.com/d3/d3-scale) function. If this is an array, hardcodes the ticks to those values. If it's a function, passes along the default tick values and expects an array of tick values in return. If nothing, it uses the default ticks supplied by the D3 function.
* @property {number} [tickGutter=0] - The amount of whitespace between the start of the tick and the chart drawing area (the yRange min).
* @property {number} [dx=0] - Any optional value passed to the `dx` attribute on the text label.
* @property {number} [dy=0] - Any optional value passed to the `dy` attribute on the text label.
* @property {'px'|'%'} units - Whether this component should use percentage or pixel values. If `percentRange={true}` it defaults to `'%'`. Options: `'%'` or `'px'`.
*/
/** @type {Props} */
let {
tickMarks = false,
gridlines = true,
tickMarkLength = 6,
baseline = false,
snapLabels = false,
format = d => d,
ticks = undefined,
tickGutter = 0,
dx = 0,
dy = 0,
units = $percentRange === true ? '%' : 'px'
} = $props();
let tickLen = $derived(tickMarks === true ? (tickMarkLength ?? 6) : 0);
let isBandwidth = $derived(typeof $xScale.bandwidth === 'function');
/** @type {Array<any>} */
let tickVals = $derived(
Array.isArray(ticks)
? ticks
: isBandwidth
? $xScale.domain()
: typeof ticks === 'function'
? ticks($xScale.ticks())
: $xScale.ticks(ticks)
);
let halfBand = $derived(isBandwidth ? $xScale.bandwidth() / 2 : 0);
</script>
<div class="axis x-axis" class:snapLabels>
{#each tickVals as tick, i (tick)}
{@const tickValUnits = $xScale(tick)}
{#if baseline === true}
<div class="baseline" style="top:100%; width:100%;"></div>
{/if}
{#if gridlines === true}
<div class="gridline" style:left="{tickValUnits}{units}" style="top:0; bottom:0;"></div>
{/if}
{#if tickMarks === true}
<div
class="tick-mark"
style:left="{tickValUnits + halfBand}{units}"
style:height="{tickLen}px"
style:bottom="{-tickLen - tickGutter}px"
></div>
{/if}
<div
class="tick tick-{i}"
style:left="{tickValUnits + halfBand}{units}"
style="top:calc(100% + {tickGutter}px);"
>
<div
class="text"
style:top="{tickLen}px"
style:transform="translate(calc(-50% + {dx}px), {dy}px)"
>
{format(tick)}
</div>
</div>
{/each}
</div>
<style>
.axis,
.tick,
.tick-mark,
.gridline,
.baseline {
position: absolute;
}
.axis {
width: 100%;
height: 100%;
}
.tick {
font-size: 11px;
}
.gridline {
border-left: 1px dashed #aaa;
}
.tick-mark {
border-left: 1px solid #aaa;
}
.baseline {
border-top: 1px solid #aaa;
}
.tick .text {
color: #666;
position: relative;
white-space: nowrap;
transform: translateX(-50%);
}
/* This looks a little better at 40 percent than 50 */
.axis.snapLabels .tick:last-child {
transform: translateX(-40%);
}
.axis.snapLabels .tick.tick-0 {
transform: translateX(40%);
}
</style>
<!--
@component
Generates an HTML y-axis. This component is also configured to detect if your y-scale is an ordinal scale. If so, it will place the tickMarks in the middle of the bandwidth.
Although this is marked as a percent-range component, you can also use it with a normal scale with no configuration needed. By default, if you have `percentRange={true}` it will use percentages, otherwise it will use pixels. This makes this component compatible with server-side and client-side rendered charts. Set the `units` prop to either `'%'` or `'px'` to override the default behavior.
-->
<script>
import { getContext } from 'svelte';
const { xRange, yScale, percentRange } = getContext('LayerCake');
/**
* @typedef {Object} Props
* @property {boolean} [tickMarks=false] - Show marks next to the tick label.
* @property {string} [labelPosition='even'] - Whether the label sits even with its value ('even') or sits on top ('above') the tick mark. Default is 'even'.
* @property {boolean} [snapBaselineLabel=false] - When labelPosition='even', adjust the lowest label so that it sits above the tick mark.
* @property {boolean} [gridlines=true] - Show gridlines extending into the chart area.
* @property {number} [tickMarkLength] - The length of the tick mark. If not set, becomes the length of the widest tick.
* @property {(d: any) => string} [format=d => d] - A function that passes the current tick value and expects a nicely formatted value in return.
* @property {number|Array<any>|Function} [ticks=4] - If this is a number, it passes that along to the [d3Scale.ticks](https://github.com/d3/d3-scale) function. If this is an array, hardcodes the ticks to those values. If it's a function, passes along the default tick values and expects an array of tick values in return.
* @property {number} [tickGutter=0] - The amount of whitespace between the start of the tick and the chart drawing area (the xRange min).
* @property {number} [dx=0] - Any optional value passed to the `dx` attribute on the text label.
* @property {number} [dy=-3] - Any optional value passed to the `dy` attribute on the text label.
* @property {number} [charPixelWidth=7.25] - Used to calculate the widest label length to offset labels. Adjust if the automatic tick length doesn't look right because you have a bigger font (or just set `tickMarkLength` to a pixel value).
* @property {'px'|'%'} units - Whether this component should use percentage or pixel values. If `percentRange={true}` it defaults to `'%'`. Options: `'%'` or `'px'`.
*/
/** @type {Props} */
let {
tickMarks = false,
labelPosition = 'even',
snapBaselineLabel = false,
gridlines = true,
tickMarkLength = undefined,
format = d => d,
ticks = 4,
tickGutter = 0,
dx = 0,
dy = -3,
charPixelWidth = 7.25,
units = $percentRange === true ? '%' : 'px'
} = $props();
/** @param {number} sum
* @param {string} val */
function calcStringLength(sum, val) {
if (val === ',' || val === '.') return sum + charPixelWidth * 0.5;
return sum + charPixelWidth;
}
let isBandwidth = $derived(typeof $yScale.bandwidth === 'function');
/** @type {Array<any>} */
let tickVals = $derived(
Array.isArray(ticks)
? ticks
: isBandwidth
? $yScale.domain()
: typeof ticks === 'function'
? ticks($yScale.ticks())
: $yScale.ticks(ticks)
);
let widestTickLen = $derived(
Math.max(
10,
Math.max(...tickVals.map(d => format(d).toString().split('').reduce(calcStringLength, 0)))
)
);
let tickLen = $derived(
tickMarks === true
? labelPosition === 'above'
? (tickMarkLength ?? widestTickLen)
: (tickMarkLength ?? 6)
: 0
);
let x1 = $derived(-tickGutter - (labelPosition === 'above' ? widestTickLen : tickLen));
let halfBand = $derived(isBandwidth ? $yScale.bandwidth() / 2 : 0);
let maxTickValUnits = $derived(Math.max(...tickVals.map($yScale)));
</script>
<div class="axis y-axis">
{#each tickVals as tick, i (tick)}
{@const tickValUnits = $yScale(tick)}
<div
class="tick tick-{i}"
style="left:{$xRange[0]}{units};top:{tickValUnits + halfBand}{units};"
>
{#if gridlines === true}
<div class="gridline" style="top:0;" style:left="{x1}px" style:right="0px"></div>
{/if}
{#if tickMarks === true}
<div class="tick-mark" style:top="0" style:left="{x1}px" style:width="{tickLen}px"></div>
{/if}
<div
class="text"
style:top="0"
style:text-align={labelPosition === 'even' ? 'right' : 'left'}
style:width="{widestTickLen}px"
style:left="{-widestTickLen - tickGutter - (labelPosition === 'even' ? tickLen : 0)}px"
style:transform="translate({dx + (labelPosition === 'even' ? -3 : 0)}px, calc(-50% + {dy +
(labelPosition === 'above' ||
(snapBaselineLabel === true && tickValUnits === maxTickValUnits)
? -3
: 4)}px))"
>
{format(tick)}
</div>
</div>
{/each}
</div>
<style>
.axis,
.tick,
.tick-mark,
.gridline,
.baseline,
.text {
position: absolute;
}
.axis {
width: 100%;
height: 100%;
}
.tick {
font-size: 11px;
width: 100%;
}
.gridline {
border-top: 1px dashed #aaa;
}
.tick-mark {
border-top: 1px solid #aaa;
}
.baseline.gridline {
border-top-style: solid;
}
.tick .text {
color: #666;
}
</style>
<!--
@component
Adds text annotations that get their x and y placement using the `xScale` and `yScale`.
-->
<script>
import { getContext } from 'svelte';
const { xGet, yGet, percentRange } = getContext('LayerCake');
/**
* @typedef {Object} ArrowSource
* @property {string} anchor - Anchor position, format: `{left|middle|right}-{top|middle|bottom}`
* @property {number} [dx] - Optional horizontal pixel offset
* @property {number} [dy] - Optional vertical pixel offset
*/
/**
* @typedef {Object} ArrowTarget
* @property {string|number} [x] - X position (can be percentage string like "68%" or data value)
* @property {string|number} [y] - Y position (can be percentage string like "48%" or data value)
* @property {number} [dx] - Optional horizontal pixel offset
* @property {number} [dy] - Optional vertical pixel offset
*/
/**
* @typedef {Object} Arrow
* @property {boolean} [clockwise=true] - Direction of arrow curve
* @property {ArrowSource} source - Arrow starting point configuration
* @property {ArrowTarget} target - Arrow ending point configuration
*/
/**
* @typedef {Object} Annotation
* @property {string} text - The text content of the annotation
* @property {number} [dx] - Optional horizontal pixel offset
* @property {number} [dy] - Optional vertical pixel offset
* @property {number} [top] - CSS top position in pixels
* @property {number} [right] - CSS right position in pixels
* @property {number} [bottom] - CSS bottom position in pixels
* @property {number} [left] - CSS left position in pixels
* @property {Array<Arrow>} [arrows] - Optional array of arrow configurations
* @description Additional dynamic properties can be added using data keys (e.g., [xKey]: value, [yKey]: value) for positioning based on chart data dimensions
*/
/**
* @typedef {Object} Props
* @property {Array<Annotation>} annotations - A list of annotation objects.
* @property {Function} [getText] - An accessor function to get the field to display.
* @property {boolean} [pr] - If `true` will set the `top` and `left` CSS positions to percentages instead of pixels.
*/
/** @type {Props} */
let { annotations, getText = d => d.text, pr = $percentRange } = $props();
let units = $derived(pr === true ? '%' : 'px');
</script>
<div class="layercake-annotations">
{#each annotations as d, i}
<div
class="layercake-annotation"
data-id={i}
style:left={`calc(${$xGet(d)}${units} + ${d.dx || 0}px)`}
style:top={`calc(${$yGet(d)}${units} + ${d.dy || 0}px)`}
>
{getText(d)}
</div>
{/each}
</div>
<style>
.layercake-annotation {
position: absolute;
}
</style>
<!--
@component
Adds SVG swoopy arrows based on a config object. It attaches arrows to divs, which are created by another component such as [Annotations.html.svelte](https://layercake.graphics/components/Annotations.html.svelte).
-->
<script>
// @ts-nocheck
import { getContext, onMount, tick } from 'svelte';
import { swoopyArrow, getElPosition, parseCssValue } from '../_modules/arrowUtils.js';
/**
* @typedef {Object} Annotation TODO: Add the schema for the annotation object.
*/
/**
* @typedef {Object} Props
* @property {Array<Annotation>} annotations - A list of annotation objects. See the [Column](https://layercake.graphics/example/Column) chart example for the schema and options.
* @property {string} [containerClass=".chart-container"] - The class name / CSS selector of the parent element of the `<LayerCake>` component. This is used to crawl the DOM for the text annotations.
* @property {string} [annotationClass=".layercake-annotation"] -The class name / CSS selector of the text annotation divs.
*/
/** @type {Props} */
let {
annotations,
containerClass = '.chart-container',
annotationClass = '.layercake-annotation'
} = $props();
let container = $state();
const { width, height, xScale, yScale, x, y } = getContext('LayerCake');
/* --------------------------------------------
* Some lookups to convert between x, y / width, height terminology
* and CSS names
*/
const lookups = [
{ dimension: 'width', css: 'left', position: 'x' },
{ dimension: 'height', css: 'top', position: 'y' }
];
let annotationEls = $state();
// This searches the DOM for the HTML annotations
// in the Annotations.svelte componenent and then
// attaches arrows to those divs
// Make sure the `.chart-container` and `.layercake-annotation`
// selectors match what you have in your project
// otherwise it won't find anything
onMount(async () => {
await tick();
annotationEls = Array.from(container.closest(containerClass).querySelectorAll(annotationClass));
});
function getArrowPath(anno, i, arrow) {
if (!annotationEls || !annotationEls[i]) return '';
const el = annotationEls[i];
/* --------------------------------------------
* Parse our attachment directives to know where to start the arrowhead
* measuring a bounding box based on our annotation el
*/
const arrowSource = getElPosition(el);
const sourceCoords = arrow.source.anchor.split('-').map((q, j) => {
const point =
q === 'middle'
? arrowSource[lookups[j].css] + arrowSource[lookups[j].dimension] / 2
: arrowSource[q];
return (
point +
parseCssValue(
arrow.source[`d${lookups[j].position}`],
i,
arrowSource.width,
arrowSource.height
)
);
});
/* --------------------------------------------
* Default to clockwise
*/
const clockwise = typeof arrow.clockwise === 'undefined' ? true : arrow.clockwise;
/* --------------------------------------------
* Parse where we're drawing to
* If we're passing in a percentage as a string then we need to convert it to pixel values
* Otherwise pass it to our xGet and yGet functions
*/
const targetCoords = [
arrow.target.x || $x(arrow.target),
arrow.target.y || $y(arrow.target)
].map((q, j) => {
const val =
typeof q === 'string' && q.includes('%')
? parseCssValue(q, j, $width, $height)
: j
? $yScale(q)
: $xScale(q);
return val + (arrow.target[`d${lookups[j].position}`] || 0);
});
/* --------------------------------------------
* Create arrow path
*/
return swoopyArrow()
.angle(Math.PI / 2)
.clockwise(clockwise)
.x(q => q[0])
.y(q => q[1])([sourceCoords, targetCoords]);
}
</script>
<g bind:this={container}>
{#if annotations.length}
<g class="swoops">
{#each annotations as anno, i}
{#if anno.arrows}
{#each anno.arrows as arrow}
<path marker-end="url(#arrowhead)" d={getArrowPath(anno, i, arrow)}></path>
{/each}
{/if}
{/each}
</g>
{/if}
</g>
<style>
.swoops {
position: absolute;
max-width: 200px;
line-height: 14px;
}
.swoops path {
fill: none;
stroke: #000;
stroke-width: 1;
}
</style>
<!--
@component
Generates an SVG marker containing a marker for a triangle makes a nice arrowhead. Add it to the snippet called "defs" on the SVG layout component.
-->
<script>
/**
* @typedef {Object} Props
* @property {string} [fill='#000'] - The arrowhead's fill color.
* @property {string} [stroke='#000'] - The arrowhead's stroke color.
*/
/** @type {Props} */
let { fill = '#000', stroke = '#000' } = $props();
</script>
<marker id="arrowhead" viewBox="-10 -10 20 20" markerWidth="17" markerHeight="17" orient="auto">
<path d="M-6,-6 L 0,0 L -6,6" {fill} {stroke} />
</marker>
// Helper functions for creating swoopy arrows
/* --------------------------------------------
* parseCssValue
*
* Parse various inputs and return then as a number
* Can be a number, which will return the input value
* A percentage, which will take the percent of the appropriate dimentions
* A pixel value, which will parse as a number
*
*/
export function parseCssValue(d, i, width, height) {
if (!d) return 0;
if (typeof d === 'number') {
return d;
}
if (d.indexOf('%') > -1) {
return (+d.replace('%', '') / 100) * (i ? height : width);
}
return +d.replace('px', '');
}
/* --------------------------------------------
* getElPosition
*
* Constract a bounding box relative in our coordinate space
* that we can attach arrow starting points to
*
*/
export function getElPosition(el) {
const annotationBbox = el.getBoundingClientRect();
const parentBbox = el.parentNode.getBoundingClientRect();
const coords = {
top: annotationBbox.top - parentBbox.top,
right: annotationBbox.right - parentBbox.left,
bottom: annotationBbox.bottom - parentBbox.top,
left: annotationBbox.left - parentBbox.left,
width: annotationBbox.width,
height: annotationBbox.height
};
return coords;
}
/* --------------------------------------------
* swoopyArrow
*
* Adapted from bizweekgraphics/swoopyarrows
*
*/
export function swoopyArrow() {
let angle = Math.PI;
let clockwise = true;
let xValue = d => d[0];
let yValue = d => d[1];
function hypotenuse(a, b) {
return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
}
function render(data) {
data = data.map((d, i) => {
return [xValue.call(data, d, i), yValue.call(data, d, i)];
});
// get the chord length ("height" {h}) between points
const h = hypotenuse(data[1][0] - data[0][0], data[1][1] - data[0][1]);
// get the distance at which chord of height h subtends {angle} radians
const d = h / (2 * Math.tan(angle / 2));
// get the radius {r} of the circumscribed circle
const r = hypotenuse(d, h / 2);
/*
SECOND, compose the corresponding SVG arc.
read up: http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
example: <path d = "M 200,50 a 50,50 0 0,1 100,0"/>
M 200,50 Moves pen to (200,50);
a draws elliptical arc;
50,50 following a degenerate ellipse, r1 == r2 == 50;
i.e. a circle of radius 50;
0 with no x-axis-rotation (irrelevant for circles);
0,1 with large-axis-flag=0 and sweep-flag=1 (clockwise);
100,0 to a point +100 in x and +0 in y, i.e. (300,50).
*/
const path =
'M ' +
data[0][0] +
',' +
data[0][1] +
' a ' +
r +
',' +
r +
' 0 0,' +
(clockwise ? '1' : '0') +
' ' +
(data[1][0] - data[0][0]) +
',' +
(data[1][1] - data[0][1]);
return path;
}
render.angle = function renderAngle(_) {
if (!arguments.length) return angle;
angle = Math.min(Math.max(_, 1e-6), Math.PI - 1e-6);
return render;
};
render.clockwise = function renderClockwise(_) {
if (!arguments.length) return clockwise;
clockwise = !!_;
return render;
};
render.x = function renderX(_) {
if (!arguments.length) return xValue;
xValue = _;
return render;
};
render.y = function renderY(_) {
if (!arguments.length) return yValue;
yValue = _;
return render;
};
return render;
}
year,value 1979,2 1980,3 1981,5 1982,8 1983,18