React/Victory: Graph not showing entries
React/Victory: Graph not showing entries
I am working on fitting my data to this Victory graph but for some reason it is not coming out like expected. I don't need a y-axis but on the x-axis I am trying to list the entries in my dataset from earliest to latest. The component seems to be receiving data but the graph does not render as expected. The example is here, https://formidable.com/open-source/victory/guides/zoom-large-data/
Component
class CustomChart extends React.Component
constructor(props)
super();
this.entireDomain = this.getEntireDomain(props);
this.state =
zoomedXDomain: this.entireDomain.x,
;
onDomainChange(domain)
this.setState(
zoomedXDomain: domain.x,
);
getData()
const zoomedXDomain = this.state;
const data, maxPoints = this.props;
const filtered = data.action.filter(
(action) => (action.timestamp >= zoomedXDomain[0] && action.timestamp <= zoomedXDomain[1]));
if (filtered.length > maxPoints )
const k = Math.ceil(filtered.length / maxPoints);
return filtered.filter(
(d, i) => ((i % k) === 0)
);
return filtered;
getEntireDomain(props)
const data = props;
return
y: [_.minBy(data.action, action => action.timestamp).timestamp, _.maxBy(data.action, action => action.timestamp).timestamp],
x: [ data.action[0].timestamp, _.last(data.action).timestamp ]
;
getZoomFactor()
const zoomedXDomain = this.state;
const factor = 10 / (zoomedXDomain[1] - zoomedXDomain[0]);
return _.round(factor, factor < 3 ? 1 : 0);
render()
const renderedData = this.getData();
return (
<div>
<VictoryChart
domain=this.entireDomain
containerComponent=<VictoryZoomContainer
zoomDimension="x"
onZoomDomainChange=this.onDomainChange.bind(this)
minimumZoom=x: 1/10000
/>
>
<VictoryScatter data=renderedData />
</VictoryChart>
<div>
this.getZoomFactor()x zoom;
rendering renderedData.length of this.props.data.length
</div>
</div>
);
//render
//component
export default graphql(getObjectsQuery,
options: (ownProps) =>
console.log('CustomChart getObjectsQuery:', ownProps.startTime);
return ( second: startTime: ownProps.startTime,
endTime: ownProps.endTime
)
)(CustomChart);
Data
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.