Skip to content

Commit

Permalink
Merge pull request #14 from tradingview/feature/migrate_to_3_3
Browse files Browse the repository at this point in the history
Migrate to lightweight 3.3.0
  • Loading branch information
dbelousov-tv authored Mar 2, 2021
2 parents 91bd408 + f0cd8a5 commit 1cf93ff
Show file tree
Hide file tree
Showing 11 changed files with 50 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.2.0;
MARKETING_VERSION = 3.3.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.2.0;
MARKETING_VERSION = 3.3.0;
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "tradingview.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class CustomPriceFormatterViewController: UIViewController {
topColor: "rgba(21, 101, 192, 0.5)",
bottomColor: "rgba(21, 101, 192, 0.5)",
lineColor: "rgba(255, 255, 255, 0.8)",
lineWidth: .two
lineWidth: .two,
crosshairMarkerBorderColor: "rgba(255, 255, 255, 1)",
crosshairMarkerBackgroundColor: "rgba(100, 50, 20, 1)"
)
let series = chart.addAreaSeries(options: options)
let data = [
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.2.0)
- LightweightCharts (3.3.0)

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

SPEC CHECKSUMS:
LightweightCharts: 04cf1c18f24019889976b0de40bef2329916e020
LightweightCharts: 05a4b19200513eb5a063ff81b09b8e18aee3997e

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.2.0'
s.version = '3.3.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.2.0/dist/lightweight-charts.standalone.production.js
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.3.0/dist/lightweight-charts.standalone.production.js
else
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.2.0/dist/lightweight-charts.standalone.development.js
curl -o $LIBRARY https://unpkg.com/lightweight-charts@3.3.0/dist/lightweight-charts.standalone.development.js
fi
cp -f $LIBRARY ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/lightweight-charts.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public extension SeriesApi where Self: SeriesObject {
context.evaluateScript(script, completion: nil)
}

func seriesType(completion: @escaping (SeriesType?) -> Void) {
let script = "\(jsName).seriesType();"
context.decodedResult(forScript: script, completion: completion)
}

private func setSeriesData<T: SeriesData>(_ data: [T]) {
let script = "\(jsName).setData(\(data.jsonString));"
context.evaluateScript(script, completion: nil)
Expand All @@ -103,4 +108,5 @@ public extension SeriesApi where Self: SeriesObject {
context.evaluateScript(script, completion: nil)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct TimeScaleOptions {
public var visible: Bool?
public var timeVisible: Bool?
public var secondsVisible: Bool?
public var shiftVisibleRangeOnNewBar: Bool?

public var tickMarkFormatter: JavaScriptMethod<TickMarkFormatterParameters, String>? {
get {
Expand All @@ -33,6 +34,7 @@ public struct TimeScaleOptions {
visible: Bool? = nil,
timeVisible: Bool? = nil,
secondsVisible: Bool? = nil,
shiftVisibleRangeOnNewBar: Bool? = nil,
tickMarkFormatter: JavaScriptMethod<TickMarkFormatterParameters, String>? = nil) {
self.rightOffset = rightOffset
self.barSpacing = barSpacing
Expand All @@ -44,6 +46,7 @@ public struct TimeScaleOptions {
self.visible = visible
self.timeVisible = timeVisible
self.secondsVisible = secondsVisible
self.shiftVisibleRangeOnNewBar = shiftVisibleRangeOnNewBar
self.tickMarkFormatter = tickMarkFormatter
}

Expand All @@ -63,6 +66,7 @@ extension TimeScaleOptions: Codable {
case visible
case timeVisible
case secondsVisible
case shiftVisibleRangeOnNewBar
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
public var lineWidth: LineWidth?
public var crosshairMarkerVisible: Bool?
public var crosshairMarkerRadius: Double?
public var crosshairMarkerBorderColor: ChartColor?
public var crosshairMarkerBackgroundColor: ChartColor?

public init(lastValueVisible: Bool? = nil,
title: String? = nil,
Expand All @@ -47,7 +49,9 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
lineStyle: LineStyle? = nil,
lineWidth: LineWidth? = nil,
crosshairMarkerVisible: Bool? = nil,
crosshairMarkerRadius: Double? = nil) {
crosshairMarkerRadius: Double? = nil,
crosshairMarkerBorderColor: ChartColor? = nil,
crosshairMarkerBackgroundColor: ChartColor? = nil) {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
Expand All @@ -70,6 +74,8 @@ public struct AreaSeriesOptions: SeriesOptionsCommon {
self.lineWidth = lineWidth
self.crosshairMarkerVisible = crosshairMarkerVisible
self.crosshairMarkerRadius = crosshairMarkerRadius
self.crosshairMarkerBorderColor = crosshairMarkerBorderColor
self.crosshairMarkerBackgroundColor = crosshairMarkerBackgroundColor
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
public var lineType: LineType?
public var crosshairMarkerVisible: Bool?
public var crosshairMarkerRadius: Double?
public var crosshairMarkerBorderColor: ChartColor?
public var crosshairMarkerBackgroundColor: ChartColor?

public init(lastValueVisible: Bool? = nil,
title: String? = nil,
Expand All @@ -45,7 +47,9 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
lineWidth: LineWidth? = nil,
lineType: LineType? = nil,
crosshairMarkerVisible: Bool? = nil,
crosshairMarkerRadius: Double? = nil) {
crosshairMarkerRadius: Double? = nil,
crosshairMarkerBorderColor: ChartColor? = nil,
crosshairMarkerBackgroundColor: ChartColor? = nil) {
self.lastValueVisible = lastValueVisible
self.title = title
self.priceScaleId = priceScaleId
Expand All @@ -67,6 +71,8 @@ public struct LineSeriesOptions: SeriesOptionsCommon {
self.lineType = lineType
self.crosshairMarkerVisible = crosshairMarkerVisible
self.crosshairMarkerRadius = crosshairMarkerRadius
self.crosshairMarkerBorderColor = crosshairMarkerBorderColor
self.crosshairMarkerBackgroundColor = crosshairMarkerBackgroundColor
}

}
10 changes: 10 additions & 0 deletions LightweightCharts/Classes/LightweightChartsModels/SeriesType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation


public enum SeriesType: String, Decodable {
case line = "Line"
case area = "Area"
case candlestick = "Candlestick"
case bar = "Bar"
case histogram = "Histogram"
}
5 changes: 5 additions & 0 deletions LightweightCharts/Classes/Protocols/SeriesApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,9 @@ public protocol SeriesApi: class {
*/
func removePriceLine(line: PriceLine)

/**
* Returns the type of this series
* - Parameter completion: this SeriesType
*/
func seriesType(completion: @escaping (SeriesType?) -> Void)
}
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.2.0'
pod 'LightweightCharts', '~> 3.3.0'
```
## Usage

Expand Down

0 comments on commit 1cf93ff

Please sign in to comment.