Last active
July 24, 2020 21:22
-
-
Save kristw/517067ddf0535e063d9481f733ca52a3 to your computer and use it in GitHub Desktop.
blog example: vx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function BarChart() { | |
const xScale = scaleBand({ rangeRound: [0, xMax], domain: data.map(d => d.letter) }); | |
const yScale = scaleLinear({ rangeRound: [yMax, 0], domain: [0, Math.max(...data.map(d => d.frequency))] }); | |
return (<svg width={width} height={height}> | |
{data.map(d => { | |
const barHeight = yMax - yScale(d.frequency); | |
return (<Bar | |
x={xScale(d.letter)} | |
y={yMax - barHeight} | |
width={xScale.bandwidth()} | |
height={barHeight} | |
fill="rgba(23, 233, 217, .5)" | |
/>); | |
})} | |
</svg>); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment