I haven't been able to find this looking around the documentation. I'd like to show a graph with the x-axis rendering Dates & Times with the most recent data on the left. I had hoped that just reversing the data property array would do it but the react-vis library is smarter than that.
I would have thought the information is on this documentation page.
So, how do I sort the x-axis descending?
Code Sample
function ExampleGraph(props) {
const {
data,
x, y,
} = props
// const keys = Object.keys(data)
// if(keys.length>2){
// console.error({data}, "has too many dimensions for x-y")
// }
const keys=[x,y]
const xyData = (()=> {
const xKey = keys[0]
const yKey = keys[1]
const xArgs = data.map(r => (r[xKey]))
const yArgs = data.map(r => (r[yKey]))
const coords = xArgs.map((x, i) => ({
x: x,
y: yArgs[i]
}))
return coords
})()
return (
<XYPlot
width={1000}
height={640}>
<HorizontalGridLines />
<LineSeries
data={xyData}
/>
<XAxis />
<YAxis />
</XYPlot>
)
}
BlazeJS (MeteorJS) template that renders the component
<template name="stepCountsGraph">
<div>
{{> React
component=ExampleGraph
data=stepCounts
y="step_count"
x="time"
}}
</div>
</template>