You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys. I'm new here and I am coming up with a concept to get around the non scalable x axis.
First, I love this graphing library thank you so much to everyone who worked hard to make this.
My experience with swift, and programming experience for that matter, is very very limited, so excuse me if I sound inexperienced. I literally learned how to alter source code last night to change my linerenderer. I am posting here because I know some of you have posted about this and I figured maybe you might want to help a bit by pointing me in the right direction for some of this. If I figure it out entirely I'll post what I've done.
I plan to feed my chart X axis an array of dates, but skipping dates is possible, so I have to represent this in the chart, of course. Here is my plan.
I have an array of Y vals, and an array of x vals that are dates(or any value). I'll convert those dates to integers, starting at 0. The final value on the xaxis will be an integer representation of the final date (in days in my case)
I just run a loop adding values to a new array data, every time I hit an assigned y value on my y array.
For spots along the new x array that are blank, I run a simple slope*change in x + previous y value.
And I'll make an equivalent array of flags(bool) to say when a data point is hit..
like this
func returnMidPointY(x1:Int, x2:Int, y1:Double, y2:Double, midX:Int)->Double{letslope=(y2-y1)/(Double(x2-x1))letmidY=(Double(midX-x1)*slope + y1)return midY
}vardata=[Double]()varflag=[Bool]()varcount=0
for i in 0..<(xvals[xvals.count-1]+1){
if (i ==xvals[count]){
data.append(readings[count])
flag.append(true)// following if statement is to prevent trying to call count+1 below when array end has been reached
if (count<xvals.count-1){
count++}}else{letthisY=returnMidPointY(xvals[count-1],x2:xvals[count],y1:readings[count-1],y2:readings[count], midX: i)
data.append(thisY)
flag.append(false)}}
That flag array will let me denote where on my xaxis I display a value. Then I will use the flag to alter the circle radius to the same width as my line render. Then I'll use the flag to alter the datavalue display.
Its these last three I need pointers on. I'm going to search through the source code myself and find where I can do this, but if anyone can point me in the right direction, I'd be very appreciative.
Thanks!
The text was updated successfully, but these errors were encountered:
The above worked well. I added a public [bool] to LineChartDataSet, used that array in both the DrawCircles and DrawValues function in LineChartRenderer as a flag to say when to display a value or a circle.
The values will exceed the maximum that are viewable in the LineChartView, so you have to alter drawvalues to ignore that, and then use the flag to say when to display a value.
maybe you want to post screenshots what you want to do. Usually if you don't have a y for the specific x, you just don't add value into the dataSet, and the library will ignore it as well, and addLineTo the next (valid) point. Seems you don't have to calculate it.
Hi guys. I'm new here and I am coming up with a concept to get around the non scalable x axis.
First, I love this graphing library thank you so much to everyone who worked hard to make this.
My experience with swift, and programming experience for that matter, is very very limited, so excuse me if I sound inexperienced. I literally learned how to alter source code last night to change my linerenderer. I am posting here because I know some of you have posted about this and I figured maybe you might want to help a bit by pointing me in the right direction for some of this. If I figure it out entirely I'll post what I've done.
I plan to feed my chart X axis an array of dates, but skipping dates is possible, so I have to represent this in the chart, of course. Here is my plan.
I have an array of Y vals, and an array of x vals that are dates(or any value). I'll convert those dates to integers, starting at 0. The final value on the xaxis will be an integer representation of the final date (in days in my case)
I just run a loop adding values to a new array data, every time I hit an assigned y value on my y array.
For spots along the new x array that are blank, I run a simple slope*change in x + previous y value.
And I'll make an equivalent array of flags(bool) to say when a data point is hit..
like this
That flag array will let me denote where on my xaxis I display a value. Then I will use the flag to alter the circle radius to the same width as my line render. Then I'll use the flag to alter the datavalue display.
Its these last three I need pointers on. I'm going to search through the source code myself and find where I can do this, but if anyone can point me in the right direction, I'd be very appreciative.
Thanks!
The text was updated successfully, but these errors were encountered: