I’m not sure what is going on, but I am consistently getting an error about my trial license key not being valid (it has 28 days left)
Error msg: “Sorry! You have not set a License Key. You can request a free trial key from http://www.scichart.com...”
Code (trial key partially snipped):
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Set this code once in MainActivity or application startup
SciChartSurface.setRuntimeLicenseKey("w2q0iyS8UeR2HKF...uqUbxqjprSIvXJPibCSl1g6ag==")
// Get the scichartsurface
val surface = findViewById<com.scichart.charting.visuals.SciChartSurface>(R.id.id_scichartsurface)
// Initialize the SciChartBuilder
SciChartBuilder.init(this)
// Obtain the SciChartBuilder instance
val sciChartBuilder = SciChartBuilder.instance()
// Create a numeric X axis
val xAxis: IAxis = sciChartBuilder.newNumericAxis()
.withAxisTitle("X Axis Title")
.withVisibleRange(-5.0, 15.0)
.build()
// Create a numeric Y axis
val yAxis: IAxis = sciChartBuilder.newNumericAxis()
.withAxisTitle("Y Axis Title").withVisibleRange(0.0, 100.0).build()
// Create a TextAnnotation and specify the inscription and position for it
val textAnnotation = sciChartBuilder.newTextAnnotation()
.withX1(5.0)
.withY1(55.0)
.withText("Hello World!")
.withHorizontalAnchorPoint(HorizontalAnchorPoint.Center)
.withVerticalAnchorPoint(VerticalAnchorPoint.Center)
.withFontStyle(20f, ColorUtil.White)
.build()
// Create interactivity modifiers
val chartModifiers = sciChartBuilder.newModifierGroup()
.withPinchZoomModifier().withReceiveHandledEvents(true).build()
.withZoomPanModifier().withReceiveHandledEvents(true).build()
.build()
// Add the Y axis to the YAxes collection of the surface
Collections.addAll(surface.yAxes, yAxis)
// Add the X axis to the XAxes collection of the surface
Collections.addAll(surface.xAxes, xAxis)
// Add the annotation to the Annotations collection of the surface
Collections.addAll(surface.annotations, textAnnotation)
// Add the interactions to the ChartModifiers collection of the surface
Collections.addAll(surface.chartModifiers, chartModifiers)
}
Any assistance appreciated. Thank you.
- C Bolton asked 4 years ago
- You must login to post comments
Hi there,
You need to set license before any SciChart related stuff is used. That’s why in this article we create custom Application class. In your case I belive SciChartSurface is defined in XML layout which is inflated durin setContentView() call. This means that chart is created before license is set. Please try to move setRuntimeLicenseKey() before that call:
// Set this code once in MainActivity or application startup
SciChartSurface.setRuntimeLicenseKey("w2q0iyS8UeR2HKF...uqUbxqjprSIvXJPibCSl1g6ag==")
setContentView(R.layout.activity_main)
Hope this will help you!
Best regards,
Yura
- Yura Khariton answered 4 years ago
- You must login to post comments
Please login first to submit.