-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implement clipData
feature in scatter chart.
#898
Conversation
@prajwal27 Thanks for contributing!
We need to fix the functionality of |
You can check line_chart_painter.dart:69 to get the idea. |
So @imaNNeoFighT , shall I remove the new |
Yes, you're correct! |
@imaNNeoFighT I checked the line_chart_painter.dart and I got this
What's the logic of 40 here? |
To be honest I don't remember :)))) |
…in scatter chart.
@imaNNeoFighT I've updated the PR as you've suggested. I did try and remove the 40. I didn't notice any change. |
clipData
feature in scatter chart.
Codecov Report
@@ Coverage Diff @@
## dev #898 +/- ##
==========================================
+ Coverage 80.65% 80.84% +0.18%
==========================================
Files 32 32
Lines 2973 3002 +29
==========================================
+ Hits 2398 2427 +29
Misses 575 575
Continue to review full report at Codecov.
|
Hi @prajwal27. |
Yeah, is this considered as bug fix or enhancement? |
I think it is a bug fix (Because it was supposed to work). |
@imaNNeoFighT thanks for the quick suggestions and reviews. It would be great if you could merge this. |
Thank you @prajwal27 As you see, it doesn't work correctly with our borders (But we considered the border width in our code). We should: I know you just copied it from our LineChart. Below code is correct: if (clip.left) {
final borderWidth = border?.left.width ?? 0;
left = getLeftOffsetDrawSize(holder) + (borderWidth / 2);
}
if (clip.top) {
final borderWidth = border?.top.width ?? 0;
top = getTopOffsetDrawSize(holder) + (borderWidth / 2);
}
if (clip.right) {
final borderWidth = border?.right.width ?? 0;
right = getLeftOffsetDrawSize(holder) +
chartUsableSize.width -
(borderWidth / 2);
}
if (clip.bottom) {
final borderWidth = border?.bottom.width ?? 0;
bottom = getTopOffsetDrawSize(holder) +
chartUsableSize.height -
(borderWidth / 2);
} |
@imaNNeoFighT that's great. I didn't see it coming. Are we good to merge now? |
No please solve the problem I mentioned first, then we're going to merge it. (I said I will fix it in the LineChart) |
Ohh my bad, sorry. I'll do it now. |
@imaNNeoFighT modified the clip equation. |
Landed in |
It was fun understanding the code! You'll probably see me more often than not :) |
Thanks for being patient :))) |
* feat: Introduce 'clipBubble' attribute to scatter chart. * fix: remove `clipBubble` attribute and implement `clipData` function in scatter chart. * added issue fix #897 to changelog. * modify clip equation to resolve border issue. Co-authored-by: prajwal27wiijii <prajwal@wiijii.co>
#897.
The Scatter chart can be used as a Bubble chart by providing different radii. So, when the radius is bigger and close to the axis of the chart, it is used to cross the axis and go out of the chart.
So, in my approach, I've added a new attribute in
ScatterChartData
calledclipBubble
. If we set it to true, it will clip the chart before drawing the spots such that the bubbles never cross the chart's axes. After the bubbles are drawn, it again restores the original region.