-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Re-engineering the core abstract-chart code. #355
base: master
Are you sure you want to change the base?
Conversation
The other graphs based on `abstract-chart.js` remain broken.
reimplement core chart, support bar-chart for full dynamic sizes
re-invent heatmap to fully dynamy and layout-control
Fix issue include `useNativeDriver` warning for RN>6.2. Some crashes on `scrollDot` when user missing some trivial styles and props.
Fix: migrate Deprecated UNSAFE_componentWillReceiveProps to standard RN method.
Dynamic chart size (line-chart fix), Add tooltip to contribution content
…PH_RATIO to line-chart.js
Update abstract-chart compatibility for line-chart
Fix: correct midpoint for BarChart labels
This library could definitely use some more responsiveness. Let's see if anybody else from the community is interested. |
The main concern is that this change is not friendly to current users because of the mixed style issues. They may add a lot of own styles to tackle the original style issue, Otherwise it's always ready to merge without crushing apps after I fixed the |
Fix: did not update when data changes
Does this PR address the 'gap' to the right side of the LineChart that a lot of people are experiencing? Even the example code suffers from this and I am having a terrible time trying to fix it. Thanks. |
The gap issue (technically padding left or padding right) is just initial motivation, small part of this PR, and eventually includes adding all padding and rework the core layout implementation. I believe the |
correct data display on scrollableInfo
return endOfWeek.getDate() >= 1 && endOfWeek.getDate() <= DAYS_IN_WEEK ? ( | ||
<Text | ||
key={weekIndex} | ||
x={x + paddingLeft} |
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 paddingLeft
is really annoying, thank god it will be removed finally.
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
paddingLeft
is really annoying, thank god it will be removed finally.
paddingLeft
still exist but migrate to chartConfig: { chartStyle:{ //here } }
without conflict with outer container style
props.
This PR isn't going to anywhere yet, but I can guarantee the contribution chart itself it's fully functional. If you only use it you are free to try my fork. I believe Doc is up to date also.
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.
Great, configurable is awesome.
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.
I checkout to your PR, but there is no build
script in package.json, so how can I try use it?
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.
I checkout to your PR, but there is no
build
script in package.json, so how can I try use it?
The complexity comes from all the recent typescript updated. So there must be a lot of conflicts as far as I know, Since PR is all based on my fork repo, a tricky and easy way to do this is to directly npm install
my fork repo as another library, you probably need to create alias for it so it wouldn't replace the main one, and then use the contributionchart
, by this way you can always switch back to the main repo and delete the old one once it's ready.
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.
You mean like?
git clone <your repo>
cd <your repo>
npm i
npm install
in your repo won't help I think, which not install anything to my app repo.
If you're planning to create a branch new lib, a branch new pkg would be great, otherwise, I can wait for this PR got merged (hopefully).
And let me know if anything I can help if you want.
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.
No, just directly install from github repo.
check this one out for specific details: https://stackoverflow.com/questions/26414587/how-to-install-multiple-versions-of-package-using-npm/56495651#56495651
You can do something like npm install YourOwnName@https://github.com/aboveyunhai/react-native-chart-kit.git
then in your project
import { ContributionChart } from 'react-native-chart-kit';
import { ContributionChart as TempContributionChart } from "YouOwnName";
Now you can use whatever you want from both repo.
seperate hideLabel from hidePointsArIndex. correct vertical line heig…
@aboveyunhai it needs a rebase to fix the conflict. @Hermanya is it ready for merge if conflicts are resolved, or what else needs to be addressed if it wants to get merge? |
|
@aboveyunhai @metrue @Hermanya I also have a suggestion, can we also have an option to do solid color fill for the chart in this PR? Or this will be done as a separate PR. Having only gradient fills limits the ui design choices |
@adilusman51 I don't think we have a plan around this. But there are merge conflicts now. As for colors, you can make a gradient from and to the same color. |
@Hermanya Thanks for providing an update. react-native-chart-kit/src/AbstractChart.tsx Line 443 in 7891d61
|
@adilusman51 unfortunately, I don't believe this is going to merge any soon. |
i have been trying to override this gradient for bars in the BarChart in my fork: https://github.com/hariDasu/react-native-chart-kit/blob/master/src/BarChart.tsx#L65 but am still trying to fully understand the chart config types and how to override the LinearGradient that is being used to color each bar. this stackoverflow post i made describes my problem in more detail: I followed the suggested approach and it looks better, but still has a slight gradient that I wish I could do without. it would be nice if this was possible in a future release. |
I used the repo and encounter a lot of problems. I reengineer a lot of core codes to make some of charts fully responsive and ease out a lot of problems, I would rather called it a prototype of Ver.2 or breaking change. So I thought it might be somehow helpful for the main repo and good to share .
This is more like a proposal instead of PR. @Hermanya
Please don't use this merge unless you only care about
BarChart
,LineChart
andContributionChart
(There are now fully responsive and can apply all padding styles).StackedBar
is broken unless I fixed it to match the newabstract-chart.js
. There is also some changes so it has no backward-compatibility for those abused property in the past.The rest of charts remain unknown because I don't know if how they used abstract-chart.js. As far I as know, they all should be fine because they just basically extends from it without actually use some of core functions.
If anyone is interested this merge may try it out. And of course it will slightly affect the chart-layout if ppl used the old style is the past but you can always apply your own
chartStyles
.I just want to use pic to show the current problem and the main issue that many merges were already based on that.
This pic show the current properties are used to build you chart.
Red(1,2,3,4)
is padding up right down left for the outer container<View>
.(P1)(Problem1): inside the chart their is a
paddingRight
Yellow(6)
. It should be rename to paddingLeft for it's true intent. The wrongpaddingRight
span almost everythere for every single calculation.(P2):
<View/>
style
prop mess with chart. for instance, changingpaddingLeft
(currently is namedpaddingRight
in code) affects bothRed(2)
andYellow(6)
. Inline-chart.js
,paddingTop
changedRed(1)
andYellow(5)
and other styles likeborderRadius
and so on.(P3): hardcode number and the way to build chart content(the space used to draw bar and line)
Yellow (3) horizontal Label Width
is predefined with fix number,Yellow (4) gutter size
(some gap between the top of chart and padding so horizontal label wouldn't overflow and aesthetic)s )is hardcoded.The content height is the sum of
Yellow(1)
andPurple
. here is the tricky part,Yellow(1)
is 3/4 of height (which is hardcoded) and then it was spliced bysegment
then render the extra one line (the position of bottom line 0) to determine thePurple
height. Whatever (Yellow(2)
-Purple
) is reserved for bottom labels(SUN, MON....). It caused position calculation extremely difficult in code and trouble to further implement padding and other size property (whatever contents belowYellow(1)
is almost uncontrollable with the current way of rendering)There are also some minor issues upon that but I don't think it matters that much because I fixed most of them along with the new implementation.
The new implementation,
<View style={}/>
is completed isolated from the chart hencestyle
prop
only affects the outer container style.paddingRight
is corrected topaddingLeft
.all the inner paddings
Green(1,2,3,4)
is now inside:so it wouldn't confused with
style
prop .Green (5,6,7)``verticalLabelHeight, horizontalLabelWidth, and gutterTop
is predefined dynamically to the size you provided. Default percentage is in Doc. You can pass some fix number or dynamic size by yourself,which left out the chart content
Blue Rect
completely dynamic to your adjustment. The old way of calculating the height is completely removed,In term of code, most of the old calculation logic
( height / some number * some number) /more number + .....
becomes straightaway addition and subtraction. IMO this is more intuitive for future implementation.segments
default is moved from 1 => 2, it means total number of lines in graph including the baseline, It has no harm if you really want to use baseline(1) only .fromZero
is completed removed because it is not generic and create duplicated code inif
block.Instead,
defMax
anddefMin
as optional props are introduced to define the default max/min in graph. If you noticed, the pic above has adefMax={1000}
anddefMin={0}
.The old 'fromZero' is basically defMin={0}.
Random no-sense exmaple like
defMin={-100} defMax={200}
<ContributionChart>
itself is standalone from others, So I just apply the way of RN view style to it so it can work likeas well as padding. More details are in the new Doc.
A customizable
TooltIp
is also added but I haven't prepared how to make Doc for it, it does required user to do some calculations by themselves.But here is the gif in action.