Skip to content

Instantly share code, notes, and snippets.

@2c2c
Created December 29, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2c2c/f3bfbebbe682caccde18fc953f30c7ac to your computer and use it in GitHub Desktop.
Save 2c2c/f3bfbebbe682caccde18fc953f30c7ac to your computer and use it in GitHub Desktop.
import React from 'react'
import * as V from 'victory'
import moment from 'moment'
const HourlyChart = (props) => {
// make axis show 10 at a time. hack since axis prop isnt working
let tick = Math.floor(props.tweets.length * .1)
return (
<V.VictoryChart>
<V.VictoryArea
data={props.tweets}
x={(datum) => moment(datum.time).format('ha')}
y={(datum) => datum.total_sent}
style={{
data: {
opacity: .4
},
parent: {
border: "1px solid #ccc"
}
}}/>
<V.VictoryAxis
style={{
axis: {
stroke: "#756f6a"
},
axisLabel: {
fontSize: 16,
padding: 20
},
grid: {},
ticks: {
stroke: "grey"
},
tickLabels: {
fontSize: 10,
padding: 5,
opacity: (t) => t % tick === 0
? 1
: 0
}
}}/>
<V.VictoryAxis dependentAxis/>
<V.VictoryLine
data={props.tweets}
x={(datum) => moment(datum.time).format('ha')}
y={(datum) => datum.total_sent} />
<V.VictoryScatter
data={props.tweets}
x={(datum) => moment(datum.time).format('ha')}
y={(datum) => datum.total_sent}
labels={(datum) => datum.total_sent}
labelComponent={<V.VictoryTooltip/>}
size={2}
/>
</V.VictoryChart>
)
}
export default HourlyChart;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment