MLLineChart 2.0.5

MLLineChart 2.0.5

Michel Anderson Lutz Teixeira 维护。



MLLineChart

 

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

一个简单的折线图库

要求

  • iOS 10.0+ / tvOS 9.0+
  • Xcode 10.2.1+

安装

CocoaPods

将以下行添加到 Podfile 中

pod "MLLineChart"

$ pod install

依赖管理器

CocoaPods

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

$ gem install cocoapods

要将MLLineChart集成到您的Xcode项目并使用CocoaPods,请在您的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子模块

  • 在终端中打开,使用cd进入您的顶级项目目录,并运行以下命令(如果您的项目未初始化为git仓库):
$ git init
  • 通过运行以下命令将MLLineChart作为git 子模块添加:
$ git submodule add https://github.com/micheltlutz/MLLineChart.git
$ git submodule update --init --recursive
  • 打开新的MLLineChart文件夹,将MLLineChart.xcodeproj拖动到您的应用程序Xcode项目的Project Navigator中。

    它应该嵌套在您的应用程序蓝色项目图标下。它是在所有其他Xcode组之上还是之下都无关紧要。

  • 在Project Navigator中选中MLLineChart.xcodeproj,并验证其部署目标与您的应用程序目标相匹配。

  • 然后,在Project Navigator中(蓝色项目图标)导航到目标配置窗口,并选择侧边栏中“Targets”标题下的应用程序目标。

  • 在此窗口的标签栏中,打开“General”面板。

  • 在“Embedded Binaries”部分下单击+按钮。

  • 您将看到两个不同的MLLineChart.xcodeproj文件夹,每个文件夹都有两个不同版本的MLLineChart.framework,嵌套在“Products”文件夹内。

    您可以从哪个“Products”文件夹选择都无关紧要。

  • 选择MLLineChart.framework

  • 这就结束了!

MLLineChart.framework会被自动添加为目标依赖项,并在复制文件构建阶段作为链接库和嵌入式库,这是在模拟器和设备上构建所必需的。

嵌入式Binary

  • https://github.com/micheltlutz/MLLineChart/releases下载最新版本。
  • 然后,在Project Navigator中(蓝色项目图标)导航到目标配置窗口,并选择侧边栏中“Targets”标题下的应用程序目标。
  • 在此窗口的标签栏中,打开“General”面板。
  • 在“Embedded Binaries”部分下单击+按钮。
  • 添加下载的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 目标

     

贡献

问题和拉取请求均受欢迎!

待办事项

  • 迁移到 Swift 4.2
  • 重新支持曲线下的线条
  • 100% 已记录

作者

Michel Anderson Lutz Teixeira @michel_lutz

灵感来源于 nhatminh12369/LineChart

我的网站

贡献

许可证

MLLineChart 在 MIT 许可下发布。有关详细信息,请参阅许可证