0000_0000_0000_0101_pnchart-swift appears crash resolved

Source: Internet
Author: User

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:

    • Pod installation.

    • Download the Swift file and import the reference directly.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.