-
Notifications
You must be signed in to change notification settings - Fork 723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new(xychart): add BarSeries #808
Conversation
horizontal?: boolean; | ||
/** | ||
* Specify bar padding when bar thickness does not come from a `band` scale. | ||
* Accepted values are [0, 1], 0 = no padding, 1 = no bar, defaults to 0.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is backwards and was updated to match d3's band scale logic: 1=no bar, 0=no padding
. will fix.
barPadding?: number; | ||
}; | ||
|
||
function BarSeries<XScale extends AxisScale, YScale extends AxisScale, Datum extends object>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of this logic can become BaseBarSeries
in the future to power animated and non-animated bars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall lgtm. have small comments and wait for green ci to approve
@@ -1,55 +1,29 @@ | |||
import React, { useContext, useCallback, useEffect } from 'react'; | |||
import React, { useContext, useCallback } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. The code in LineSeries
looks much cleaner with the HOC.
Pull Request Test Coverage Report for Build 30Details
💛 - Coveralls |
const [, forceUpdate] = useState(Math.random()); | ||
const privateRegistry = useMemo(() => new DataRegistry<XScale, YScale, Datum>(), []); | ||
|
||
const registerData = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as all of these 5 functions depends only on privateRegistry
, perhaps a single useMemo
block is enough?
or should the first two also depend on the value of forceUpdate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call! initially I didn't have the force update, but you're right that now a single memo works 👌 had to wrap some of the functions for the appropriate this
context to work.
This PR adds
BarSeries
to thexychart
package and refactors / fixes other issues in the process🚀 Enhancements
adds
BarSeries
componentadds
withRegisteredData
HOC which swapsdata
/xAccessor
/yAccessor
props for those in theDataRegistry
in context. This makes*Series
implementation more straight forward because they should always use values from context so they are in sync with the context scales.re-writes
useDataRegistry
DataRegistry
, which did not result in the necessaryhook
=>scales
=>context
=>component
updates when the registry was updated.DataRegistry
API and uses it for its implementationimproves the light/dark theme colors:
📝 Documentation
for the
/xychart
demo:line
orbar
seriesrender horizontally
toggleAdds tests for all new components.
@kristw @techniq @hshoff