Skip to content

Commit

Permalink
Merge pull request #41 from tradingview/feature/migrate_to_3_8
Browse files Browse the repository at this point in the history
Migrate to 3.8.0
  • Loading branch information
makedonsky94 authored Mar 22, 2022
2 parents 6461208 + 9d916a4 commit dc5b245
Show file tree
Hide file tree
Showing 38 changed files with 4,164 additions and 3,996 deletions.
2 changes: 2 additions & 0 deletions Example/LightweightCharts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -608,6 +609,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class BarChartViewController: UIViewController {
layout: LayoutOptions(backgroundColor: ChartColor(.black), textColor: ChartColor(.white)),
rightPriceScale: VisiblePriceScaleOptions(borderColor: ChartColor(.gray)),
timeScale: TimeScaleOptions(borderColor: ChartColor(.gray)),
crosshair: CrosshairOptions(mode: .normal)
crosshair: CrosshairOptions(mode: .normal),
trackingMode: TrackingModeOptions(exitMode: .onTouchEnd)
)
let chart = LightweightCharts(options: options)
chart.clearWebViewBackground()
Expand Down
298 changes: 149 additions & 149 deletions Example/LightweightCharts/Example/CandlestickChartViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/CustomFontFamilyViewController.swift

Large diffs are not rendered by default.

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/CustomThemesViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/CustomWatermarkViewController.swift

Large diffs are not rendered by default.

700 changes: 350 additions & 350 deletions Example/LightweightCharts/Example/FitContentViewController.swift

Large diffs are not rendered by default.

600 changes: 300 additions & 300 deletions Example/LightweightCharts/Example/FloatingTooltipViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/GoToRealtimeButtonViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/LegendViewController.swift

Large diffs are not rendered by default.

600 changes: 300 additions & 300 deletions Example/LightweightCharts/Example/MagnifierTooltipViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/NoPriceScaleViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/NoTimeScaleViewController.swift

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ class PriceLineViewController: UIViewController {
self.priceLine = priceLine
}

private func generateData() -> [LineData] {
private func generateData() -> [SingleValueData] {
var time = DateComponents(calendar: .current, year: 2018, day: 0).date!
var result: [LineData] = []
var result: [SingleValueData] = []
for i in 0..<60 {
time = Date(timeInterval: 60 * 60 * 24, since: time)
let lineData = LineData(time: .utc(timestamp: time.timeIntervalSince1970), value: Double(i))
let lineData = SingleValueData(time: .utc(timestamp: time.timeIntervalSince1970), value: Double(i))
result.append(lineData)
}
return result
Expand Down
300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/PriceScaleAtLeftViewController.swift

Large diffs are not rendered by default.

930 changes: 465 additions & 465 deletions Example/LightweightCharts/Example/RangeSwitcherViewController.swift

Large diffs are not rendered by default.

304 changes: 152 additions & 152 deletions Example/LightweightCharts/Example/RealtimeEmulationViewController.swift

Large diffs are not rendered by default.

600 changes: 300 additions & 300 deletions Example/LightweightCharts/Example/ThreeLineLegendViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/TrackingTooltipViewController.swift

Large diffs are not rendered by default.

300 changes: 150 additions & 150 deletions Example/LightweightCharts/Example/VolumeStudyViewController.swift

Large diffs are not rendered by default.

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.6.1)
- LightweightCharts (3.8.0)

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

SPEC CHECKSUMS:
LightweightCharts: 1a6c10a3eccb065f3a270dd0c26515ca714f786a
LightweightCharts: bf203521ec7fce9fab873ff4cefb4d80950d7641

PODFILE CHECKSUM: 10aa45b030d82b96cfc0e4e3b143c5488576107b

Expand Down
2 changes: 1 addition & 1 deletion 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.7.1'
s.version = '3.8.0'
s.summary = 'LightweightCharts for iOS.'
s.description = 'LightweightCharts pod. Swift wrapper above JavaScript library.'
s.homepage = 'https://tradingview.com'
Expand Down
4 changes: 2 additions & 2 deletions Sources/LightweightCharts/Assets/lightweight-charts.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
public class AreaSeries: SeriesObject, SeriesApi {

public typealias Options = AreaSeriesOptions
public typealias TickValue = LineData
public typealias TickValue = SingleValueData

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
public class BaselineSeries: SeriesObject, SeriesApi {

public typealias Options = BaselineSeriesOptions
public typealias TickValue = LineData
public typealias TickValue = SingleValueData

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import Foundation
public class CandlestickSeries: SeriesObject, SeriesApi {

public typealias Options = CandlestickSeriesOptions
public typealias TickValue = BarData
public typealias TickValue = CandlestickData

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import Foundation

protocol BarSeriesData: SeriesData {

var time: Time { get }

var open: Double? { get }
var high: Double? { get }
var low: Double? { get }
var close: Double? { get }

protocol BarSeriesData: OhlcData {
var color: ChartColor? { get }
}

// MARK: -
Expand All @@ -19,13 +12,15 @@ public struct BarData: BarSeriesData {
public var high: Double?
public var low: Double?
public var close: Double?
public var color: ChartColor?

public init(time: Time, open: Double?, high: Double?, low: Double?, close: Double?) {
public init(time: Time, open: Double?, high: Double?, low: Double?, close: Double?, color: ChartColor? = nil) {
self.time = time
self.open = open
self.high = high
self.low = low
self.close = close
self.color = color
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Foundation

protocol CandlestickSeriesData : OhlcData {
var color: ChartColor? { get }
var borderColor: ChartColor? { get }
var wickColor: ChartColor? { get }
}

// MARK: -
public struct CandlestickData : CandlestickSeriesData {
public var time: Time
public var open: Double?
public var high: Double?
public var low: Double?
public var close: Double?
public var color: ChartColor?
public var borderColor: ChartColor?
public var wickColor: ChartColor?

public init(time: Time,
open: Double?,
high: Double?,
low: Double?,
close: Double?,
color: ChartColor? = nil,
borderColor: ChartColor? = nil,
wickColor: ChartColor? = nil) {
self.time = time
self.open = open
self.high = high
self.low = low
self.close = close
self.color = color
self.borderColor = borderColor
self.wickColor = wickColor
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
/**
Structure describing a single item of data for histogram series
*/
protocol HistogramSeriesData: LineSeriesData {
protocol HistogramSeriesData: SingleValueSeriesData {

/**
* Optional color value for certain data item. If missed, color from HistogramSeriesOptions is used
Expand All @@ -25,4 +25,9 @@ public struct HistogramData: HistogramSeriesData {
self.value = value
}

public init(time: Time, value: Double?, color: ChartColor? = nil) {
self.time = time
self.value = value
self.color = color
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Foundation

protocol LineSeriesData: SeriesData {

protocol LineSeriesData: SingleValueSeriesData {
/**
* Price value of data item
Optional color value for certain data item. If missed, color from options is used
*/
var value: Double? { get }

var color: ChartColor? { get }
}

// MARK: -
Expand All @@ -17,10 +16,12 @@ public struct LineData: LineSeriesData {

public var time: Time
public var value: Double?
public var color: ChartColor?

public init(time: Time, value: Double?) {
public init(time: Time, value: Double?, color: ChartColor? = nil) {
self.time = time
self.value = value
self.color = color
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Foundation

/**
Represents a bar with a Time and open, high, low, and close prices.
*/
public protocol OhlcData : SeriesData {

/**
The bar time
*/
var time: Time { get }

/**
The open price
*/
var open: Double? { get }

/**
The high price
*/
var high: Double? { get }

/**
The low price
*/
var low: Double? { get }

/**
The close price
*/
var close: Double? { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import Foundation

public protocol SeriesData: Codable {

/**
The time of the data
*/
var time: Time { get }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Foundation

/**
A base interface for a data point of single-value series
*/
public protocol SingleValueSeriesData : SeriesData {

/**
* Price value of data item
*/
var value: Double? { get }
}


public struct SingleValueData : SingleValueSeriesData {
public var time: Time
public var value: Double?

public init(time: Time, value: Double?) {
self.time = time
self.value = value
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
import Foundation

/**
Represents a price line options
*/
public struct PriceLineOptions: Codable {

/**
Price line's value
*/
public var price: Double?

/**
Price line's color
*/
public var color: ChartColor?

/**
Price line's width in pixels
*/
public var lineWidth: LineWidth?

/**
Price line's style
*/
public var lineStyle: LineStyle?

/**
Display line
*/
public var lineVisible: Bool?

/**
Display the current price value in on the price scale
*/
public var axisLabelVisible: Bool?

/**
Price line's on the chart pane
*/
public var title: String?

public init(price: Double? = nil,
color: ChartColor? = nil,
lineWidth: LineWidth? = nil,
lineStyle: LineStyle? = nil,
lineVisible: Bool? = nil,
axisLabelVisible: Bool? = nil,
title: String? = nil) {
self.price = price
self.color = color
self.lineWidth = lineWidth
self.lineStyle = lineStyle
self.lineVisible = lineVisible
self.axisLabelVisible = axisLabelVisible
self.title = title
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public struct ChartOptions: Codable {
Structure that describes kinetic scroll behavior
*/
public var kineticScroll: KineticScrollOptions?

/**
Represent options for the tracking mode's behavior.
*/
public var trackingMode: TrackingModeOptions?

public init(width: Double? = nil,
height: Double? = nil,
Expand All @@ -88,7 +93,8 @@ public struct ChartOptions: Codable {
localization: LocalizationOptions? = nil,
handleScroll: HandleScrollOptions? = nil,
handleScale: TogglableOptions<HandleScaleOptions>? = nil,
kineticScroll: KineticScrollOptions? = nil) {
kineticScroll: KineticScrollOptions? = nil,
trackingMode: TrackingModeOptions? = nil) {
self.width = width
self.height = height
self.watermark = watermark
Expand All @@ -103,6 +109,7 @@ public struct ChartOptions: Codable {
self.handleScroll = handleScroll
self.handleScale = handleScale
self.kineticScroll = kineticScroll
self.trackingMode = trackingMode
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

/**
* Represent options for the tracking mode's behavior.
*/
public struct TrackingModeOptions: Codable {
public var exitMode: TrackingModeExitMode?

public init(exitMode: TrackingModeExitMode? = nil) {
self.exitMode = exitMode
}
}

/**
* Determine how to exit the tracking mode.
*
* By default, mobile users will long press to deactivate the scroll and have the ability to check values and dates.
* Another press is required to activate the scroll, be able to move left/right, zoom, etc.
*/
public enum TrackingModeExitMode: Int, Codable {
/**
* Tracking Mode will be deactivated on touch end event.
*/
case onTouchEnd
/**
* Tracking Mode will be deactivated on the next tap event.
*/
case onNextTap
}

0 comments on commit dc5b245

Please sign in to comment.