LoginSignup
63
59

More than 5 years have passed since last update.

[Swift] [iOS] チャート表示ライブラリ [ios-charts] 詳細な使い方

Last updated at Posted at 2016-02-01

目的

前回の記事のより詳細な紹介。

プロパティ

ChartViewBase (全てのチャートに含まれる)

UIViewを継承。

// タップでデータを選択できるか
.highlightPerTapEnabled = true

// 指を離してもスクロールが続くか
.dragDecelerationEnabled = true

// 指を離してからの自動スクロールの減速度合い(0~1)
.dragDecelerationFrictionCoef = 0.9

// description textのフォント、フォントカラー
.descriptionFont = UIFont(name: "HelveticaNeue", size: 9.0)
.descriptionTextColor UIColor.blackColor()

// description textの整列
.descriptionTextAlign = NSTextAlignment.Right

// description textの表示位置
.descriptionTextPosition = nil

// information textのフォント、フォントカラー
.infoFont = UIFont(name: "HelveticaNeue", size: 12.0)
.infoTextColor = UIColor(red: 247.0/255.0, green: 189.0/255.0, blue: 51.0/255.0, alpha: 1.0) // orange

// description textの内容
.descriptionText = "Description"

// データがない時に表示するテキスト
.noDataText = "No chart data available."

// なぜ、データが無いかを説明するテキスト
.noDataTextDescription = ""

// グラフの余白
.extraTopOffset = 0.0
.extraRightOffset = 0.0
.extraBottomOffset = 0.0
.extraLeftOffset = 0.0

BarLineChartViewBase

ChartViewBaseを継承。

// ピンチでズームが可能か
.pinchZoomEnabled = false

// ダブルタップでズームが可能か
.doubleTapToZoomEnabled = true

// ドラッグ可能か
.dragEnabled = true

// X,Y方向にズーム可能か
.scaleYEnabled = true
.scaleYEnabled = true

// チャートエリアの背景色
.gridBackgroundColor = UIColor(red: 240/255.0, green: 240/255.0, blue: 240/255.0, alpha: 1.0)

// ボーダーの色、太さ
borderColor = UIColor.blackColor()
borderLineWidth: CGFloat = 1.0

// グリッド線の表示
.drawGridBackgroundEnabled = false

// 境界線の表示
.drawBordersEnabled = false

// 最小のオフセット
.minOffset = CGFloat(10.0)

// 左のY軸
.leftAxis: ChartYAxis!

// 右のY軸
.rightAxis: ChartYAxis!

// X軸
.xAxis: ChartXAxis!

ChartYAxis, ChartXAxisについては[Swift] [iOS] チャート表示ライブラリ [ios-charts] 軸に関する設定を参照。

BarLineChartView

BarLineChartViewBaseを継承。

// 選択されたバーの右上に三角形の印でハイライトするか
.drawHighlightArrowEnabled = false

// バー上にある値の表示(バー内か、バーより上か)
.drawValueAboveBarEnabled = true

// それぞれのバーにグレーのエリアが描画される
.drawHighlightArrowEnabled = false

メソッド

ChartViewBase (全てのチャートに含まれる)

UIViewを継承。

// グラフの余白
func setExtraOffsets(left left: CGFloat, top: CGFloat, right: CGFloat, bottom: CGFloat)
63
59
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
63
59