-
Notifications
You must be signed in to change notification settings - Fork 652
Open
Description
when using the version of the master branch, and applying the demo code in the Readme, it raise error.
Description
Expected Behavior
It should show the chart as mentioned in the docs
Actual Behavior
error
cannot force unwrap value of non-optional type 'Int'
----------------------------------------
SchemeBuildError: Failed to build the scheme "ExpenseTracker"
cannot force unwrap value of non-optional type 'Int'
Compile LineChartView.swift (x86_64):
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:84:50: error: cannot force unwrap value of non-optional type 'Int'
Text("\(rateValue!)%")
~~~~~~~~~^
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:79:47: warning: left side of nil coalescing operator '??' has non-optional type 'Int', so the right side is never used
if (rateValue ?? 0 >= 0){
~~~~~~~~~ ^~~~~
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:145:97: error: missing argument for parameter 'rateValue' in call
LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Basic")
^
, rateValue: <#Int?#>
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:36:12: note: 'init(data:title:legend:style:form:rateValue:dropShadow:valueSpecifier:)' declared here
public init(data: [Double],
^
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:148:213: error: missing argument for parameter 'rateValue' in call
LineChartView(data: [282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188], title: "Line chart", legend: "Basic")
^
, rateValue: <#Int?#>
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:36:12: note: 'init(data:title:legend:style:form:rateValue:dropShadow:valueSpecifier:)' declared here
public init(data: [Double],
^
Possible Fix
use guard before the line where rateValue! is used
Steps to Reproduce
- import the package, choose branch master
- paste this code in the view
MultiLineChartView(data: [([8,32,11,23,40,28], GradientColors.green), ([90,99,78,111,70,60,77], GradientColors.purple), ([34,56,72,38,43,100,50], GradientColors.orngPink)], title: "Title")
Your Environment
iMac late 2015
macOS Monterey
Xcode Version 13.3 (13E113)
- Version of this package used:
master
Metadata
Metadata
Assignees
Labels
No labels