• Stars
    star
    108
  • Rank 311,196 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This library allows implementing charts into mobile apps

Mobile Analytics Chart

PlatformCocoaPods compatibleSPM compatibleLicense: MIT


Feature


Animation redrawing

Animation redrawing

Gestures

Gestures

Loading state

Loading state

An intermediate value

An intermediate value

Supported

  • Multiple chart
  • Dragging and panning
  • Single point display
  • Animation redrawing
  • Customization
  • Dark Theme

Chart configuration

  • Quantity and currency units
  • Linear, quadratic and horizontalQuadratic path type
  • Gradient

Render configuration

  • Customize range label, XAxis, YAxis, zero line, definition view
  • Toggle gesture (Swipe, pinch and handle)
  • Setup redraw animation duration
  • Configure insets and margins

Calculator configuration

  • Setup minimum and maximum like custom value or these values will be recalculated automatically
  • Customize automatically recalculated line width

Changelog

Link to Changelog

Connecting dependencies

Swift Package Manager

dependencies: [
  .package(url: "https://github.com/yoomoney/mobile-analytics-chart-swift")
],
targets: [
  .target(
    name: "MyProject",
    dependencies: [..., "MobileAnalyticsChartSwift"]
  )
...
]

CocoaPods

  1. Install CocoaPods
gem install cocoapods
  1. Create file Podfile\

CocoaPods provides pod init command to create a Podfile with default settings.

  1. Add dependencie in Podfile.
    Example Podfilefrom demo-app.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target 'Your Target Name' do
pod 'MobileAnalyticsChartSwift',
  :git => 'https://github.com/yoomoney/mobile-analytics-chart-swift.git',
  :tag => 'tag'
end

Your Target Name - the target name in Xcode for your application.
tag - SDK version. The current version can be found on github in the releases.

  1. Run the command pod install

Carthage

Carthage is not currently supported.

Fast integration

  1. Create AnalyticsChartSpriteKitModuleInputData.

To work with MobileAnalyticsChartSwift entities, import the dependencies into the source file

import MobileAnalyticsChartSwift

An example of creating a AnalyticsChartSpriteKitModuleInputData:

// Creating a fade animation configuration
let fadeAnimation = ChartFadeAnimation(
  fadeOutColor: UIColor(white: 219 / 255, alpha: 1),
  fadeInColor: UIColor(white: 236 / 255, alpha: 1),
  startDuration: 0.2,
  fadeOutDuration: 0.6,
  fadeInDuration: 0.6
)

// Creating date formatters
let dmmmyyyyDateFormatter = DateFormatter()
dmmmyyyyDateFormatter.dateFormat = "d MMM yyyy"
let dmmmDateFormatter = DateFormatter()
dmmmDateFormatter.dateFormat = "d MMM"

// Creating a chart data
let calendar = Calendar.current
let dates = (0 ..< 6).compactMap {
  calendar.date(byAdding: DateComponents(day: $0), to: Date())
}
let values: [CGFloat] = [4, 8, 15, 16, 23, 42]
let chartData = ChartData(
  values: values,
  dates: dates
)
let path = ChartPath(
  type: .horizontalQuadratic,
  color: UIColor(red: 51 / 255, green: 102 / 255, blue: 1, alpha: 1),
  minWidth: 1.0,
  maxWidth: 5.0,
  fadeAnimation: fadeAnimation
)
let chartRenderConfiguration = ChartRenderConfiguration(
  unit: .quantity,
  path: path,
  gradient: nil
)
let analyticsChartSpriteKitViewModel = AnalyticsChartSpriteKitViewModel(
  data: chartData,
  configuration: chartRenderConfiguration
)

// Creating a range label configuration
let rangeLabel = ChartRangeLabel(
  color: UIColor(white: 102 / 255, alpha: 1),
  font: .systemFont(ofSize: 13, weight: .regular),
  dateFormatter: dmmmyyyyDateFormatter,
  insets: UIEdgeInsets(top: 16, left: 0, bottom: 16, right: 0)
)

// Creating a xAxis configuration
let xAxis = ChartXAxis(
  labelColor: UIColor(white: 179 / 255, alpha: 1),
  labelFont: .systemFont(ofSize: 11, weight: .regular),
  dateFormatter: dmmmDateFormatter,
  insets: UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0),
  margins: UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16),
  zoomFactorLabels: 1.5
)

// Creating a yAxis configuration
let yAxis = ChartYAxis(
  labelColor: UIColor(white: 179 / 255, alpha: 1),
  labelFont: .systemFont(ofSize: 11, weight: .regular),
  labelInsets: UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 0),
  lineColor: UIColor(white: 0, alpha: 0.12),
  lineWidth: 1
)

// Creating a zero line
let zeroLine = ChartZeroLine(
    color: UIColor(white: 236 / 255, alpha: 1),
    width: 1
)

// Creating a gesture state configuration
let gestureState = ChartGestureState(
  swipeIsActive: true,
  pinchIsActive: true,
  handleIsActive: true
)

// Creating a animation configuration
let animation = ChartAnimation(
  redrawDuration: 0.2
)

// Creating a definition configuration
let definitionView = ChartDefinitionView(
  backgroundColor: UIColor(red: 0.043, green: 0.09, blue: 0.204, alpha: 1),
  valueLabelFont: .systemFont(ofSize: 13),
  valueLabelColor: UIColor(white: 0.95, alpha: 1.0),
  dateLabelFont: .systemFont(ofSize: 11),
  dateLabelColor: UIColor(white: 0.7, alpha: 1.0),
  dateFormatter: dmmmyyyyDateFormatter
)
let definition = ChartDefinition(
  line: ChartDefinitionLine(color: UIColor(white: 236 / 255, alpha: 1), width: 1),
  point: ChartDefinitionPoint(minRadius: 4, maxRadius: 8),
  view: definitionView,
  fadeAnimation: fadeAnimation
)

// Creating a chart sprite kit module input data
let chartViewModel = AnalyticsChartSpriteKitModuleInputData(
  viewModels: [analyticsChartSpriteKitViewModel],
  renderConfiguration: RenderConfiguration(
    rangeLabel: rangeLabel,
    xAxis: xAxis,
    yAxis: yAxis,
    zeroLine: zeroLine,
    gestureState: gestureState,
    animation: animation,
    definition: definition,
    backgroundColor: UIColor(white: 247 / 255, alpha: 1),
    chartInsets: .zero,
    chartMargins: UIEdgeInsets(top: 64, left: 0, bottom: 0, right: 0),
    fadeInDuration: 0.3,
    fadeOutDuration: 0.3
  ),
  calculatorConfiguration: CalculatorConfiguration(
    minStaticValue: nil,
    maxStaticValue: nil
  )
)
  1. Create ChartView and AnalyticsChartSpriteKitModuleInput using AnalyticsChartSpriteKitAssembly.

An example of creating:

let (chartView, moduleInput) = AnalyticsChartSpriteKitAssembly.makeModule(
  inputData: chartViewModel
)
  1. ChartView is a UIView and you can use it wherever you want.
  2. With AnalyticsChartSpriteKitModuleInput you can set charts, set visibility range and enable or disable charts loading state.

Run Example

To run the Example application, you need to:

  1. Make a git clone of the repository.
git clone https://github.com/yoomoney/mobile-analytics-chart-swift.git
  1. Go to the project folder in the console and execute the following commands:
gem install bundler
bundle
pod install
  1. Open MobileAnalyticsChartSwift.xcworkspace.
  2. Select and run a scheme MobileAnalyticsChartSwiftExamplePods.

License

Mobile Analytics Chart Swift available under the MIT license. See the LICENSE file for more information.

More Repositories

1

db-queue

Worker-queue implementation on top of Java and database
Java
218
star
2

yookassa-github-docs

104
star
3

yookassa-sdk-php

PHP SDK for YooKassa Payments API
PHP
59
star
4

grafana-dashboard-dsl

DSL for generating Grafana dashboards
Kotlin
53
star
5

yookassa-payments-swift

This library allows implementing payment acceptance into mobile apps on iOS and works as an extension to the YooMoney API
Swift
41
star
6

yookassa-sdk-python

Python SDK for YooKassa Payments API
Python
37
star
7

yookassa-android-sdk

This library allows implementing payment acceptance into mobile apps on Android. It works as an extension to the YooMoney API.
Kotlin
36
star
8

functional-swift

This library provide many various extensions for swift
Swift
24
star
9

cms-opencart3

YooKassa payment module for Opencart 3.x
PHP
21
star
10

android-activitylifecyclecallbacks-example

This repository contains usage examples of ActivityLifecycleCallbacks in Android for the article at Medium and Habr.
Kotlin
20
star
11

yoomoney-sdk-java

This Java library contains classes that allows you to do payments and call other methods of YooMoney public API
Java
19
star
12

grafana-dashboard-plugin

Gradle plugin for grafana dashboards publication
Java
16
star
13

db-queue-scheduler

Periodic task executions on top of db-queue library
Java
15
star
14

cms-prestashop

YooKassa payment module for PrestaShop
PHP
11
star
15

check-dependencies-plugin

Gradle plugin for working with dependencies
Java
8
star
16

cms-opencart2

YooKassa payment module for Opencart 2.x
PHP
8
star
17

openapi-bundler

Kotlin
5
star
18

yookassa-payout-sdk-python

Python SDK for YooKassa Payouts API
Python
4
star
19

yandex-checkout-sdk-php

PHP
4
star
20

java-plugin

The gradle-plugin for building java-projects
Kotlin
3
star
21

cms-drupal8

YooKassa payment module for Drupal 8.x
PHP
3
star
22

library-project-plugin

The gradle-plugin for building libraries
Java
2
star
23

moira-kotlin-dsl

Domain Specific Language (DSL) designed to describe Moira triggers.
Kotlin
2
star
24

artifact-release-plugin

The gradle-plugin to release libraries
Kotlin
2
star
25

cms-joomshopping

YooKassa payment module for Joomla 3.x + JoomShopping 4.x
PHP
2
star
26

java-artifact-publish-plugin

The gradle-plugin for publishing artifacts
Kotlin
2
star
27

yoomoney-sdk-objc

This open-source library allows you to work with YooMoney API
Objective-C
2
star
28

gradle-project-plugin

Gradle plugin for building gradle plugins
Java
2
star
29

cms-simpla

YooKassa payment module for Simpla
PHP
2
star
30

cms-modx-shopkeeper

YooKassa payment module for ModX Revolution + ShopKeeper 1.x, 2.x
PHP
2
star
31

yoomoney-core-api-swift

This library allows implementing network layer into mobile apps or sdk
Swift
2
star
32

yookassa-payout-sdk-php

PHP SDK for YooKassa Payouts API
PHP
2
star
33

cms-oscommerce

YooKassa payment module for osCommerce
PHP
2
star
34

metrica-logging-ios

This repository contains usage examples of metric logging in iOS for the YooMoney day conference
Swift
1
star
35

yookassa-wallet-api-swift

This library contains classes for connection to the YooMoney Wallet API
Swift
1
star
36

weblate-plugin

Gradle plugin for extracting translations from Weblate
Kotlin
1
star
37

cms-opencart15

YooKassa payment module for Opencart 1.5
PHP
1
star
38

yoomoney.github.io

https://opensource.yoomoney.ru/
TypeScript
1
star
39

march-android

This library provide structure and classes for building architecture in mobile apps
Kotlin
1
star
40

cms-hostcms

YooKassa payment module for HostCMS
PHP
1
star
41

moira-trigger-plugin

Gradle plugin for integration with moira-trigger-dsl
Kotlin
1
star
42

cms-drupal7

YooKassa payment module for Drupal 7.x
PHP
1
star
43

pure-process

Primitives for business logic structuring
JavaScript
1
star