Charts - iOS / tvOS / OSXのための美しいチャート!クロスプラットフォームのMPAndroidチャートのアップル側。

(Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.)

Created at: 2015-03-20 18:49:12
Language: Swift
License: Apache-2.0

バージョン4.0.0MPAndroidChart #f6a398bに同期

代替タグ サポートされているプラットフォーム リリース 最新のポッドリリース カルタゴ対応 ビルドステータス コデコフ https://gitter.im/danielgindi/Charts でチャットに参加する

注意:チャート3.0にはいくつかの重大な変更があります。リリース/移行ノートをお読みください。

別の注意:ChartsRealmは現在別のリポジトリにあります。ポッドも、チャート/コアとチャート/レルムの代わりになりました
Charts
ChartsRealm

もう1つ注意:Swiftが進化するにつれて、最新のSwiftコンパイラを使用していない場合は、マスターブランチをチェックアウトしないでください。代わりに、リリースページにアクセスして、自分に合ったものを選択する必要があります。

  • Xcode 14 / Swift 5.7(マスターブランチ)
  • iOS > = 12.0 (組み込みフレームワークとして使用)
  • tvOS >= 12.0
  • macOS >= 10.13

さて、Android開発者の間で非常に人気があるPhilipp JahodaによるMPAndroidChartと呼ばれるこの美しいライブラリがありますが、iOS用のチャートを作成するためのまともなソリューションはありませんでした。

コンパイラによって高度に最適化でき、プロジェクトの両方で使用できるため、書き込むことを選択しました。デモプロジェクトは、それがどのように機能するかを示すために書かれています。

Swift
Swift
ObjC
ObjC

Android、iOS、tvOS、macOS用のこのライブラリの驚くべき機能は、学習曲線がシングルトンであるため、両方のプラットフォームで開発するときに時間を節約できることです-それは一度だけ発生し、コードは非常に似ているため、開発者は別のライブラリで同じ出力を生成するためにアプリを再発明する必要はありません。(そして、それは現在そこに本当に別の良い選択がないという事実さえ考慮していません...)

デモの実行に問題がありますか?

  • ChartsDemo/ChartsDemo.xcodeproj
    は iOS/tvOS のデモプロジェクトです。
  • ChartsDemo-OSX/ChartsDemo-OSX.xcodeproj
    macOSのデモプロジェクトです
  • サポートされているバージョンの Xcode を実行していることを確認します。
    • 通常、ここでは上記の数行で指定されています。
    • ほとんどの場合、最新のXcodeバージョンになります。
  • プロジェクトが Swift 5.0 をサポートしていることを確認する
  • オプション:プロジェクトフォルダで実行して、依存関係をフェッチします(つまり、依存関係をテストします)。
    carthage checkout
    • カルタゴをお持ちでない場合は、ここで入手できます。

使い

正しくコンパイルするには:

  1. をプロジェクトにドラッグします。
    Charts.xcodeproj
  2. ターゲットの設定に移動し、[フレームワーク、ライブラリ、および埋め込みコンテンツ]セクションの[+]を押して、Charts.frameworkを選択します。
  3. @import Charts
  4. ObjCプロジェクトでSwiftを使用する場合:
  • ブリッジングヘッダーをインポートする必要があります。通常は "YourProject-Swift.h" なので、ChartsDemo では "ChartsDemo-Swift.h" です。プロジェクトに実際に "ChartsDemo-Swift.h"を含めようとしないでください:-)
  • (Xcode 8.1 およびそれ以前)[ビルドオプション]で、[埋め込みコンテンツにSwiftコードが含まれている]をマークします。
  • (Xcode 8.2+)[ビルドオプション]で、[常にSwift標準ライブラリを埋め込む]をマークします。
  1. Realm.io を使用する場合:
    • Realmフレームワークはチャートにリンクされておらず、オプションのバインディングのためにのみ存在することに注意してください。つまり、プロジェクトにフレームワークが必要であり、Chartsでコンパイルされたものと互換性のあるバージョンである必要があります。常に最新バージョンに対してコンパイルするように最善を尽くします。
    • 依存関係としても追加する必要があります。
      ChartsRealm

3rdパーティのチュートリアル

ビデオチュートリアル

ブログ記事

チュートリアルをここに表示したいですか?PR を作成してください。

トラブルシューティング

コンパイルできませんか?

  • CocoaPodsまたはCarthageからコンパイルされたフレームワークをインストールすることと、ソースコードをコピーすることの違いに注意してください。
  • 「使用法」セクションをもう一度お読みください。
  • 課題内を検索
  • 問題のセクションで丁寧に質問してみてください

その他の問題/機能要求

  • 課題内を検索
  • 問題のセクションで丁寧に質問してみてください

ココアポッドのインストール

ポッドファイルに追加します。「チャート」はライブラリの名前です。
Realmのサポートについては、追加してください。

pod 'Charts'
pod 'ChartsRealm'

注:ポッドの「ios-charts」は正しいライブラリではなく、他の誰かによる別のプロジェクトを参照しています。

カルタゴインストール

チャートに Carthage のビルド済みバイナリが含まれるようになりました。

github "danielgindi/Charts" == 4.1.0
github "danielgindi/Charts" ~> 4.1.0

In order to build the binaries for a new release, use

carthage build --no-skip-current && carthage archive Charts
.

Swift Package Manager Install

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/danielgindi/Charts.git", .upToNextMajor(from: "4.1.0"))
]

3rd party bindings

Xamarin (by @Flash3001): iOS - GitHub/NuGet. Android - GitHub/NuGet.

Help

If you like what you see here, and want to support the work being done in this repository, you could:

  • Contribute code, issues and pull requests
  • Let people know this library exists (🔥 spread the word 🔥)
  • Donate (You can buy me a beer, or you can buy me dinner :-)

Note: The author of MPAndroidChart is the reason that this library exists, and is accepting donations on his page. He deserves them!

Questions & Issues

If you are having questions or problems, you should:

  • Make sure you are using the latest version of the library. Check the release-section.
  • Study the Android version's Documentation-Wiki
  • Search or open questions on stackoverflow with the
    ios-charts
    tag
  • Search known issues for your problem (open and closed)
  • Create new issues (please 🔥 search known issues before 🔥, do not create duplicate issues)

Features

Core features:

  • 8 different chart types
  • Scaling on both axes (with touch-gesture, axes separately or pinch-zoom)
  • Dragging / Panning (with touch-gesture)
  • Combined-Charts (line-, bar-, scatter-, candle-stick-, bubble-)
  • Dual (separate) Axes
  • Customizable Axes (both x- and y-axis)
  • Highlighting values (with customizable popup-views)
  • Save chart to camera-roll / export to PNG/JPEG
  • Predefined color templates
  • Legends (generated automatically, customizable)
  • Animations (build up animations, on both x- and y-axis)
  • Limit lines (providing additional information, maximums, ...)
  • Fully customizable (paints, typefaces, legends, colors, background, gestures, dashed lines, ...)
  • Plotting data directly from Realm.io mobile database (here)

Chart types:

Screenshots are currently taken from the original repository, as they render exactly the same :-)

  • LineChart (with legend, simple design) alt tag

  • LineChart (with legend, simple design) alt tag

  • LineChart (cubic lines) alt tag

  • LineChart (gradient fill) alt tag

  • Combined-Chart (bar- and linechart in this case) alt tag

  • BarChart (with legend, simple design)

alt tag

  • BarChart (grouped DataSets)

alt tag

  • Horizontal-BarChart

alt tag

  • PieChart (with selection, ...)

alt tag

  • ScatterChart (with squares, triangles, circles, ... and more)

alt tag

  • CandleStickChart (for financial data)

alt tag

  • BubbleChart (area covered by bubbles indicates the value)

alt tag

  • RadarChart (spider web chart)

alt tag

Documentation

Currently there's no need for documentation for the iOS/tvOS/macOS version, as the API is 95% the same as on Android.
You can read the official MPAndroidChart documentation here: Wiki

Or you can see the Charts Demo project in both Objective-C and Swift (ChartsDemo-iOS, as well as macOS ChartsDemo-macOS) and learn the how-tos from it.

Special Thanks

Goes to @liuxuan30, @petester42 and @AlBirdie for new features, bugfixes, and lots and lots of involvement in our open-sourced community! You guys are a huge help to all of those coming here with questions and issues, and I couldn't respond to all of those without you.

Our amazing sponsors

Debricked: Use open source securely

debricked

License

Copyright 2016 Daniel Cohen Gindi & Philipp Jahoda

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.