Skip to content

Instantly share code, notes, and snippets.

@guzmonne
Created April 15, 2017 02:57
Show Gist options
  • Save guzmonne/cffe8635b591b79a677762f560270671 to your computer and use it in GitHub Desktop.
Save guzmonne/cffe8635b591b79a677762f560270671 to your computer and use it in GitHub Desktop.
Chart element example
import React from 'react'
import T from 'prop-types'
import Chart from './Chart.js'
import Background from './Background.js'
import Axis from './Axis.js'
import Bars from './Bars.js'
const SubjectBarsChart = ({data}) => (
<Chart
data={data}
xAccesor={d => d.subject}
yAccesor={d => d.score}
xScale="band"
xScaleOptions={{
padding: 0.2,
}}
yScale="linear"
yScaleOptions={{
minRange: 0,
}}
>
<Background />
<Axis variable="x" textAngle={-45}/>
<Axis variable="y" ticks={10} tickSize={5} />
<Bars />
</Chart>
)
SubjectBarsChart.propTypes = {
data: T.arrayOf(T.shape({
subject: T.string.isRequired,
score: T.number.isRequired,
}))
}
export default SubjectBarsChart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment