Skip to content

Commit

Permalink
Improved the chart filter data
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen van Zanten committed Nov 27, 2018
1 parent 4112bf7 commit 9b21d62
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
2 changes: 0 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
binary "https://icepa.github.io/Tor.framework/Tor.json" "305.2.1"
github "HamzaGhazouani/HGPlaceholders" "0.3.0"
github "JohnEstropia/CoreStore" "5.3.1"
github "ReactiveX/RxSwift" "4.4.0"
github "SwiftyJSON/SwiftyJSON" "4.2.0"
github "aschuch/QRCode" "601af09fa394da662753a1d0bdfeb7d11e54e7e7"
github "danielgindi/Charts" "v3.2.1"
github "evgenyneu/keychain-swift" "11.0.0"
github "hackiftekhar/IQKeyboardManager" "v6.1.1"
github "krzyzanowskim/CryptoSwift" "0.13.0"
github "vergecurrency/SwiftInsightClient" "22e51ba45357638edb35152adf10337e41507876"
github "xmartlabs/Eureka" "4.3.0"
github "yenom/BitcoinKit" "v1.0.2"
2 changes: 1 addition & 1 deletion VergeiOS/Components/WalletChart/PriceChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PriceChartView: AbstractChartView {
}

func set(chartData: [ChartDataEntry]) {
let priceSet = LineChartDataSet(values: nth(entries: chartData, step: 3), label: "Price History")
let priceSet = LineChartDataSet(values: chartData, label: "Price History")
style(priceSet: priceSet)

let data = LineChartData(dataSet: priceSet)
Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Components/WalletChart/VolumeChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class VolumeChartView: AbstractChartView {
}

func set(chartData: [BarChartDataEntry]) {
let priceSet = BarChartDataSet(values: nth(entries: chartData, step: 10), label: "Volume History")
let priceSet = BarChartDataSet(values: chartData, label: "Volume History")
style(priceSet: priceSet)

DispatchQueue.main.async {
Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Kernel/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct Config {
static let iOSRepo: String = "https://github.com/vergecurrency/vIOS"
static let blockchainExlorer: String = "https://verge-blockchain.info/"
static let bwsEndpoint: String = "https://load.vergecoreteam.com/bws/api/"
static let priceDataEndpoint: String = "https://load.vergecoreteam.com/price/api/v1/price/"
static let priceDataEndpoint: String = "https://usxvglw.vergecoreteam.com/price/api/v1/price/"
static let chartDataEndpoint: String = "https://graphs2.coinmarketcap.com/currencies/"
static let ipCheckEndpoint: String = "http://api.ipstack.com/check?access_key=e95ebddbee9137302b3cf50b39a33362&format=1"

Expand Down
3 changes: 2 additions & 1 deletion VergeiOS/Kernel/Wallet/WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ public class WalletClient {

print("Get request to: \(url)")
print("With signature: \(signature)")

print("And Copayer id: \(copayerId)")

var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue(copayerId, forHTTPHeaderField: "x-identity")
Expand Down
11 changes: 5 additions & 6 deletions VergeiOS/Storyboards/Transactions.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@
<viewLayoutGuide key="safeArea" id="uTh-7I-4Dc"/>
</view>
<navigationItem key="navigationItem" id="M51-BB-bff">
<barButtonItem key="leftBarButtonItem" image="Close" id="4rY-6J-X6j">
<barButtonItem key="leftBarButtonItem" systemItem="stop" id="Plx-gs-Ctf">
<connections>
<action selector="closeViewController:" destination="Igw-3T-6sZ" id="m57-hG-HEU"/>
<action selector="closeViewController:" destination="Igw-3T-6sZ" id="qKQ-TR-aZn"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" image="Refresh" id="IhH-Ac-YiK">
Expand Down Expand Up @@ -320,24 +320,23 @@
</scenes>
<resources>
<image name="AddAddress" width="30" height="30"/>
<image name="Close" width="30" height="30"/>
<image name="Contacts" width="30" height="30"/>
<image name="Receive" width="30" height="30"/>
<image name="Refresh" width="30" height="30"/>
<namedColor name="BackgroundGrey">
<color red="0.97299998998641968" green="0.96899998188018799" blue="0.96899998188018799" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="PrimaryLight">
<color red="0.21600000560283661" green="0.74099999666213989" blue="0.88599997758865356" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.21568627450980393" green="0.73725490196078436" blue="0.88235294117647056" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryDark">
<color red="0.097999997437000275" green="0.23899999260902405" blue="0.33300000429153442" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="SecondaryLight">
<color red="0.3919999897480011" green="0.47099998593330383" blue="0.52499997615814209" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.38823529411764707" green="0.47058823529411764" blue="0.52156862745098043" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="VergeGrey">
<color red="0.60799998044967651" green="0.60799998044967651" blue="0.60799998044967651" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.60784313725490191" green="0.60784313725490191" blue="0.60784313725490191" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
<inferredMetricsTieBreakers>
Expand Down
34 changes: 32 additions & 2 deletions VergeiOS/Views/Wallet/WalletSlides/ChartWalletSlideView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class ChartWalletSlideView: WalletSlideView, ChartViewDelegate, ChartFilterToolb
var filter: ChartFilterToolbar.Filter = .oneDay
var lastChangeFilter: TimeInterval?

var nthFilter = [
ChartFilterToolbar.Filter.all: 3,
ChartFilterToolbar.Filter.oneYear: 1,
ChartFilterToolbar.Filter.threeMonths: 3,
ChartFilterToolbar.Filter.oneMonth: 3,
ChartFilterToolbar.Filter.oneWeek: 3,
ChartFilterToolbar.Filter.oneDay: 2,
]

override func awakeFromNib() {
super.awakeFromNib()

Expand Down Expand Up @@ -136,8 +145,8 @@ class ChartWalletSlideView: WalletSlideView, ChartViewDelegate, ChartFilterToolb
}

DispatchQueue.main.async {
self.priceChartView.set(chartData: priceData)
self.volumeChartView.set(chartData: volumeData)
self.priceChartView.set(chartData: self.nth(entries: priceData, step: self.nthFilter[self.filter]!))
self.volumeChartView.set(chartData: self.nth(entries: volumeData, step: self.nthFilter[self.filter]! + 5) as! [BarChartDataEntry])
self.setPriceLabels(withData: data.priceUsd)
self.activityIndicator.stopAnimating()
}
Expand Down Expand Up @@ -193,4 +202,25 @@ class ChartWalletSlideView: WalletSlideView, ChartViewDelegate, ChartFilterToolb
return nil
}
}

func nth(entries: [ChartDataEntry], step: Int) -> [ChartDataEntry] {
var position = 0

let values: [Double] = entries.map { item in
return item.y
}

let highest = values.max()
let lowest = values.min()

return entries.filter { args in
if args.y == highest || args.y == lowest {
return true
}

position = 1 + position
return position % step == 0
}
}

}

0 comments on commit 9b21d62

Please sign in to comment.