MLLineChart

 

Swift 5.0 Platforms License Swift Package Manager Carthage compatible CocoaPods compatible Travis

一个简单的折线图库

系统要求

安装

CocoaPods

将以下行添加到您的 Podfile

pod "MLLineChart"

$ pod install

依赖管理器

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要使用 CocoaPods 将 MLLineChart 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

pod 'MLLineChart', '~> 2.0.5'

然后,运行以下命令

$ pod install
Carthage

Carthage 是一个去中心化的依赖管理器,它可以自动化向您的 Cocoa 应用程序添加框架的过程。

您可以使用 Homebrew 使用以下命令安装 Carthage

$ brew update
$ brew install carthage

要使用 Carthage 将 MLLineChart 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它

github "micheltlutz/MLLineChart" ~> 2.0.5

手动安装

如果您不想使用上述任何依赖管理器,您可以手动将 MLLineChart 集成到您的项目中。

Git 子模块

$ git init
$ git submodule add https://github.com/micheltlutz/MLLineChart.git
$ git submodule update --init --recursive

MLLineChart.framework 被自动添加为目标依赖项、链接框架和嵌入式框架,在一个复制文件构建阶段中,这就是在模拟器和设备上构建所需的一切。

嵌入式二进制文件

使用方法

import MLLineChart

class ViewController: UIViewController {
	 private var lineChart: MLLineChart!
    private var dataEntries: [MLPointEntry] = []
    var widthChart = CGFloat(320)
    var heightChart = CGFloat(275)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        makeData()
        setupChart()
    }

    private func makeData() {
        dataEntries.append(MLPointEntry(value: 5, label: "1", color: .gray))
        dataEntries.append(MLPointEntry(value: 6, label: "2", color: .green))
        dataEntries.append(MLPointEntry(value: 4, label: "3", color: .blue))
    }

    private func setupChart() {
        lineChart = MLLineChart(frame: CGRect(x: 0, y: 0, width: widthChart, height: heightChart))
        lineChart.translatesAutoresizingMaskIntoConstraints = false
        lineChart.dataEntries = dataEntries
        lineChart.lineColor = .gray
        lineChart.lineWidth = 2
        lineChart.showShadows = true
        lineChart.showAxisLine = true
        lineChart.gradienLinesColors = [UIColor.gray.cgColor, UIColor.green.cgColor, UIColor.blue.cgColor]
        lineChart.configLabelsBottom = MLLabelConfig(color: .white,
                                                           backgroundColor: .gray,
                                                           rounded: true,
                                                           font: UIFont.systemFont(ofSize: 11),
                                                           width: 16, height: 16, fontSize: 11)
    }    
    /// Cntinue your code
    
}

文档

MLLineChart 文档 (- 已记录)

演示应用

在此项目上使用 MLLineChartDemo Target

     

贡献

欢迎提交 Issue 和 Pull Request!

待办事项

作者

Michel Anderson Lutz Teixeira @michel_lutz

灵感来自 nhatminh12369/LineChart

我的网站

贡献

许可证

MLLineChart 基于 MIT 许可证发布。有关详细信息,请参阅 LICENSE