Giter Site home page Giter Site logo

crystalmarch / coordinateaxischart Goto Github PK

View Code? Open in Web Editor NEW
101.0 5.0 11.0 2.88 MB

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

Swift 96.20% Ruby 3.80%
swift ios mathematics chart coordinates cocoapods

coordinateaxischart's Introduction

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

CoordinateAxisChart for Android

Effect picture

alt text alt text alt text

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()

coordinateaxischart's People

Contributors

adamnemecek avatar crystalmarch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

coordinateaxischart's Issues

怎么刷新数据重新显示?

这个坐标图感觉非常好用。现在有个需求,画好图后怎么在不移除chartView的条件下,删除旧数据,导入新数据,重新刷新画图呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.