PNChart(https://github.com/kevinzhow/PNChart) Swift Implementation
This isn't on CocoaPods yet, so to install, add this to your Podfile
pod 'PNChartSwift',:git => 'https://github.com/kevinzhow/PNChart-Swift.git'
A simple and beautiful chart lib used in Piner and CoinsMan for iOS(https://github.com/kevinzhow/PNChart) Swift Implementation
License: MIT License
PNChart(https://github.com/kevinzhow/PNChart) Swift Implementation
This isn't on CocoaPods yet, so to install, add this to your Podfile
pod 'PNChartSwift',:git => 'https://github.com/kevinzhow/PNChart-Swift.git'
I got this error message in MasterViewController.swift
/Users/MNurdin/Documents/Github/PNChart-Swift/ExampleApp/ExampleApp/MasterViewController.swift:10:8: No such module 'PNChartSwift'
Please advice. Thank you.
Hi I can't seem to find a circle chart example or any points to the code? Is this left out?
The easy solution is that you should add a piece of code in PNLineChart.swift
,Found the property public var charade:NSArray =[]{...}
add code below yValueMin = yin; yValueMax = yMax;
add judge if yValueMax == yValueMin{ yValueMax += 1// you could modify the value}
Any chance you are considering porting the other charts into Swift? I am looking to use the ScatterChart for a project (currently all in Swift) and trying to decide if I need to use the PNChart and bridge to it from my swift code or use the PNChart-swift library.
Hi, how I can make the current value automatic checking and update value automatic if value has changed
PROBLEM SOLVED!
NSTimer.scheduledTimerWithTimeInterval(0.9, target: self, selector: "updateValues", userInfo: nil, repeats: true)
}
func updateValues() {
lineChart!.updateChartByCurrent("YOUR NEW VALUE!!")
}
}
Hi Kevin,
Noticed the PNChart-Swift repo doesn't include a license like the Objective C version does. Is it licensed under MIT license as well? Can you post the license right in the Swift repo?
Regards,
OutsideRide
Needs automatically re-render chart when layout has changed.
Line chart crashes when there is only one data point.
In the PNChart readme (Objective C) it shows that there is functionality for circle, pie, and scatter charts as well as legends for your chart. When will this functionality be available in the Swift version of this project?
我也是国人,打开来发下 70多个 issues 求解,新手不太懂。
It works fine with single line graph and no errors when tapped on graph but when multi line graph is plotted, it fails on tapping the graph with the following error
Could not cast value of type '__NSArrayM' (0x102bb48d8) to 'PNChartSwift.PNValue' (0x10280fba0).
Assertion failed: (CGFloatIsValid(x) && CGFloatIsValid(y)), function void CGPathMoveToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat), file Paths/CGPath.cc, line 254.
It's happening on progressline.moveToPoint(CGPointMake(x, y))
My code is pretty simplistic:
var weekData:NSDictionary = JSON["week"] as! NSDictionary
// Example: { "02/15": 7 }
self.chartView?.xLabels = weekData.allKeys
var data = PNLineChartData()
data.color = UIColor(red: 77.0 / 255.0, green: 186.0 / 255.0, blue: 122.0 / 255.0, alpha: 1.0)
data.itemCount = weekData.allKeys.count
data.getData = ({(index: Int) -> PNLineChartDataItem in
var yValue:CGFloat = weekData.allValues[index] as! CGFloat
var item = PNLineChartDataItem(y: yValue)
return item
})
self.chartView?.chartData = [data]
self.chartView?.strokeChart()
Hi! I am trying to run the example app but i am getting this error:
diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
I understand i need to install cocoa pods, but i am unclear as to why if i am using swift?
Would love to use circle chart in my new swift app, any plans on adding it soon?
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
var viewController:UIViewController = segue.destinationViewController as UIViewController
var ChartLabel:UILabel = UILabel(frame: CGRectMake(0, 90, 320.0, 30))
ChartLabel.textColor = PNGreenColor
ChartLabel.font = UIFont(name: "Avenir-Medium", size:23.0)
ChartLabel.textAlignment = NSTextAlignment.Center
//
////MasterViewController.swift:39:33: Cannot convert the expression's type 'String?' to type 'NSString'
//
switch segue.identifier as NSString {
case "lineChart":
//Add LineChart
ChartLabel.text = "Line Chart"
I'm using a pieChart (which I love btw)... When a user taps a cell in a tableView, I want to reset the pieChart so that it animates while updating to display the new data. Is there a good way to go about this. So far all I have done is remove the subview and then re-add it but the pie chart doesn't animate back in, and only the labels to the pie slices look like they animate back in. Not sure how to go about this so that the pieChart will show re-animating into view with the new data
like this tool so far, and plan on using it on one of my projects but now it won't compile on beta 5 when it worked on beta 4. Anyone else tried it? When I remove the PNChart files my project compiles and runs. It complained about adding override to init functions and after that now I get the error below.
Referring to an argument in another function!
store %swift.type* %T, %swift.type** %2
LLVM ERROR: Broken function found, compilation aborted!
Command /Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
I saw that in another post you were going to make some changes for beta 5, so maybe this will be fixed with that update.
Thanks so much
on Line 354: I get the following Error:
PNChart/PNBarChart/PNBarChart.swift:354:43: 'AnyObject?' does not have a member named 'floatValue'
Any idea how to fix this issue? I've Swift iOS 8.1
hi!~
In PNBarChart.swift, the logic is that if user have set the strokeColor and strokeColors at the same time, then use StrokColor first.(line 243-248)
However, strokeColor:[UIColor] has a default value that is PNGreenColor, so setting value to strokeColors:[NSArray] is in vain because of that. (line 247 can not be reached)
Looks like a great piece of work but does not compile under XCODE6 (final) right now. About 20 issues, becoming more after I started to fix some. It would be great if you could take a look! thx
Why i cant find the lib in cocoapods by keyword "PNChartSwift"?
Guys if you guys looking for this in swift
Check this one
https://github.com/PandaraWen/PDChart
It works for Xcode beta 6
and it does work for Xcode 6 GM if you fix that ONE error
let me know if you guys got it
Hi,
How to show Y labels based on Y values?
Really love the library, could you please fix all the compilation errors that appear in Xcode 6 Beta 3?
Should I use the swift version or the objective c version.
Now, Xcode6 Beta4
had been around for a couple of days, the notable change was the Access control
added. You should update to the Beta4
.
很喜欢用这个库,简单实用,但是一直没有支持swift3.0或者2.3.希望作者能够支持一下!谢谢!
Will you upgrade PNCharts to Swift 1.2? Thanks
func getYValueMax(yLabels:NSArray) {
// XCODE 6 GM
//PNBarChart.swift:355:43: 'AnyObject?' does not have a member named 'floatValue'
//
var max:CGFloat = CGFloat(yLabels.valueForKeyPath("@max.floatValue").floatValue)
if max == 0 {
yValueMax = yMinValue
}else{
yValueMax = max
}
}
Hi, first of all, thanks for library!
I try to figure out how to set line chart to show labels correctly if there are many same values.
For example:
lineChart.xLabels = [
"27.3","28.3","29.3","30.3","31.3","1.","2.",
"3.","4.","5.","6.","7.","8.","9.",
"10.","11.","12.","13.","14.","15.","16.",
"17.","18.","19.","20.","21.","22.","23.",
"23.","24."
]
var data01Array: [CGFloat] = [
2, 4, 5, 3, 5, 2, 3,
1, 4, 2, 0, 5, 6, 4,
3, 4, 2, 1, 5, 0, 3,
2, 5, 4, 1, 3, 2, 4,
1, 5
]
produces line chart with same y labels with overflow:
There should be only 7 y labels 0, 1, 2, 3, 4, 5, 6.
Thanks for help.
Is it possible to use utilize update chart data in the Swift library or just the ObjC one?
Hello everyone,
I discover PNChart today and I'm very glad because it fits perfectly with my needs. But I have a crash when I try to instantiate a simple PNChartBar. I only want to display a simple chart.
Here is my code :
When I run it, I get an error when I try to fill the yvalue :
I probably missed something simple, so if someone could give me an advice, it would be great!
Is this distributed under the MIT license as the ObjC code?
The Obj-C version has:
barChart.rotateForXAxisText = true
this doesn't exist in the swift version
var grade = value / yValueMax.
I want to show negative values in a bar chart, how can i do it?
Please add a demo project for using with Swift. Since the Swift version does not support all charts yet.
How to make this penchant bar chart in a stacked form with 3 or more bar for each label
Unable to find a specification for PNChartSwift
In the code below, if all values are 0, yValueMax tries to ge yMinValue. But since yMinValue is not initialized, the app crashes.
func getYValueMax(yLabels:NSArray) {
let max:CGFloat = CGFloat(yLabels.valueForKeyPath("@max.floatValue") as! Float)
if max == 0 {
yValueMax = yMinValue
} else{
yValueMax = max
}
}
Can be temporarily fixed by manually setting barChart.yMinValue
when initializing.
When do you expect the circle graph and the pie graph to be enable in swift
A bit of a noob question, but I'm looking to use the PNChart-Swift library in a swift project I'm working on. Is there a trick to using is as a framework, or referencing it from an external project?
Will this PNChart-Swift version work in a Today Extension?
Thanks.
lineWidth of PNLineChartData has no affect
I love using this, but I'm needing to remove the view and redraw/readd 30 times per second, instead of updating the data dynamically. Are there any motions to enable updateChartData in this swift version?
Also, what's with the state of the issues on this git..? so many nonsensical posts.. must be frustrating...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.