SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hi , many of the charts provide a way to set the date on the x axis for the data series and that makes the axis match the DataSeries value defined for that axis, but for heatmap dataseries when you define xType as date the xAxis of type date is not displaying on surface, I don’t know what I’m doing wrong and there is no sample for dates on GitHub , the samples only use int , would be great if you can provide a date sample for the heatmap , thanks
Hi there,
I’m trying to display little icons as axis labels using the LabelProvider API and NSAttributedString (with NSTextAttachmet). Is this supported? Here’s a minimal example:
import UIKit
import Foundation
import SciChart
import SciChart.Protected.SCILabelProviderBase
class ViewController: UIViewController {
private lazy var chart: SCIChartSurface = {
let c = SCIChartSurface(frame: .zero)
c.xAxes.add(items: SCINumericAxis())
let yAxis = SCINumericAxis()
yAxis.labelProvider = SymbolLabelProvider()
c.yAxes.add(items: yAxis)
return c
}()
override func viewDidLoad() {
super.viewDidLoad()
SCIChartSurface.setRuntimeLicenseKey(myLicenseKey)
view.addSubview(chart)
chart.translatesAutoresizingMaskIntoConstraints = false
let guide = self.view.safeAreaLayoutGuide
NSLayoutConstraint.activate([
chart.leadingAnchor.constraint(equalTo: guide.leadingAnchor),
chart.trailingAnchor.constraint(equalTo: guide.trailingAnchor),
chart.topAnchor.constraint(equalTo: guide.topAnchor),
chart.bottomAnchor.constraint(equalTo: guide.bottomAnchor),
])
}
}
class SymbolLabelProvider: SCILabelProviderBase<SCINumericAxis> {
lazy var numberFormatter: NumberFormatter = {
let f = NumberFormatter()
f.allowsFloats = true
f.maximumFractionDigits = 2
return f
}()
init() {
super.init(axisType: ISCINumericAxis.self)
}
override func formatLabel(_ dataValue: ISCIComparable!) -> ISCIString! {
let intValue = Int(dataValue.toDouble())
let font = UIFont.init(descriptor: axis.tickLabelStyle.fontDescriptor, size: UIFont.systemFontSize * 4)
if intValue.isMultiple(of: 2) {
let i = UIImage(systemName: "circle", withConfiguration: UIImage.SymbolConfiguration(font: font))
return NSAttributedString(attachment: NSTextAttachment(image: i!))
} else {
let attributes: [NSAttributedString.Key: Any] = [
.font: font,
.foregroundColor: UIColor.yellow,
]
return NSAttributedString(string: numberFormatter.string(for: dataValue.toDouble())!, attributes: attributes)
}
}
}
See attached screenshot for the result.
If this is not supported: any suggestions / ideas for a workaround?
Thanks
—Matthias
how to create ECG Monitor demo
Hi guys,
I want to show x value on chart bar itself as shown in the attached image along with this query. I tried using annotation where I need to give x and y value each time and it look not appropriate in the 2 data series column chart using, instead of that I need easy way to represent label of bar value on graph bar.
please suggest if any.
Thanks in advance.
Hi guys,
I have some troubles with piecharts in swift. I want to provide custom labels outside of the piecharts segments. I found a screenshot of a nested piechart attached to an issue in your issue tracker. Thats what I want to do in swift, but I couldn’t find out a way to do so. Could you please provide an example code?
Thanks a lot in advance!
Alex
Hey everyone, my team currently has Scicharts for WPF set up and functioning the way we want it too.
We are moving to Xamarin and have tested Scicharts in a Xamarin.Forms project working for Android/iOS and Windows WPF.
The next step was to install Visual Studios for Mac, and setup a new Xamarin.Forms project and pull the code from the windows version of our Xamarin.Forms project. For windows we use a custom renderer to get the scicharts to work for all platforms available on the windows version. For Mac, we are trying to get a custom renderer set up to load the swift version of the Scicharts for Mac. It’s not going so well.
Can anyone provide details on if it’s possible to get a xaramarin.forms project to load the scicharts for mac framework?
Thanks
NOTE** I picked iOS because for some reason MacOS wasn’t in the list of platforms
Hi, I want to set yaxis labels outside the chart but unable to find any solution please help.
I’m updating some code that was written against SciChart iOS v2. We have one graph in that code that relied on removeFromLegend
in a renderable series, to prevent the legend from getting ridiculous long.
As an example, suppose we have Western Earth, Western Wind, Western Fire, Eastern Earth, Eastern Wind, and Eastern Fire. Each element is styled the same, no matter where it’s located. In the legend, we only want to see Earth, Wind, and Fire. Our actual list of series is much longer…4 “elements”, up to 8 locations, making 32 legend entries, with 28 duplicates.
What’s the replacement for removeFromLegend
? How do I prevent these duplications?
I had recently integrated SciChart into my app, and faced some problems with chat appearance on trial mode which are described here: https://www.scichart.com/questions/ios/issue-with-scichart-on-ios-simulator
Due to this problems I tried to run my app on an actual device, and got this build error from Xcode:
”’
ld: building for iOS, but linking in dylib file (/Users/ruslansabirov/Library/Developer/Xcode/DerivedData/exinity-aupulhpegzsnlfcrnqfiwnvnljpj/Build/Products/Debug-iphoneos/SciChart.framework/SciChart) built for iOS Simulator, file ‘/Users/ruslansabirov/Library/Developer/Xcode/DerivedData/exinity-aupulhpegzsnlfcrnqfiwnvnljpj/Build/Products/Debug-iphoneos/SciChart.framework/SciChart’ for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
”’
How can I fix this problem?
I was trying to test SciChart on simulator, but I have a problem: I added chart surface on my view, and after I launch an app, SciChart is showing me this text on the screen :
“Hardware rendering performance of SciChart in simulator is SLOW. Please use an actual device to feel the real-world performance”
How do I remove this text and test my charts on the simulator?
Hi,
I’d like to update the iOS version to the latest stable one (4.1.0), but after following the steps here: https://www.scichart.com/documentation/ios/current/integrating-scichart-libraries.html
Xcode keeps complaining:
framework not found SciChart.xcframework
clang: error: linker command failed with exit code 1
If I downgrade back to 3.1.1 everything works again. Any idea why the version 4.1.0 is not working? I’m using Pods to manage all dependencies.
While moving the rollover cursor, if the number of series under the cursor increases, the rollover cursor labels become wrongly positioned. This ViewController subclass Swift example reproduces the problem.
import UIKit
import SciChart
class ViewController: UIViewController {
// Surface is added in Storyboard
@IBOutlet weak var surface: SCIChartSurface!
override func viewDidLoad() {
super.viewDidLoad()
let xAxis = SCINumericAxis()
let yAxis = SCINumericAxis()
xAxis.visibleRange = SCIDoubleRange(min: 0, max: 260)
yAxis.visibleRange = SCIDoubleRange(min: -5, max:12)
yAxis.autoRange = .never
self.surface.chartModifiers.add(items: SCIRolloverModifier())
self.surface.xAxes.add(xAxis)
self.surface.yAxes.add(yAxis)
self.surface.renderableSeries.add(items:
renderableSeries( 10...50, 10, .red),
renderableSeries(150...250, 8, .green),
renderableSeries( 10...100, 2, .cyan),
renderableSeries(200...250, 0, .orange),
renderableSeries( 10...250, 5, .white)
)
}
func renderableSeries(_ xValues:ClosedRange<Int>, _ yValue:Double, _ color:UIColor) -> SCIFastLineRenderableSeries {
let series = SCIXyDataSeries(xType: .double, yType: .double)
xValues.forEach { series.append(x: $0, y: yValue ) }
let rSeries = SCIFastLineRenderableSeries()
rSeries.dataSeries = series
rSeries.strokeStyle = SCISolidPenStyle(color: color, thickness: 4)
return rSeries
}
}
Hi,
We have an issue where the graph grid lines and tick markers do not show on iOS 10. Everything works on iOS 11 and up. Any idea why this is happening?
Hi,
I’m trying to convert Java code to swift and I need the AnnotationLabel’s setAxisLabelStyle equivalent.
AnnotationLabel annotationLabel = new AnnotationLabel(getContext());
annotationLabel.setLabelPlacement(LabelPlacement.Axis);
annotationLabel.setAxisLabelStyle(new Action1<AnnotationLabel>()
{
@Override
public void execute(AnnotationLabel annotationLabel)
{
annotationLabel.setFontStyle(new FontStyle(37.0f, Color.BLUE));
annotationLabel.setBackgroundResource(R.drawable.current_price);
}
});
How can i apply this code in swift?
Hi,
I’m trying to convert Java code to swift and I need the RolloverModifier class’s updateCurrentPoint method. I create CustomRolloverModifier class inherits from SCIRolloverModifier class and import SciChart.Protected.SCIRolloverModifier extension too. But i can’t find updateCurrentPoint method. What is the updateCurrentPoint equivalent method on swift?
Thanks.
SciChart 3.1.0.5175 running on iOS 13.6
Please see this short video which demonstrates the issue: https://youtu.be/HjtWZDZeyXM
I have a chart showing a single Spline data series. The data series never drops below zero, yet the chart shows multiple points where the line drops below zero as you zoom in and out. This behavior changes as the zoom level changes.
Is this expected behavior for the spline chart? Is there a way to change the behavior so the chart does not show these sub-zero points?
private func drawChart()
{
createChartSurface()
let series = self.getPositionSeries( name: name, color: color, results: resultsSession.rearResults )
self.sciChartSurface?.renderableSeries.add(series)
}
private func createChartSurface()
{
// If we created a chart surface previously then we need to remove it from the superview
sciChartSurface?.removeFromSuperview()
// Create a SCIChartSurface. This is a UIView so can be added directly to the UI
sciChartSurface = SCIChartSurface()
sciChartSurface?.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(sciChartSurface!)
//sciChartSurface?.autoresizingMask = [.flexibleHeight, .flexibleWidth] // chart bottom falls off the view without this
sciChartSurface?.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor).isActive = true
sciChartSurface?.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true
sciChartSurface?.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
sciChartSurface?.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true
// Create an XAxis and YAxis. This step is mandatory before creating series
let xaxis = SCINumericAxis()
xaxis.axisTitle = "Seconds"
sciChartSurface?.xAxes.add(xaxis)
let yaxis = SCINumericAxis()
yaxis.axisTitle = "Position (mm)"
yaxis.axisId = "p" // position
yaxis.axisAlignment = .right
sciChartSurface?.yAxes.add(yaxis)
let yaxis = SCINumericAxis()
yaxis.axisTitle = "Speed mm/s"
yaxis.axisId = "s" // speed
yaxis.axisAlignment = .left
sciChartSurface?.yAxes.add(yaxis)
addModifiers()
}
private func getPositionSeries( name: String, color: UIColor, results: ResultData ) -> SCISplineLineRenderableSeries
{
let positionData = SCIXyDataSeries(xType: .double, yType: .double)
positionData.seriesName = name
let start = resultsSession.indexStart + 1
let last = resultsSession.indexEnd
for index in start ... last {
let t1 = resultsSession.sensorData[index-1].time
let t2 = resultsSession.sensorData[index].time
if ((t2-t1) == 1) {
let x = Double(t2) / resultsSession.sampleRate
let y = results.axleData[index].position
positionData.append(x: x, y: y)
} else {
// There was a gap in the data. Fill in the gap with a horizontal line.
let y = results.axleData[index-1].position
for tx in (t1 + 1) ... t2 {
let x = Double(tx) / resultsSession.sampleRate
positionData.append(x:x, y:y)
}
}
}
let positionSeries = SCISplineLineRenderableSeries() // SCIFastLineRenderableSeries()
positionSeries.dataSeries = positionData
positionSeries.yAxisId = "p"
positionSeries.strokeStyle = SCISolidPenStyle(color: color, thickness: 1.0)
return positionSeries
}
Hi,
How can i listen annotation selection changes? I try this code but i’m getting error “Cannot assign to property: ‘lineAnnotation’ is immutable”
var lineAnnotation = SCILineAnnotation()
lineAnnotation.annotationSelectionChangedListener = { (annotation, isSelected) in
//
}
Tnx.
Hi,
I’m trying to convert Java code to swift and I need the same CustomCategoryDateAxis class as Yura’s answer: https://www.scichart.com/questions/android/setvisiblerangelimitmode-on-xaxis
I try to inherit from SCICategoryDateAxis but there is no isZoomConstrainSatisfied and coerceVisibleRange overrides.
How can i write the same code in swift?
Tnx.
Hello,
I’m trying to convert Android (Java) code to iOS (Swift), and I need to create a custom SCIZoomPanModifier. In the android code, onFling, onDown, and onDown were overridden, but I can’t seem to do that in iOS. How can I override onFling, onDown, and onUp in iOS to mimic the android code?
Thanks
Currently we have two graph surfaces with two Y axes on each side and we need all of the Y axes to have fixed width size. Until now we were achieving that like this:
topGraphSurface.LeftAxisAreaForcedSize = 45;
topGraphSurface.RightAxisAreaForcedSize = 45;
bottomGraphSurface.LeftAxisAreaForcedSize = 45;
bottomGraphSurface.RightAxisAreaForcedSize = 45;
but since updating to the new SciChart v3 we get the error “SciChartSurface does not contain a definition for (Left)AxisAreaForcedSize”. I couldn’t find any information about this in the Migration guide, so is there a way to achieve this in the new version?
Hello,
I need to display realtime chart with 20 series of data. My data is arriving at 500Hz. When I’m displaying this data, I find that after a while SciChart hangs with what appears to be a deadlock.
I’ve read as much as I can find about realtime graphing with SciChart and I started with tutorial 4 – Adding Realtime Updates. This article (https://www.scichart.com/questions/wpf/is-xydataseries-safe-to-being-changed-in-a-separate-thread) suggests that SciChart is thread safe so I tried using a second thread to feed data into a graph. My only change was to move from the main thread timer in the example to a GCD timer running at 500Hz. With this, I’m easily able to reproduce the deadlock in around 1.5 seconds.
Here is the main thread which is attempting to render:
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x0000000192bc8c20 in __psynch_rw_rdlock ()
#1 0x0000000192ae4864 in _pthread_rwlock_lock_wait ()
#2 0x0000000192ae47fc in _pthread_rwlock_lock_slow$VARIANT$mp ()
#3 0x0000000104a93828 in -[SCIRenderableSeriesLock initWithRenderableSeries:] ()
#4 0x0000000104ab742c in -[SCIRenderSurfaceRenderer p_SCI_updateCoreData:renderPassState:viewportSize:] ()
#5 0x0000000104ab6f4c in -[SCIRenderSurfaceRenderer p_SCI_renderLoop:assetManager:renderPassState:] ()
#6 0x0000000104ab6dc4 in -[SCIRenderSurfaceRenderer onDrawWithContext:andAssetManager:] ()
#7 0x00000001049c50c0 in -[SCIRenderSurfaceDrawable2D drawFrameIn:withDrawableSize:] ()
#8 0x0000000104ad4db8 in -[SCITwisterRendererBase drawFrameIn:withDrawableSize:] ()
#9 0x00000001049e56c8 in -[SCIMetalRenderer drawFrameIn:withDrawableSize:] ()
#10 0x0000000104a25b70 in -[SCIMetalRenderSurfaceBase draw] ()
#11 0x00000001999861ec in -[CALayer display] ()
#12 0x00000001999984d4 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#13 0x00000001998e11d8 in CA::Context::commit_transaction(CA::Transaction*, double) ()
#14 0x000000019990ab78 in CA::Transaction::commit() ()
#15 0x000000019990b58c in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
#16 0x0000000192d50fbc in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#17 0x0000000192d4beb0 in __CFRunLoopDoObservers ()
#18 0x0000000192d4c32c in __CFRunLoopRun ()
#19 0x0000000192d4bc38 in CFRunLoopRunSpecific ()
#20 0x000000019d39a38c in GSEventRunModal ()
#21 0x0000000196e7c444 in UIApplicationMain ()
#22 0x00000001042cc478 in main at /Users/mall/Downloads/SciChart.iOS.Examples-SciChart_v3_Release/tutorials/tutorials-2d/Tutorial 04 - Adding Realtime Updates/Tutorial 04 - Adding Realtime Updates/AppDelegate.swift:5
#23 0x0000000192bd38f0 in start ()
and here is my worker thread adding data to a series:
Thread 11 Queue : com.apple.root.default-qos.overcommit (concurrent)
#0 0x0000000192bc8c20 in __psynch_rw_rdlock ()
#1 0x0000000192ae4864 in _pthread_rwlock_lock_wait ()
#2 0x0000000192ae47fc in _pthread_rwlock_lock_slow$VARIANT$mp ()
#3 0x0000000104ac1518 in -[SCIXDataSeries p_SCI_searchDataIndexOn:xMinAsDouble:xMaxAsDouble:downSearchMode:upSearchMode:] ()
#4 0x0000000104ac1368 in -[SCIXDataSeries getIndicesXRange:xMinAsDouble:xMaxAsDouble:isCategoryAxis:] ()
#5 0x0000000104ac1b34 in -[SCIXDataSeries getWindowYRangeWithXCoordCalc:getPositiveRange:] ()
#6 0x0000000104aceddc in -[SCIRenderableSeriesBase getYRange:positive:] ()
#7 0x00000001049b25ac in -[SCIRangeCalculationHelper2DBase getWindowedYRangeWithXCalculators:] ()
#8 0x0000000104a05f84 in -[SCIAxisBase getWindowedYRangeWithXRanges:] ()
#9 0x00000001049f4184 in -[SCIChartSurface p_SCI_zoomExtentsYWithCalculators:andDuration:] ()
#10 0x00000001049f3d14 in -[SCIChartSurface p_SCI_zoomExtentsWithDuration:] ()
#11 0x00000001042c79e8 in closure #1 in ViewController.handleTimer() at /Users/mall/Downloads/SciChart.iOS.Examples-SciChart_v3_Release/tutorials/tutorials-2d/Tutorial 04 - Adding Realtime Updates/Tutorial 04 - Adding Realtime Updates/ViewController.swift:84
#12 0x00000001042c7500 in thunk for @escaping @callee_guaranteed () -> () ()
#13 0x0000000104abdae0 in +[SCIUpdateSuspender usingWithSuspendable:withBlock:] ()
#14 0x00000001042c7824 in ViewController.handleTimer() at /Users/mall/Downloads/SciChart.iOS.Examples-SciChart_v3_Release/tutorials/tutorials-2d/Tutorial 04 - Adding Realtime Updates/Tutorial 04 - Adding Realtime Updates/ViewController.swift:79
#15 0x00000001042c9250 in partial apply ()
#16 0x00000001042cb1e4 in closure #1 in closure #1 in RepeatingTimer.timer.getter at /Users/mall/Downloads/SciChart.iOS.Examples-SciChart_v3_Release/tutorials/tutorials-2d/Tutorial 04 - Adding Realtime Updates/Tutorial 04 - Adding Realtime Updates/RepeatingTimer.swift:26
#17 0x00000001042c7500 in thunk for @escaping @callee_guaranteed () -> () ()
#18 0x0000000107093730 in _dispatch_client_callout ()
#19 0x0000000107096390 in _dispatch_continuation_pop ()
#20 0x00000001070a9614 in _dispatch_source_invoke ()
#21 0x00000001070a4d74 in _dispatch_root_queue_drain ()
#22 0x00000001070a5698 in _dispatch_worker_thread2 ()
#23 0x0000000192aeab38 in _pthread_wqthread ()
Here is my version of the ViewController class from Tutorial 4 with the GCD timer (note that it uses RepeatingTimer class found here: https://gist.github.com/danielgalasko/1da90276f23ea24cb3467c33d2c05768) – my changes are marked with the //MALL comment:
import UIKit
import SciChart
class ViewController: UIViewController {
//MALL
private var timer = RepeatingTimer(timeInterval: 1.0/500.0)
private let pointsCount = 200
private var count: Int = 0
private let lineData = SCIDoubleValues()
private lazy var lineDataSeries: SCIXyDataSeries = {
let lineDataSeries = SCIXyDataSeries(xType: .int, yType: .double)
lineDataSeries.seriesName = "Line Series"
lineDataSeries.fifoCapacity = 300
return lineDataSeries
}()
private let scatterData = SCIDoubleValues()
private lazy var scatterDataSeries: SCIXyDataSeries = {
let scatterDataSeries = SCIXyDataSeries(xType: .int, yType: .double)
scatterDataSeries.seriesName = "Scatter Series"
scatterDataSeries.fifoCapacity = 300
return scatterDataSeries
}()
private var surface: SCIChartSurface {
return view as! SCIChartSurface
}
override func loadView() {
viewRespectsSystemMinimumLayoutMargins = false
view = SCIChartSurface()
}
override func viewDidLoad() {
super.viewDidLoad()
let xValues = SCIIntegerValues()
for i in 0 ..< pointsCount {
xValues.add(Int32(i))
lineData.add(sin(Double(i) * 0.1))
scatterData.add(cos(Double(i) * 0.1))
count += 1
}
lineDataSeries.append(x: xValues, y: lineData)
scatterDataSeries.append(x: xValues, y: scatterData)
let lineSeries = SCIFastLineRenderableSeries()
lineSeries.dataSeries = lineDataSeries
let pointMarker = SCIEllipsePointMarker()
pointMarker.fillStyle = SCISolidBrushStyle(colorCode: 0xFF32CD32)
pointMarker.size = CGSize(width: 10, height: 10)
let scatterSeries = SCIXyScatterRenderableSeries()
scatterSeries.dataSeries = scatterDataSeries
scatterSeries.pointMarker = pointMarker
let legendModifier = SCILegendModifier()
legendModifier.orientation = .horizontal
legendModifier.position = [.bottom, .centerHorizontal]
legendModifier.margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
SCIUpdateSuspender.usingWith(self.surface) {
self.surface.xAxes.add(items: SCINumericAxis())
self.surface.yAxes.add(items: SCINumericAxis())
self.surface.renderableSeries.add(items: lineSeries, scatterSeries)
self.surface.chartModifiers.add(items: SCIPinchZoomModifier(), SCIZoomExtentsModifier())
self.surface.chartModifiers.add(items: SCIRolloverModifier(), legendModifier)
}
// MALL
timer.eventHandler = handleTimer
timer.resume()
}
// MALL
private func handleTimer() {
let x = count
SCIUpdateSuspender.usingWith(surface) {
self.lineDataSeries.append(x: x, y: sin(Double(x) * 0.1))
self.scatterDataSeries.append(x: x, y: cos(Double(x) * 0.1))
// zoom series to fit viewport size into X-Axis direction
self.surface.zoomExtents()
self.count += 1
}
}
}
Thanks in advance for any help you can offer.
Hello
In the real-time line chart, I want an animation like the video(link below).
Can you be provided with animations such as a point where a point drawn in real time continues to blink?
https://drive.google.com/file/d/1tcSFNPwSR4XEZqMX_t8GK2vzV5NUQUcn/view?usp=sharing
I am setting SCIDateTimeAxis as my XAxis by using the code:
let xAxis = SCIDateTimeAxis()
xAxis.style.labelStyle.color = UIColor.darkGray
xAxis.textFormatting = “dd MMM”
xAxis.visibleRange = SCIDateRange(dateMin: 2019-07-29 11:30:00, max:2019-07-29 11:30:00)
As I have a requirement to change the application Language to THI.
How can I set the locale to the axis, so the label visible on the axis should displayed in THI language.
As right now it is always visible in english irrespective of the language like 1 sep, 20 sep, 10 oct, 30 oct, 20 nov .
Please help.
Thanks
Vikas Ahuja
Hello, I have tried to see if it is possible to show the rollover without showing any labels so that is is just a vertical bar. I was searching on StackOverflow and a few answers said it was not possible to omit any of the values from the graph. I did see that we can customize the cursor, is it possible to just have it be a vertical bar instead of a cross?? Then I could just use it instead of the default rollover.
I am linking a mockup we made of what we want to make. In the image, you have the graphic showing where the use as pressed, and above the graphic, we will show and update a graphic with the relevant information for that point.
Also, I will need to programmatically dismiss it so it will need to stay visible even if the user is panning or zooming.
See the screen shot (attached)
To dupe this start on the SciChart home page, select documentation, select iOS, then enter anything into the search box.
I get the same results with Chrome and Safari.
SciChart 3.1.0.5175
iOS 13.5
Xcode 10.15.5
If I am using the API incorrectly please let me know. I am not aware of any requirement to wait after using the SciChart API.
It appears the SCILegendModifier has some kind of timing bug. If you draw a chart on a surface with a legend, then clear the chart, then add another plot to the same surface you will notice the legend has stale data. However, if you clear the surface and wait a second before you add the new plot it will work as expected.
I created a sample Xcode project to demonstrate the issue. See the attachment chart.zip
I also created a video to demonstrate the issue: https://youtu.be/1JBTd1sfVgI
I have a workaround so this is not urgent, but I would like to remove the delay for my production release.
I’m tested on iPhone 8 (iOS 13.5.1) and iPad (iPadOS 13.5.1). On iPad the graph always works great but on iPhone sooner or later it always fails.
The exception is always “Thread 1: EXC_BAD_ACCESS (code=1, address=0x11d927ffc)” in the application main:
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); <–
}
}
in the task stack:
SciChart`XValuesProviderWrapper<int>::GetDoubleValue:
0x103b530e0 <+0>: ldr x8, [x0, #0x8]
0x103b530e4 <+4>: ldr w8, [x8, w1, sxtw #2] <--
0x103b530e8 <+8>: scvtf d0, w8
0x103b530ec <+12>: ret
The truth is, I have no idea what’s going on. .. Please, anyone know what might be happening?
Thank you very much!
Due to the app upgrade, the code is in objective-c. This is my initialization code:
- (void) loadSciChartSurface:(SCIChartSurface*)surface {
sciChartSurface = surface;
sciChartSurface.translatesAutoresizingMaskIntoConstraints = true;
// scroll
SCIZoomPanModifier *zoomPan = [SCIZoomPanModifier new];
zoomPan.receiveHandledEvents = true;
zoomPan.zoomExtentsY = false;
zoomPan.direction = SCIDirection2D_XDirection;
[sciChartSurface.chartModifiers add:zoomPan];
// zoom
SCIPinchZoomModifier *pinchZoomModifier = [SCIPinchZoomModifier new];
pinchZoomModifier.direction = SCIDirection2D_XDirection;
pinchZoomModifier.scaleFactor = 1.5;
[sciChartSurface.chartModifiers add:pinchZoomModifier];
// series
rSeries = [SCIFastLineRenderableSeries new];
xAxis = [SCINumericAxis new];
yAxis = [SCINumericAxis new];
xAxis.visibleRangeChangeListener = ^(id<ISCIAxis> axis, id<ISCIRange> oldRange, id<ISCIRange> newRange, BOOL isAnimating) {
int min = newRange.minAsDouble;
int max = newRange.maxAsDouble;
int center = (min + max) / 2;
if (center <= 0) {
axis.visibleRange.min = @(0.0 - xHalfWidth);
axis.visibleRange.max = @(xWidth - xHalfWidth);
} else if (center >= dataSamples) {
axis.visibleRange.min = @(dataSamples - xHalfWidth);
axis.visibleRange.max = @(dataSamples + xHalfWidth);
} else {
// xWith is updated to keep the zoom factor in limits, when (center <= 0) or (center >= dataSamples)
xWidth = max - min;
xHalfWidth = xWidth / 2;
}
};
[SCIUpdateSuspender usingWithSuspendable:sciChartSurface withBlock:^{
[sciChartSurface.xAxes add:xAxis];
[sciChartSurface.yAxes add:yAxis];
[sciChartSurface.renderableSeries add:rSeries];
[SCIAnimations sweepSeries:rSeries duration:0.0 andEasingFunction:[SCICubicEase new]];
}];
dataSeries = [[SCIXyDataSeries alloc] initWithXType:SCIDataType_Int yType:SCIDataType_Short];
// x
xWidth = theFileFormat.mSampleRate * MIN_SECONDS_IN_GRID * 1;
xIndex = 0;
xHalfWidth = xWidth / 2;
xAxis.visibleRange = [[SCIDoubleRange alloc] initWithMin:0.0 max:xWidth];
// y
yAxis.visibleRange = [[SCIDoubleRange alloc] initWithMin:SHRT_MIN max:SHRT_MAX];
[self loadDefaultStyle];
}
I’m trying to clear a SCIUniformHeatmapDataSeries after connecting it to a SCIChartSurface, but it is very slow and energy consuming. However, if I clear the data series before it is connected to the sci chart, then the clearing is pretty fast. How can I clear the data series after it is connected to the chart surface quickly? Do I have to make a new data series, clear it, and connect to the scichartsurface every time I want to clear a data series? This is for iOS by the way.
EDIT: code
for i in 0..<data.MATRIX_COLUMNS {
for j in 0..<data.MATRIX_ROWS {
data.ecm2DMatrix[i][j] = Double.nan
SCIUpdateSuspender.usingWith(charts.ecmSurface) {
self.data.ecmDataSeries.update(z:self.data.ecm2DMatrix[i][j], atX: i, y: j)
}
I would like to change the color of chart legend, but have failed to find information on how can I do this for iOS. Any sort of tutorial would be highly appreciated.
Worst case scenario would be to create a custom theme that is based on Bright Spark theme and update legend parameters there, but for this I would need to know what exactly does Bright Spark theme looks like.
Looking forward to any recommendations.
Best Regards,
Paul.
Hi guys,
I’m currently evaluating SciChart on iOS using Swift. It seems to have an excellent level of customisation and is almost a drop-in fit for what were are looking for.
I’m creating a timeline chart of candlesticks which the user can pan through. However while the zooming of the Y axis keeps the candles nicely in frame, the zoom snaps into place instantly as the pan happens which is very disorienting. Searching the docs, I cannot see a way to cause a smooth animation as the chart automatically zooms in and out.
This is probably the only thing that we really need to do to make this product work for us so hopefully there is an answer to solve this for us!
Thanks in advance!
Hello,
We have an app where we need to specify a different width for each column. I have attached an image of the result we want. We are currently using “SCIFastColumnRenderableSeries” for the diagram, but all columns have a fixed width and I couldn’t find any way to modify it.
Do you have any suggestions how to accomplish this?
Thanks!
When I create a SCIChartSurface programmatically, following the Quick Start guide:
https://www.scichart.com/documentation/ios/current/creating-your-first-scichart-ios-app.html#adding-scichartsurface-purely-from-code
Functionally everything works as expected, but I see a series of these messages in the log:
[CAMetalLayer nextDrawable] returning nil because allocation failed.
I do not see these messages when the SCIChartSurface is instantiated via a storyboard.
I am using an SCINumericAxis for my y-axis. I am setting the visibleRange to (Min = 28, Max = 76). I am leaving the minorsPerMajor to the default of 5. However when looking at my graph (attached) you can see that the major tick labels are actually every 6 minors, e.g. 30, 36, 42, etc. when they should be 30, 35, 40, etc for minorsPerMajor set to 5.
Please advise on how to fix this issue as my major tick labels should be every 5, not every 6.
I have followed the example at: https://www.scichart.com/documentation/ios/current/legend-modifier.html for creating a legend with a custom item.
The initial problem I am trying to solve is that the default legend has a black background but my chart is white. If I set the background of the legend to white, this is a problem because the series text is white, so you can’t read it any longer. Therefore in order to have a legend with a white background to match my chart, I needed custom legend items to be able to set the series text color to black.
I have created my ChartLegendCell.swift file based on the example and my ChartLegendCell.xib which has a UIView and a UILabel. I incorporate these into my code exactly as in the example. However the legend does not show up upon render. I added a breakpoint inside the ChartLegendCell.swift class and I see bindSeriesInfo method called twice per series. What I noticed is that the first time it is called, printing out self.bounds shows (0,0,230,35) which is correct, but the second time it is called self.bounds is (0,0,0,0).
Is there more code which needs to be added in the ChartLegendCell.swift to make sure the width and height aren’t 0?
Hello, I’m having an issue when I put multiple surfaces in an iOS view. Only the one made first is shown and there is a black space in place of the other. I swapped the order of creation and now the other is visible instead. Does anyone know why this is happening or have suggestions for putting multiple surfaces in an iOS view? Thanks
Hello, I’ve been trying to create a SCIUniformHeatMap, but I only get a blank, black screen.
Can anyone recommend why colors and the graph aren’t showing up? Thanks
var ecmSurface: SCIChartSurface = SCIChartSurface()
var ecmDataSeries = SCIUniformHeatmapDataSeries(xType: .double, yType: .double, zType: .double, xSize: ReviewModeData.MATRIX_COLUMNS, ySize:ReviewModeData.MATRIX_ROWS)
var heatmapRenderableSeries: SCIFastUniformHeatmapRenderableSeries = SCIFastUniformHeatmapRenderableSeries()
private let countColors = 6
private var colorRGBArray: [UIColor] = [
UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 131.0/255.0, alpha: 1),
UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 255.0/255.0, alpha: 1),
UIColor(red: 0.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1),
UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 0.0/255.0, alpha: 1),
UIColor(red: 255.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1),
UIColor(red: 128.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1)
]
for i in 0..<ReviewModeData.MATRIX_COLUMNS {
for j in 0 ..< ReviewModeData.MATRIX_ROWS {
ecmDataSeries.update(z: ecm2DMatrix[i][j], atX: i, y: j)
}
}
var colorZValueArray: [Double] = determineColorMapValues(clim1: 0, clim2: 1);
var colorMap = SCIColorMap(colors: colorRGBArray, andStops: colorZValueArray as [NSNumber])
//configure ECM heatmap
heatmapRenderableSeries.minimum = ReviewModeData.ECM_CLIM1
heatmapRenderableSeries.maximum = ReviewModeData.ECM_CLIM2
heatmapRenderableSeries.dataSeries = ecmDataSeries
heatmapRenderableSeries.colorMap = colorMap!
Hi,
There is a strange displaying behavior of custom annotation. I added custom annotation using the code below.
let imageView = UIImageView(image: UIImage(named: imageName))
imageView.frame = CGRect(origin: .zero, size: CGSize(width: 10, height: 10))
let customAnnotation = SCICustomAnnotation()
customAnnotation.customView = imageView
customAnnotation.verticalAnchorPoint = .bottom
customAnnotation.horizontalAnchorPoint = .center
customAnnotation.set(x1: xCoordinate)
customAnnotation.set(y1: yCoordinate)
sciChartSurface?.annotations.add(items: customAnnotation)
The result looks good, but when I move surface left and right, custom annotation would go outside of bounds. Like the image I uploaded.
Please help me solve the issue.
Thanks.
I am trying to add a legend to my chart similar to how is done in the LegendChartView.swift code in the sample app. However the legend does not show and I get several NSLayoutConstraints conflicts such as this one:
[LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (
"<NSLayoutConstraint:0x283528af0 UIButton:0x13c52d840.height == 25 (active)>",
"<NSLayoutConstraint:0x2835285f0 UIButton:0x13c52d840.bottom == UIView:0x13c545060.bottom - 4 (active)>",
"<NSLayoutConstraint:0x2835285a0 V:|-(4)-[UIButton:0x13c52d840] (active, names: '|':UIView:0x13c545060 )>",
"<NSLayoutConstraint:0x283528b40 'UIIBSystemGenerated' SCIDefaultLegendItem:0x13c543f90.top == UIView:0x13c545060.top (active)>",
"<NSLayoutConstraint:0x283528b90 'UIIBSystemGenerated' V:[UIView:0x13c545060]-(0)-| (active, names: '|':SCIDefaultLegendItem:0x13c543f90 )>",
"<NSLayoutConstraint:0x283529c20 'UIView-Encapsulated-Layout-Height' SCIDefaultLegendItem:0x13c543f90.height == 0 (active)>" )
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x283528af0 UIButton:0x13c52d840.height == 25 (active)>
The internal SCIDefaultLegendItems look to keep setting their width and height to 0 which causes conflicts with the underlying UIButton and UILabel components.
Any thoughts on how to get around this? My chart has four series. I have seen the article on drawing the legend outside the chart surface area however I do not want to do that.
Thank you!
I have a question about the font of the label text. When the screen is captured and enlarged, the character has an outline border. Is there a way to get rid of this border? Japanese Kanji font is used.
Thank you.
var yAxisLeft = new SCINumericAxis();
yAxisLeft.AxisTitle = syAxLeft;
yAxisLeft.AxisId = "Primary Y-Axis";
yAxisLeft.AxisAlignment = SCIAxisAlignment.Left;
yAxisLeft.TitleStyle = new SCIFontStyle(14, UIColor.Green);
yAxisLeft.TickLabelStyle = new SCIFontStyle(14, UIColor.Green);
yAxisLeft.DrawMajorBands = false;
yAxisLeft.DrawMinorGridLines = false;
When I add CursorModifier programmatically on long tap I have to remove my finger from screen and press it again In order to CursorModifier become visible
Is it possible to do the following?
1) scroll chart horizontally
2) long tap on screen
3) add CursorModifier programmatically and show it immediately
4) move CursorModifier(finger is still touching the screen)
5) remove finger from screen and remove CursorModifier so I can scroll again
Thank you for reply in advance!
Hello,
Would it be possible to receive some information on how to take the legend outside of the chart surface area? We are having an issue when the user selects more axis’ to be shown in the chart. The chart then shrinks horizontally making the legend difficult to access for removing the axis’.
A quick how to with some code example would be highly appreciated. To further highlight, this is Xamarin.iOS project we are talking about.
Thank you and have a nice day.
Best Regards
Hello everyone.
We are trying to migrate to V3 in our iOS project and we have many issues.
One of the most important is the implementation of vertically-draggable horizontal lines.
I have a nice working code for SCICharts V2 but I cannot find any similar example of how we can implement a custom modifier for moving an SCIHorizontalLineAnnotation vertically in V3.
We have done it already with the V2 but now that we have to migrate to V3 there is a huge missing part in your documentation.
Our code was using-overiding onPanGesture() in order to figure out if the modifier should handle the touching event, then we were using the touch point in order to find the closer horizontal lines and choose the closest one in order to change the vertical value depending on the touching-changing point.
The only similar example that I found in your documentation (https://www.scichart.com/example/ios-custom-modifier/) is using SCIGestureModifier which is not accesible by the V3.
I am trying to use your SCIChartModifierBase class but cannot find anywhere a similar example of what we need.
I already tried to understand how you want us to use the ” override func onEvent(_ args: SCIModifierEventArgs!) ” function of the
SCIChartModifierBase but still no luck, it is impossible to figure out without any kind of a similar example.
The reason of needing an example is that this task needs much more information like these:
1. How to decide if the modifier should handle the touch event and how it should be ignored or handled by the next modifier in the same group ?
2. How to handle the touch started, changed, cancelled events ?
3. How to say in realtime to other modifiers in the same group that we need to to handle the same event simultaneously with this custom modifier ?
4. How to say to the group of modifiers that after the first modifer is taken the touch event then the rest should not use it ?
I will paste here our current implementation that we have done for V2 and needs to be transformed to V3 in case you need more details.
An important part is how we add the modifiers on the chart and this is how we are doing it right now:
let zoom = SCIPinchZoomModifier()
zoom.direction = .xDirection
let group = SCIChartModifierCollection(collection: [CustomModifier(chart: self),
PanModifier(),
zoom])
//group.handleGestureFirstOnly = true // Not existing in V3 anymore ! How should we do it in V3 ?
chart.chartModifiers = group
I believe that this code will be really useful for many people out there even for V2 or for migrating to V3.
Swift iOs code using SCICharts V2:
class Modifier: SCIGestureModifier {
private weak var control: ChartView?
private var editingProperty: ChartView.BindableProperty?
private var calculator: SCICoordinateCalculatorProtocol?
init(chart: ChartView?) {
self.control = chart
}
override func onPanGesture(_ gesture: UIPanGestureRecognizer?, at view: UIView?) -> Bool {
guard let chart = view as? SCIChartSurface,
let gesture_ = gesture
else { return super.onPanGesture(gesture, at: view) }
let location = gesture_.location(in: chart)
switch gesture_.state {
case .began:
control?.sendActions(for: .touchDown)
editingProperty = testForDraggableLine(location: location, in: chart)
calculator = yAxis().getCurrentCoordinateCalculator()
if editingProperty != nil {
// Annotations on SciChart don't have Zindex and we want current line to be on the top
let draggableLines = control?.chart.annotations.array.compactMap { $0 as? DraggableLine }
if let myLine = draggableLines?.first(where: { $0.bindingKeyValue == editingProperty }) {
control?.chart.annotations.remove(myLine)
control?.chart.annotations.add(myLine)
}
control?.isTouchingLine(isTouching: editingProperty != nil)
}
return editingProperty != nil
case .changed:
if editingProperty != nil {
handleDraggingLines(location: location, in: chart)
return true
}
case UIGestureRecognizer.State.ended:
if editingProperty != nil {
control?.sendActions(for: .editingDidEnd)
editingProperty = nil
_ = control?.adjustYRange(force: true)
control?.sendActions(for: .valueChanged)
control?.refreshPositions()
control?.isNotTouchingLine()
return true
}
case UIGestureRecognizer.State.cancelled:
if editingProperty != nil {
control?.sendActions(for: .editingDidEnd)
editingProperty = nil
_ = control?.adjustYRange(force: true)
control?.sendActions(for: .valueChanged)
control?.refreshPositions()
control?.isNotTouchingLine()
return true
}
default:
break
}
return false
}
private func handleDraggingLines(location: CGPoint, in chart: SCIChartSurface) {
guard let renderSurface = chart.renderSurface,
let yCalculator = self.calculator,
let editingProperty = editingProperty else { return }
let pointInChart = renderSurface.point(inChartFrame: location)
let valueForYAxis = yCalculator.getDataValue(from: Double(pointInChart.y))
control?.setValue(Decimal(valueForYAxis), forKey: editingProperty.rawValue)
}
// SOS: Filter possible properties that can be returned. We want to always avoid return - and then - dragging the current price bid or ask !
private func testForDraggableLine(location: CGPoint, in chart: SCIChartSurface) -> ChartView.BindableProperty? {
let hitTestDistance: Double = 30 // Pixels !
let nearItems = chart.annotations.array
.compactMap { $0 as? DraggableLine }
.filter { item in
return item.bindingKeyValue != ChartView.BindableProperty.ask &&
item.bindingKeyValue != ChartView.BindableProperty.bid &&
!item.isHidden &&
item.yDistance(from: location) <= hitTestDistance
}
return nearItems
.sorted { $0.yDistance(from: location) < $1.yDistance(from: location) }
.first?.bindingKeyValue
}
}
We are having an issue which is preventing us from upgrading to a newer version of Xamarin iOS SciChart.
With Xamarin iOS SciChart v3, the UpdateTicks method from SCINumericTickProvider cannot be overridden, because it doesn’t exist (at least not public).
In Xamarin Android SciChart v3, it works with overriding the UpdateTicks method.
In Xamarin iOS SciChart v2, it was possible to customize the ticks by overriding the method GetMajorTicksFromAxis from the class SCINumericTickProvider.
It looks like the types generation from iOS to Xamarin C# has missed to correctly export the UpdateTicks method as public overridable. (Because the docs say it should be there and it is there on Android Xamarin.)
When search this forum, I found that we can achieve it by adding point marker. But I am getting this error when trying to add point marker :
‘Operation: setPointMarker: is not avaliable on type: SCIHorizontallyStackedColumnsCollection’
let me know this feature(round top corners of bars) is availble or not ! Or is there any way to do this ?
If we set ClipMode.None we can pan infinitely to the uncharted space of left and right. this is fine.
But I want to do panning infinitely only to the left side. So I set ‘clipAtMax’. This is stop panning at right. But instead of panning infinity to the left, it is stretching the left part.
Any solution ?
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
iPhone 6, OS 12.4.3., X-axis, Y-axis texts are shown in inverted text. We can see this issue if we download the AppStore version of SciChart app
Stacked Bar chat: If we give 0 values, there are Black lines showing at middle of screen. please see attached screen.
We are using stacked bar chart, and showing only 6 bars visible at a time.
In the X-Axis, the month labels are missing for alternate months & only displays all month label as a flash when graph is being scrolled. Is there any way to fix this.
We need to generate adhoc ipa file for review purpose and we are using the trial version, but its fails. Can you help us on the same?