Skip to content

Commit

Permalink
Merge pull request #10 from greenJVS/update_to_version_3_2
Browse files Browse the repository at this point in the history
Update lightweight-charts to 3.2
  • Loading branch information
timocov authored Nov 16, 2020
2 parents efedcf7 + d0e1cfa commit 6a9320a
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Example/LightweightCharts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
INFOPLIST_FILE = LightweightCharts/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 3.1.5;
MARKETING_VERSION = 3.2.0;
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "tradingview.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -638,7 +638,7 @@
INFOPLIST_FILE = LightweightCharts/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 3.1.5;
MARKETING_VERSION = 3.2.0;
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "tradingview.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- LightweightCharts (3.1.5)
- LightweightCharts (3.2.0)

DEPENDENCIES:
- LightweightCharts (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
LightweightCharts: 89edd9005561a7a88ba73341a7c7d9a5b850b4f9
LightweightCharts: 04cf1c18f24019889976b0de40bef2329916e020

PODFILE CHECKSUM: 10aa45b030d82b96cfc0e4e3b143c5488576107b

Expand Down
6 changes: 3 additions & 3 deletions LightweightCharts.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'LightweightCharts'
s.version = '3.1.5'
s.version = '3.2.0'
s.summary = 'LightweightCharts for iOS.'
s.description = 'LightweightCharts pod. Swift wrapper above JavaScript library.'
s.homepage = 'https://tradingview.com'
Expand All @@ -19,9 +19,9 @@ Pod::Spec.new do |s|
:script => 'LIBRARY=${TEMP_DIR}/lightweight-charts.js
if [ "${CONFIGURATION}" = "Release" ]; then
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.1.5/dist/lightweight-charts.standalone.production.js
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.2.0/dist/lightweight-charts.standalone.production.js
else
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.1.5/dist/lightweight-charts.standalone.development.js
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.2.0/dist/lightweight-charts.standalone.development.js
fi
cp -f $LIBRARY ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/lightweight-charts.js'
Expand Down
16 changes: 15 additions & 1 deletion LightweightCharts/Classes/Implementations/API/TimeScale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,22 @@ extension TimeScale: TimeScaleApi {
context?.evaluateScript(script, completion: nil)
}

func logicalToCoordinate(logical: Logical, completion: @escaping (Coordinate?) -> Void) {
let script = "\(jsName).logicalToCoordinate(\(logical));"
context?.evaluateScript(script) { (result, _) in
completion(result as? Coordinate)
}
}

func coordinateToLogical(x: Double, completion: @escaping (Logical?) -> Void) {
let script = "\(jsName).coordinateToLogical(\(x));"
context?.evaluateScript(script) { (result, _) in
completion(result as? Logical)
}
}

func timeToCoordinate(time: Time, completion: @escaping (Coordinate?) -> Void) {
let script = "\(jsName).timeToCoordinate(\(time.jsonString);"
let script = "\(jsName).timeToCoordinate(\(time.jsonString));"
context?.evaluateScript(script) { (result, _) in
completion(result as? Coordinate)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ public struct PriceLineOptions: Codable {
public var lineWidth: LineWidth?
public var lineStyle: LineStyle?
public var axisLabelVisible: Bool?
public var title: String?

public init(price: Double? = nil,
color: ChartColor? = nil,
lineWidth: LineWidth? = nil,
lineStyle: LineStyle? = nil,
axisLabelVisible: Bool? = nil) {
axisLabelVisible: Bool? = nil,
title: String? = nil) {
self.price = price
self.color = color
self.lineWidth = lineWidth
self.lineStyle = lineStyle
self.axisLabelVisible = axisLabelVisible
self.title = title
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import Foundation

public enum PriceLineSource: Int, Codable {
/**
* The last bar data
*/
case lastBar
/**
* The last visible bar in viewport
*/
case lastVisible
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
public var lastValueVisible: Bool?
public var title: String?
public var priceScaleId: String?
public var visible: Bool?
public var priceLineVisible: Bool?
public var priceLineSource: PriceLineSource?
public var priceLineWidth: LineWidth?
Expand All @@ -28,6 +29,7 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
public init(lastValueVisible: Bool? = nil,
title: String? = nil,
priceScaleId: String? = nil,
visible: Bool? = nil,
priceLineVisible: Bool? = nil,
priceLineSource: PriceLineSource? = nil,
priceLineWidth: LineWidth? = nil,
Expand All @@ -49,6 +51,7 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
self.visible = visible
self.priceLineVisible = priceLineVisible
self.priceLineSource = priceLineSource
self.priceLineWidth = priceLineWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public struct BarSeriesOptions: SeriesOptionsCommon {
public var lastValueVisible: Bool?
public var title: String?
public var priceScaleId: String?
public var visible: Bool?
public var priceLineVisible: Bool?
public var priceLineSource: PriceLineSource?
public var priceLineWidth: LineWidth?
Expand All @@ -25,6 +26,7 @@ public struct BarSeriesOptions: SeriesOptionsCommon {
public init(lastValueVisible: Bool? = nil,
title: String? = nil,
priceScaleId: String? = nil,
visible: Bool? = nil,
priceLineVisible: Bool? = nil,
priceLineSource: PriceLineSource? = nil,
priceLineWidth: LineWidth? = nil,
Expand All @@ -43,6 +45,7 @@ public struct BarSeriesOptions: SeriesOptionsCommon {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
self.visible = visible
self.priceLineVisible = priceLineVisible
self.priceLineSource = priceLineSource
self.priceLineWidth = priceLineWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public struct CandlestickSeriesOptions: SeriesOptionsCommon {
public var lastValueVisible: Bool?
public var title: String?
public var priceScaleId: String?
public var visible: Bool?
public var priceLineVisible: Bool?
public var priceLineSource: PriceLineSource?
public var priceLineWidth: LineWidth?
Expand Down Expand Up @@ -75,6 +76,7 @@ public struct CandlestickSeriesOptions: SeriesOptionsCommon {
public init(lastValueVisible: Bool? = nil,
title: String? = nil,
priceScaleId: String? = nil,
visible: Bool? = nil,
priceLineVisible: Bool? = nil,
priceLineSource: PriceLineSource? = nil,
priceLineWidth: LineWidth? = nil,
Expand All @@ -99,6 +101,7 @@ public struct CandlestickSeriesOptions: SeriesOptionsCommon {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
self.visible = visible
self.priceLineVisible = priceLineVisible
self.priceLineSource = priceLineSource
self.priceLineWidth = priceLineWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public struct HistogramSeriesOptions: SeriesOptionsCommon {
public var lastValueVisible: Bool?
public var title: String?
public var priceScaleId: String?
public var visible: Bool?
public var priceLineVisible: Bool?
public var priceLineSource: PriceLineSource?
public var priceLineWidth: LineWidth?
Expand All @@ -23,6 +24,7 @@ public struct HistogramSeriesOptions: SeriesOptionsCommon {
public init(lastValueVisible: Bool? = nil,
title: String? = nil,
priceScaleId: String? = nil,
visible: Bool? = nil,
priceLineVisible: Bool? = nil,
priceLineSource: PriceLineSource? = nil,
priceLineWidth: LineWidth? = nil,
Expand All @@ -39,6 +41,7 @@ public struct HistogramSeriesOptions: SeriesOptionsCommon {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
self.visible = visible
self.priceLineVisible = priceLineVisible
self.priceLineSource = priceLineSource
self.priceLineWidth = priceLineWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
public var lastValueVisible: Bool?
public var title: String?
public var priceScaleId: String?
public var visible: Bool?
public var priceLineVisible: Bool?
public var priceLineSource: PriceLineSource?
public var priceLineWidth: LineWidth?
Expand All @@ -27,6 +28,7 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
public init(lastValueVisible: Bool? = nil,
title: String? = nil,
priceScaleId: String? = nil,
visible: Bool? = nil,
priceLineVisible: Bool? = nil,
priceLineSource: PriceLineSource? = nil,
priceLineWidth: LineWidth? = nil,
Expand All @@ -47,6 +49,7 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
self.visible = visible
self.priceLineVisible = priceLineVisible
self.priceLineSource = priceLineSource
self.priceLineWidth = priceLineWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public protocol SeriesOptionsCommon: Codable {
*/
var priceScaleId: String? { get }

/**
Visibility of series.
*/
var visible: Bool? { get }

/**
Visibility of the price line. Price line is a horizontal line indicating the last price of the series
*/
Expand Down
17 changes: 16 additions & 1 deletion LightweightCharts/Classes/Protocols/TimeScaleApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,28 @@ public protocol TimeScaleApi: class {
*/
func fitContent()

/**
* Converts a logical index to local x coordinate.
*
* - Parameter logical: logical index needs to be converted
* - Parameter completion: x coordinate of that time or `null` if the chart doesn't have data
*/
func logicalToCoordinate(logical: Logical, completion: @escaping (Coordinate?) -> Void)

/**
* Converts a coordinate to logical index.
*
* - Parameter x: coordinate needs to be converted
* - Parameter completion: logical index that is located on that coordinate or `null` if the chart doesn't have data
*/
func coordinateToLogical(x: Double, completion: @escaping (Logical?) -> Void)

/**
* Converts a time to local x coordinate.
*
* @param time - time needs to be converted
* @returns x coordinate of that time or `null` if no time found on time scale
*/

func timeToCoordinate(time: Time, completion: @escaping (Coordinate?) -> Void)
/**
* Converts a coordinate to time.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LightweightCharts is available through [CocoaPods](https://cocoapods.org). To in
it, just simply add the following line to your Podfile:

```ruby
pod 'LightweightCharts', '~> 3.1.5'
pod 'LightweightCharts', '~> 3.2.0'
```
## Usage

Expand Down

0 comments on commit 6a9320a

Please sign in to comment.