android怎么定义幂函数,GitHub - CrystalMarch/CoordinateAxisChart: Drawing graphs of point, linear function, ...

CoordinateAxisChart

Drawing graphs of point, linear function, power function, exponential function, logarithmic function, circular function, etc in a coordinate. (实现了在坐标系中画点,一次函数,幂函数,指数函数,对数函数,三角函数等)

for instance:

linear function(一次函数): yAxis = xAxis - 3

power function(幂函数): yAxis = pow(xAxis, 2)

exponential function(指数函数): yAxis = pow(2, xAxis)

logarithmic function, xAxis should be greater than zero(对数函数, 此时应该设置axis的值大于0): yAxis = log (xAxis)

circular function(三角函数), like sin, cos, tan: yAxis = sin (xAxis)

Android version entrance

Effect picture

d382e46f80b8a2c27b93353ec99ef6ff.gif

5d4c94ffe9a11ff6ef902b80956acb22.png

527b4aaab6f040be079c200932d229df.png

Installation

CocoaPods

Add to your Podfile:

Swift:

use_frameworks!

pod 'CoordinateAxisChart', '~> 1.0.1'

Note: To use Swift 3.x / master, you need Xcode 8+

To use master directly (it's usually stable):

pod 'CoordinateAxisChart', :git => 'https://github.com/CrystalMarch/CoordinateAxisChart.git'

And then:

pod install

Import the framework in your code:

import CoordinateAxisChart

Quick start

let chartView = CoordinateAxisChart()

chartView.frame = CGRect(x:50,y:50,width:220,height:220)

var pointData: [CGPoint] = []

for i in -40...70 {

let xAxis = CGFloat(i)/10

let yAxis = sin (xAxis)

pointData.append(CGPoint(x:xAxis,y:yAxis))

}

chartView.setPointData(pointData: pointData, chartType: .line,lineOrPointColor:UIColor .red,animation: true)

chartView.xMaxValue = 7

chartView.animationTime = 2

chartView.axisColor = UIColor.gray

chartView.xMinValue = -4

chartView.yMaxValue = 3

chartView.yMinValue = -3

self.view.addSubview(chartView)

func refreshButonClick(sender:UIButton) {

chartView.refresh()

}

func clearButtonClick(sender:UIButton) {

chartView.clear()

}

func changeAxisColorButtonClick(sender: UIButton) {

let red = CGFloat(arc4random()%256)/255.0

let green = CGFloat(arc4random()%256)/255.0

let blue = CGFloat(arc4random()%256)/255.0

chartView.axisColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0)

}

func changeAxisValueButtonClick(sender:UIButton) {

chartView.xMaxValue = Int(arc4random()%10)

chartView.xMinValue = -Int(arc4random()%10)

chartView.yMaxValue = Int(arc4random()%10)

chartView.yMinValue = -Int(arc4random()%10)

}

Properties:

xMaxValue:

set the max value of x axis(设置x轴的最大值)

xMinValue:

set the min value of x axis(设置x轴的最小值)

yMaxValue:

set the max value of y axis(设置y轴的最大值)

yMinValue:

set the min value of y axis(设置y轴的最小值)

axisColor:

set the color of the axis(设置坐标轴的颜色)

animationTime:

set the animation time of draw line(设置画函数线条的动画时间)

Function:

setPointData(pointData:[CGPoint],chartType:ChartType,lineOrPointColor:UIColor,animation:Bool)

pointDate: set the data for chart

chartType: set the chart type (line or point)

lineOrPointColor: set the line or point color

animation: set whether animation is needed

refresh()

clear()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值