Comments (4)
I’m sure you thought of this, but what’s wrong with keeping all the state in react (the data would come from the ‘template’ right, not the data endpoint?) and then simply updating the data through a POST and updating the react stuff? Help me learn! ha
from openrunlog.
Yeah you're right that it's possible. The tricky part isn't with where to store the data - there's multiple ways to do that including what you mention.
The part that doesn't quite work with react's flow is that react tries to be efficient in which DOM elements it updates so it has a virtual representation that it updates first and runs a diff against what's currently there and only updates nodes that should change. The problem here is that since the chart itself is inserted by the xChart library and not rendered directly by the react component, react doesn't know about the chart and so it won't update.
The "hack" that I've figured out to get around that is to just force the chart update on every call to render() and let the graphing library figure out what to do:
if (this.myChart) {
this.myChart.setData(this.getInitialState()["data"]);
}
As a result, the above sort of drops benefits of react but it's the best I've been able to come up with so far.
from openrunlog.
Ohhh - I see. Would it be helpful if this was re-written in pure D3? Though, I think, you’d still have the issue with D3 trying to figure out what to do (you’d end up having to call an equivalent ‘render’ on D3 to make your changes appear, but then it’s pure D3 (and not one more layer of abstraction through that charting library?).
from openrunlog.
Yeah I'm not sure if that's beneficial since it wouldn't alleviate these problems - so I'm not sure it's worth the work. I think the chart library itself pretty smart about not rendering if the data hasn't changed so it might not actually matter.
xCharts is actually pretty nice but I think I've encountered a few bugs with it in the past few days relating to setData() , if anything I might try to track those down.
from openrunlog.
Related Issues (20)
- fork_process breaks app when ORL_DEBUG=False HOT 2
- allow for more precision than seconds in racelog
- Invalid Profile View HOT 3
- Streak Calculation bug
- calendar exception on no data for calendar period
- Embedable Calendar/Log
- Add Run validation - miles only validated client side HOT 1
- Add Run validation - client doesn't validate date HOT 1
- User URL Uniqueness not respected when saving user settings HOT 1
- iOS Chrome Date() format is not expected HOT 1
- Streak worker exception: going over cursor/list bounds
- Remove models.Week
- Workout "type" HOT 2
- Enable CSP in HTTP headers
- Consider replacing mongoengine with motorengine HOT 1
- upgrade to tornado 4.4.2 HOT 1
- migrate to python 3
- Backups broken due to mongoctl/pymongo incompatibility HOT 1
- Register busted? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openrunlog.