Pre loader

Cannot solve these issues while migrating from version 2 to version 3

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


Dear SCICharts support:
We have a very large project that must be migrated to version 3 because right it uses version 2.
I am stuck in the following issues:

1/ I cannot convert Double or Date to ISCIComparable.

Our x axis contains Date-timestamp values and I am trying to find the index of the dataseries.xValues of a specific Date having as parameter my Date value which is Date type and not ISCIComparable.
How can I do this ?

When I try my attempt 1:

let x: Double = <DoubleValue>
let index = dataSeries.xValues.findIndex(of: x, searchMode: .nearest, isSorted: true) 

I am getting the build error: “Cannot convert value of type ‘Date?’ to expected argument type ‘ISCIComparable?'”

When I try my attempt 2:

If I also try to iterate the xValues and find the ISCIComparable value which has doubleValue equal the x then I get the error “Type ‘ISCIList?’ does not conform to protocol ‘Sequence'”
I mean something like this:

let x: Date = Date()
var comparableValue: ISCIComparable? = nil
for val in dataSeries.xValues {
    if val.toDate() == x {
        comparableValue = val

So any solution please ?

2/ I am trying to update the last point of dataSeries using this code:

let lastPoint = dataSeries.count - 1
if let open = dataSeries.openValues.value(at: lastPoint) {
        dataSeries.update( open: open,
                                    high: max(dataSeries.highValues().value(at: lastPoint).toDouble(), mbidPrice),
                                    low: min(dataSeries.lowValues().value(at: lastPoint).toDouble(), mbidPrice),
                                    close: mbidPrice,
                                    at: lastPoint)     }

and I get the error “Cannot convert value of type ‘ISCIComparable’ to expected argument type ‘ISCIValues?’ “
Why ? How should I do this ?

Thanks a lot in advance

  • You must to post comments

Hi there

Since you are migrating from v2 – please see our migration guide.

After that, let’s get to your questions one by one.

1/ I cannot convert Double or Date to ISCIComparable.

As per our documentation: NOTE: SciChart API has extensions for NSNumber and NSDate types, adding conformance to ISCIComparable.

So you just need to wrap your Swift values inside NSNumber or NSDate, e.g.:

let x: Double = 10
let index = dataSeries.xValues.findIndex(of: NSNumber(value: x), searchMode: .nearest, isSorted: true)

we do that in our Example Application, so please make sure to investigate one of the examples of whole app as well.

“Type ‘ISCIList?’ does not conform to protocol ‘Sequence’”

Definitely it’s not, you can find our more about ISCIList in our API documentation. To iterate over it you will need to use regular for loop:

var comparableValue: ISCIComparable? = nil
for i in 0 ... dataSeries.xValues.count {
    comparableValue = dataSeries.xValues.value(at: i)

2/ I am trying to update the last point of dataSeries using this code:

It’s because update method accepts one of the following:
– Swift Comparable type, to update only one value
– ISCIValues, to update list as quick as possible, because ISCIValues is the fastest way to operate with DataSeries
– Regular Swift Array, to update list of data.

And since you are trying to update only one value and your open value isn’t Swift Double, you should convert it via toDouble() method as you did below for other values, see example below:

if let open = dataSeries.openValues.value(at: lastPoint).toDouble() {
    dataSeries.update(open: open,
        high: max(dataSeries.highValues.value(at: lastPoint).toDouble(), someDoubleValue),
        low: min(dataSeries.lowValues.value(at: lastPoint).toDouble(), someDoubleValue),
        close: someDoubleValue,
        at: lastPoint)

Hope that helps.

Best Regards,
Nazar R.

  • You must to post comments

Hello again.
I want to say a big thank you for your really instant response.
I also want to comment that the last part was tricky because the real issue for me was that the build error was misleading because the real “syntax error” here was that in version 3 now we don’t need the parentheses for the calls “.dataSeries.highValues()” and “dataSeries.lowValues()” but the build error was showing me the first parameter ( OPENVALUE ) and didn’t notice that now we should not use parentheses and we can access the values by doing “dataSeries.highValues” and “dataSeries.lowValues”.
I believe my above issues should be clearly mentioned in you very useful migration guide which was my main helper until now that I have a black screen and not sure what is the cause of this.
I will investigate more your example projects but to be honest I didn’t find an example where you use “SCIOhlcDataSeries” with Swift and this is the reason that I cannot find the real cause of my black SCIChart.
Do you have any Swift example using SCIOhlcDataSeries ?
Thanks a lot in advance

Showing 2 results
Your Answer

Please first to submit.