Skip to content

Lightning-Chart/lcjs-ios-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightningChart® JS iOS usage example

This repository showcases how to use LightningChart® JS charting library in a iOS project.

More information about LightningChart® JS can be found from our website, https://www.arction.com/lightningchart-js/.

Getting Started

The project can be opened with XCode and run on the emulator or an actual device. Refer to the Apple Developer Guide for instructions for iOS development.

The chart is running inside a WKWebView. Data is send from the native swift code to the WKWebView to be displayed. You can find the source code for the charts from /iOS/assets. index.html is the page that is running inside the WKWebView and contains the JavaScript for configuring the chart. lcjs.iife.js is IIFE packaged version of LightningChart® JS that can be found inside the NPM package.

JavaScript has to be enabled on iOS device (enabled by default) on the WebView for the chart to work.

Sending data to the chart

Data can be send to the chart from native Swift code with the help of evaluateJavaScript method.

    chart.evaluateJavaScript("setData(\(self.yData), \((self.xData)));") { (any, error) in
        if((error) != nil){ print("Error : \(String(describing: error))")}
    }

The setData is a JavaScript method that has been defined inside the WKWebView. The evaluateJavascript method will call that method to set data in the chart. The contents of yData and xData are provided as the arguments to the setData method.

  function setData(ySet, xSet){
         if(ySet.length && xSet.length){
             const chartData = xSet.map( ( itr1, itr2 ) => ( { x: itr1, y: ySet[itr2] } ) )
             lineSeries.add(chartData)
         }
     }

Support

If you notice an error in the example code, please open an issue on GitHub.

Official API documentation can be found on Arction website.

If the docs and other materials do not solve your problem as well as implementation help is needed, ask on StackOverflow (tagged lightningchart).

If you think you found a bug in the LightningChart JavaScript library, please contact support@arction.com.

Direct developer email support can be purchased through a Support Plan or by contacting sales@arction.com.

© Arction Ltd 2009-2020. All rights reserved.

Android is a trademark of Google LLC.

About

iOS project template with LightningChart JS

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors