-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Can we add nil values to a dataset yet? #113
Comments
Well, you don't have to insert nils. You just add yVals for whatever xIndex you want. Suppose you have: You could just set: And not set value for Oranges... |
Not sure how that would be applicable for the following implementation;
Say I want to omit the first 10 y values. In that case I have to insert something so that the x values start from index 10 onwards. |
The thing is you do not have to insert y values for xindex 0. You coulds בתאריך יום שני, 1 ביוני 2015, AlBirdie [email protected] כתב:
|
If autoscaling is on I get an exception when I add xValues without y values at the end of the dataset. I've managed to resolve this issue by changing: ChartDataSet - calcMinMax (line 99) |
Interesting, for me the application crashes at _yVals.count in ChartDataSet (EXC_BAD_INSTRUCTION). |
_yVals will try to automatically unwrap, and could crash on that. Is _yVals On Mon, Jun 1, 2015 at 3:02 PM, AlBirdie [email protected] wrote:
|
Nope, _yVals is not nil. Debugging Swift code in an ObjC project is kind of pointless as it doesn't work properly. |
Yeah I hope they fix it in the upcoming Xcode update. It's not showing On Mon, Jun 1, 2015 at 3:38 PM, AlBirdie [email protected] wrote:
|
Alright, got it. The problem with my project relates to the performance enhancement @dorsoft mentioned in #29; I've managed to make a candle stick chart with 10k data points pan/zoom smoothly. by changing var minx = max(dataSet.entryIndex(entry: entryFrom, isEqual: true), 0); to var minx = max(_minX, 0); That essentially breaks the drawLinear method for LineCharts that have "empty" x values. Go back to the original code, and the method executes normally. |
That's why I don't accept such changes without extensive testing :-) On Mon, Jun 1, 2015 at 4:42 PM, AlBirdie [email protected] wrote:
|
Just change This fixes the issue |
That fixes the issue of the source not being executable. However, there are other side effects with this. For instance, in case you omit the first say 10 values, the renderer will skip 10 values whilst panning (in case the visible range is smaller than the max range of course), even though the current x range ranges from like 30 to 70. Min / max calculations don't work properly as well. |
@AlBirdie I didn't understand - is the issue solved for you? What is the current status on this? |
Nah, the issue remains. I've also tried to use the 'lowestVisibileXIndex' and 'highestVisibleXIndex' instead of calculating minx and maxx manually in the renderer, but with the same results, when you zoom in on a set that omits the first 10 values and then pan the set, it will always omit the first 10 values, even if your visible range goes from 20 to 50. Couldn't figure out why this happens yet. |
I bet it's something with min/max x values not updating correctly. I'll look into it. |
I just use this thread to ask, can I add null values (NSNull singleton) into Y? I get your idea that only insert valid values at the xIndex. Is it a must that we have to detect if the value at xIndex is nil/Null, we should passby and continue the next? |
@liuxuan30 you shouldn't add |
@AlBirdie I'm not experiencing the problem you are describing. Watch this: |
Interesting... What implementation of the library did you use for that demo? Also, can you verify your result with autoScale on the y axis enabled? |
Well it's the latest version, with Bar chart demo, setting the first y On Thu, Jun 11, 2015 at 12:31 PM, AlBirdie [email protected] wrote:
|
I haven't tested this without autoScale, so I suppose that that's the origin of the issue, yes. I'm currently not in the office to confirm this, but I'll get back to you as soon as possible. |
@danielgindi for RadarChart, say we have two dataSets, and the x is [a,b,c,d,e], while dataSet 1 is [1,2,nil,nil,5] and dataSet 2 is [10,11,12,13,14], if we drop the two nil valus in dataSet 1, the radar chart shape is strange then... How should I deal with it? |
It makes no sense to skip values in RadarChart On Mon, Jun 15, 2015 at 9:27 AM, Xuan [email protected] wrote:
|
can radar chart support different size for xAxis and yAxis, say at xIndex 3, I have only have nil values. but other xIndex had valid data |
I'm actually not an expert on radar charts. I don't understand them. You On Mon, Jun 15, 2015 at 9:51 AM, Xuan [email protected] wrote:
|
Alright, but I think it's a serious topic ragards radar chart. Because I have run into some corner cases while doing unit tests. All about invalid data. What I am asking is, how you deal with the invalid data in radar chart? Simply ignore it and draw the line to next point? I tried to read the code, but a little hard to understand. Looks like I need to create some test case so we can move forward |
Daniel, I've tested your case and I'm seeing the same as you do. However, that's only the case for the BarChartRenderer. The LineRenderer behaves as I've described earlier (always omitting the first values during panning/zooming). This has nothing to do with the autoScaling, though. Actually, nevermind. Using the "correct" implementation of minx and maxx in the LineChartRenderer's drawLinear, the error is gone. @dorsoft 's solution regarding minx and maxx calculations won't work with this, unfortunately. Hopefully we can find a way to still introduce the performance boost of his changes into the line renderer. |
So I guess we can close this - and we'll look into a way to introduce @dorsoft's changes correctly :-) |
Hi all, This topic is some months old now and closed, but I had a similar issue than I wanted to visualize a CandleSticks Chart with gaps, i.e. yVals not necessarily containing a DataEntry for each x-index, and when panning in a zoomed Chart I had rendering issues, like candlesticks after gaps not always drawn, depending on how much I was panning on the right. I figured out implementation of CandleStickChartRenderer’s drawDataSet is incorrect. In the for loop, the actual intention at line // get the entry is to get the entry with xIndex == j, but it is wrong when yVals does not contain a value for each x-index. If you have gaps in charts, you can be sure that entries.count != entries[entries.count-1].xIndex So my approach was to use entryForXIndex : Before the loop : let maxx = min(_maxX + 1, entries.last!.xIndex+1) and in the loop let e = dataSet.entryForXIndex(j) as! CandleChartDataEntry You then need an extra condition, as "If no Entry at the specifed x-index is found, entryForXIndex method returns the Entry at the closest x-index" So if (e.xIndex != j) This worked for me. |
Basically, I need to draw a chart that doesn't have continous data, so the y values could look like this;
nil, Entry, Entry, nil, nil, nil, Entry,... you get the idea.
The chart should then just show gaps where there's no data for the corresponding x value.
I'm pretty certain that this isn't supported yet, and I'm not sure how to that either to be honest.
Do have an idea with regards to a suitable implementation for this?
There's already a feature request for this for the Android version (PhilJay/MPAndroidChart#293).
The text was updated successfully, but these errors were encountered: