0000_0000_0000_0101 Pnchart-swift appeared crash solution
Optional Swift Blog officially opened, team members: Pmst, Starry Night Twilight, Jim, ICE. Address: optionalswift.cn. The foreign visit is slow, you understand.
These days have been busy with the project, because to use the Draw line chart function to achieve a trend of traffic over time, so I finally chose the Pnchart-swfit. There are two ways to use:
I chose the latter, easy to operate, and because it was written by Swift, the use of gray is often handy.
As for the framework code, probably because just wrote, so there are a lot of bugs, I met a orz ....
Bug Description
This is related to the y-axis value, if your y-axis value is [10,32,12,17], then the maximum value max=32,min=10, that is, the y -axis coordinates from 10 to 32 end, this is very good understanding, Because your data range is between [Min,max], the coordinate value range should be this.
Now discuss the situation. The y-axis value is [10,10,10,10], then the maximum value max=10,min=10, the two equal, there seems to be nothing, according to our idea is the y-axis on a point, is this a bug? Obviously that's not what I'm talking about. Instead, there is a one-step division in the frame.
public func strokeChart()The following code is found in the function.
innerGrade = (yValue! - yValueMin) / (yValueMax - yValueMin)//除数≠0才可以 假如=0 就是NAN了无效 程序崩掉
Workaround
Now find the line in the attribute public var chartData:NSArray = [] yValueMin = yMin;
yValueMax = yMax; to add the Judgment code:
if yValueMax == yValueMin{ 1 //加上1 当然也可以自己修改喽}
At last
Intend to write a drawing framework on the basis of this framework, which is currently intended
0000_0000_0000_0101_pnchart-swift appears crash resolved