Hello! I want to create an AxisMarkerAnnotation but the padding doesn’t match the position of the text on the axis – I would like to align it and what is the way to do it? couldn’t find the right settings
- Sergey Evdokimov asked 3 days ago
- last active 3 days ago
I have a screen with multiple chart surfaces stacked on top of each other within a ScrollView. I can’t use a single chart surface because each of the charts is combined with other types of views to display extra information about the data in the charts.
I have a few issues I’m trying to solve:
Each of the charts uses the same x-axis range. When a user pinches to zoom or drags to pan on a chart, I want all the charts to be synchronized to zoom and pan at the same time. How can I do this?
Because the charts are embedded in a ScrollView, when I use the following modifiers it is very difficult to smoothly zoom and pan without the ScrollView being activated to scroll up and down. How can I make it so that the ScrollView is deactivated from moving while the user is attempting to zoom or pan a chart
surface.chartModifiers.add(
XAxisDragModifier().apply {
dragMode = AxisDragModifierBase.AxisDragMode.Pan
minTouchArea = 1000.0f
}
)
surface.chartModifiers.add(
PinchZoomModifier().apply {
direction = Direction2D.XDirection
}
)
- Marcela Guerra asked 6 days ago
- last active 4 days ago
Hello! I am try to create chart with axis on top in my react native app, chart is create succesfuly, but when I start add annotation – it shift to top by axis height – whats may be wrong?
`
// create
surface = new CSciChartSurface(context);
surface.setRenderSurface(new RenderSurface(context));
// Initialize the SciChartBuilder
SciChartBuilder.init(context);
// Obtain the SciChartBuilder instance
sciChartBuilder = SciChartBuilder.instance();
xAxis = sciChartBuilder
.newCategoryDateAxis()
.withTextFormatting(DateChartFormatter.defaultDateFormat)
.withGrowBy(0.0d, 0.04d)
.withDrawMajorGridLines(true)
.withDrawMinorGridLines(false)
.withDrawMajorBands(false)
.withDrawMajorTicks(false)
.withAxisAlignment(AxisAlignment.Top)
.build();
// same yaxis and any
VerticalLineAnnotation verticalLine = sciChartBuilder.newVerticalLineAnnotation()
.withPosition(10, 16)
.withStroke(2, ColorUtil.Orange)
.withIsEditable(true)
.build();
Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getRenderableSeries(), lineRenderableSeries);
Collections.addAll(surface.getAnnotations(), verticalLine);
// add to view
this.addView(surface);
`
- Sergey Evdokimov asked 3 weeks ago
- last active 3 weeks ago
Hello! How i can create same style on select chart
i use public class XyCustomPaletteProvider extends PaletteProviderBase<XyRenderableSeriesBase> implements IFillPaletteProvider, IStrokePaletteProvider, IPointMarkerPaletteProvider {
but i can pass only single color like this:
I try create three AreaStyle with gradient but nothing could be done…
use version SciChart 4.4.0.4739
- Sergey Evdokimov asked 3 weeks ago
- last active 3 weeks ago
I need to show cursor on chart on button click.
Same like finance chart api.
- Amol Patil asked 1 month ago
- last active 1 month ago
Hello,
I am developing a finance application and I am using AnimatingLineChart for it. I want prices like tickLine to be displayed instantly on this screen. But I’m having 2 problems while developing.
1- As I have included in the screenshot, the price movement seems to be in a straight line because the y-axis ranges are too much. I want to reduce the range here and show the price action in a healthier way. In the screenshot, the blue color is the graph drawn by the line graph, and the red color is the graph I want to draw. I create a very low range when determining the range, but this is not reflected in the chart. I am attaching the code I used below;
final NumericAxis yAxis = sciChartBuilder.newNumericAxis()
.withVisibleRange(new DoubleRange(1.095, 1.096))
.withGrowBy(new DoubleRange(0.1d, 0.1d))
.build();
2- Can I do this without entering a min and max value for Y axis while using this chart type? I want to create a structure in which it will dynamically determine the max and min values according to the price data it receives.
Do you have any suggestions for improving these or a better graphic type for it?
Thank you and have nice work.
- devrim çatak asked 2 months ago
- last active 1 month ago
Hello,
while developing on XML in my Android project, I see the preview instantly, but when I add “com.scichart.charting.visuals.SciChartSurface” to my XML codes, the preview stops working. There was no such problem before, but I’ve been encountering this problem recently and unfortunately I couldn’t find a solution. I have adjusted Clean Project, Rebuild Project, Invalid Cache and Gradle Update, but no results. I add the image that occurs when I add a surface.
Best regards.
- devrim çatak asked 2 months ago
Hi, I’d like to preview SciChartSurface in Compose using @Preview annotation.
I am getting error
java.lang.NoClassDefFoundError: Could not initialize class com.scichart.drawing.canvas.RenderSurface$d
@Composable
fun MyAndroidViewPreview() {
val context = LocalContext.current
AndroidView(
factory = { context ->
// Create Android View with SciChartSurface
SciChartSurface(context)
},
update = { view ->
// Update Android View here
}
)
}
@Preview
@Composable
fun MyAndroidViewPreviewWrapper() {
MyAndroidViewPreview()
}
- Sebastian Paciorek asked 2 months ago
I’m seeing a crash log that happens only some times (it’s not consistently reproducible) that looks like this:
libc F FORTIFY: pthread_mutex_lock called on a destroyed mutex
libc F Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 10371 (GLThread), pid 9832
DEBUG F #00 pc 00000000000531f4 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #01 pc 000000000005507c /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+124) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #02 pc 00000000000c360c /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+60) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #03 pc 00000000000c34a0 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_lock+208) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #04 pc 0000000000833ac8 /vendor/lib64/egl/libGLES_mali.so (eglp_try_display_finish_terminating+88) (BuildId: 556d636a49f8475a)
F #05 pc 000000000083f268 /vendor/lib64/egl/libGLES_mali.so (eglp_release_tls+232) (BuildId: 556d636a49f8475a)
F #06 pc 00000000000c2c8c /apex/com.android.runtime/lib64/bionic/libc.so (pthread_key_clean_all()+124) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #07 pc 00000000000c2408 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_exit+72) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #08 pc 00000000000c2270 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: dc4001c2ef2dfc23467040797a96840c)
F #09 pc 0000000000054a30 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: dc4001c2ef2dfc23467040797a96840c)
Any idea what could be happening?
- Marcela Guerra asked 3 months ago
Lets imagine that we have zoom feature and we want to format axis depend on user selected zoom. for example if year select yearly the pattern is yyyy MM dd and if selected zoom is day the pattern is something like this HH:mm:ss. how we can achieve to this goal?
- Vahid Garousi asked 3 months ago
- last active 3 months ago
I get this error when i want to download this dependency.
please help me
- Vahid Garousi asked 3 months ago
Hi,
I am trying to implement an improvement for my app where the chart is hidden if the licence key is invalid. But I can’t find how to do that. If I enter an invalid key like shown in examples, the code never ends up in the catch clause. Is there any other way? Or is this a bug?
try {
SciChartSurface.setRuntimeLicenseKey(getString(R.string.sci_chart_runtime_licence_key));
} catch (Exception e) {
Elog.e("SciChart Error when setting the license", e);
}
- Evado Dev asked 4 months ago
- last active 4 months ago
How can we change Xaxis to Arabic date?
- Vahid Garousi asked 4 months ago
- last active 3 months ago
Hi,
i have some candles and i want to force the chart for removing candles with
open = Double.NaN
high = Double.NaN
low = Double.NaN
close = Double.NaN
openTime – special day (timestamp)
What I see:
- Vahid Garousi asked 4 months ago
- last active 3 months ago
Hi,
I’m using scichart for android and trying to change the color of the column that was hit by touch. I have successfully identified which index of the data series that was hit. I’ve looked all over the android documentation but does not find an answer or example for this. This is my onTouch function:
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
SciChartSurface surface = (SciChartSurface) view;
touchPoint.set(motionEvent.getX(), motionEvent.getY());
surface.translatePoint(touchPoint, surface.getRenderableSeriesArea());
for (IRenderableSeries renderableSeries : surface.getRenderableSeries()) {
renderableSeries.hitTest(hitTestInfo, touchPoint.x, touchPoint.y, 30);
if (hitTestInfo.isHit) {
Double yValue = consumptionDataSeries.getYValues().get(hitTestInfo.dataSeriesIndex);
// Todo: Show a text annotation and color the column differently
Toast.makeText(this.getContext(), yValue.toString(), Toast.LENGTH_SHORT).show();
}
}
return true;
}
What should I do next?
- Linnea Springare asked 4 months ago
- last active 4 months ago
Hello,
I am using a candlestick chart for a financial application and I want to add the sign and price to the highest and lowest price bar that appears on the screen as in the attached image. As the chart is scrolled, the highest price and lowest price data and location should also change. how can I do that?
Best regards.
- devrim çatak asked 4 months ago
- last active 4 months ago
Hello,
As you can see in the attached image, I’m using a Candlestick Chart for a financial application, but the gap between each bar on the chart is pretty small and it doesn’t look good.
I want to add a space between the bars but I couldn’t find how to do it. Can you help me?
Best regards.
- devrim çatak asked 5 months ago
- last active 4 months ago
Hi,
I am new to SciCharts and I am developing line chart with multiple line series with different colors. All line series have time span on X-axis and a double value on Y-axis. I need to show time ticks after specific interval for example i need to show tick after every 30 seconds or 1 minute or 3 minute. and may else.I have also took a look at Major Delta and Minor delta but i am confused and not properly using it . And also interval can be changed with at runtime like a user can select that they want to see X-axis time tick after every 30 second or 50 second or etc. Please can you give me and example for it. I hope for Quick repsonse.
Date majorDelta = new Date(DateIntervalUtil.fromSeconds(1));
Date minorDelta = new Date(DateIntervalUtil.fromSeconds(30));
DateAxis xAxis = sciChartBuilder.newDateAxis()
.withAutoRangeMode(AutoRange.Never)
.withSubDayTextFormatting(“mm:ss”)
.withMinorDelta(majorDelta)
.withMajorDelta(minorDelta)
.withAutoTicks(false)
.build();
Best Regards,
- Zahid Mahmood asked 5 months ago
- last active 5 months ago
In financial markets, there is a type of chart that is as follows.
I did not find this type of chart in SciChart.
Please help me how to draw this chart
- Vahid Garousi asked 6 months ago
- last active 5 months ago
I need to create a multi line chart along with a seekbar at bottom and If user moves the seekbar then line chart should show a tooltip or marker view at that point.
- satyam kamboj asked 6 months ago
- last active 5 months ago
Hi
I want to access the SciTrader application source so that I can implement the features I need by checking it.
Please guide me to access this source code
- Vahid Garousi asked 6 months ago
- last active 6 months ago
Hello. Some time ago we started receiving very interesting crash reports in our crashlytics about scichart init. We can’t reproduce it by ourselves, but there are a lot of samples from our users with different devices and with different Android OS.
Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.**.**-WqNyhtp24SkSTYz13S2c3w==/base.apk"],nativeLibraryDirectories=[/data/app/com.**.**-WqNyhtp24SkSTYz13S2c3w==/lib/arm64, /system/lib64]]] couldn't find "libcore.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at com.scichart.core.utility.NativeLibraryHelper.tryLoadLibrary(SourceFile:2)
at com.scichart.core.utility.NativeLibraryHelper.tryLoadCoreLibrary(:2)
at com.scichart.core.licensing.Credentials.<clinit>(SourceFile:1)
at com.scichart.core.licensing.Credentials.setRuntimeLicenseKey(SourceFile:1)
at com.scichart.charting.visuals.SciChartSurface.setRuntimeLicenseKey()
At our last build we added
abi {
enableSplit = false
}
This action reduced the number of crashes, but it still happens:
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/mnt/asec/com.**.**-2/base.apk!/lib/armeabi-v7a/libcore.so" segment 1: Permission denied
at java.lang.Runtime.loadLibrary0(Runtime.java:989)
at java.lang.System.loadLibrary(System.java:1567)
at com.scichart.core.utility.NativeLibraryHelper.tryLoadLibrary(SourceFile:2)
at com.scichart.core.utility.NativeLibraryHelper.tryLoadCoreLibrary(SourceFile)
at com.scichart.core.licensing.Credentials.<clinit>(SourceFile:1)
at com.scichart.core.licensing.Credentials.setRuntimeLicenseKey(SourceFile:1)
at com.scichart.charting.visuals.SciChartSurface.setRuntimeLicenseKey(SourceFile)
Have there been similar problems?
- Alexander Ostrovsky asked 6 months ago
- last active 1 month ago
Hello!
The legend is in horizontal orientation, and Im displaying multiple series.
When the legend is inside the chart (default config), Im able to scroll left or right to see all available series.
But when it is moved outside the chart, it is no longer scrollable. Checkboxes are still clickable to show or hide series.
Thinking it might be something interfering with the scroll gesture, I started a new project following the Android tutorial. It still stops working as soon as I move it outside the chart.
Is this a bug, or am I missing something?
This does not happens on iOS.
Regards
XML Layout
`
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_margin="30dp"
android:id="@+id/chart_layout"
android:layout_width="match_parent"
android:layout_height="500dp"
android:orientation="horizontal"/>
<com.scichart.charting.visuals.legend.SciChartLegend
android:id="@+id/legend"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"/>
</LinearLayout>
`
Legend and LegendModifier config
final SciChartLegend legend = findViewById(R.id.legend);
legend.setLegendOrientation(Orientation.HORIZONTAL);
final LegendModifier legendModifier = new LegendModifier(legend, false);
surface.getChartModifiers().add(legendModifier);
- Rodrigo Garcia asked 7 months ago
- last active 7 months ago
Does Scichart Android have a function to import 3D models (.obj, .cad…)?
- Hyunji Jeon asked 7 months ago
Hi there!
I wonder if SciChart has support (for Android & iOS) for the following chart types (see attached example chart images):
Timeline chart (where events are mapped onto a linear timeline)
“Equation” chart (which shows an ellipsis, based on a mathematical equation)
Polar chart (as line, column and stacked bars)
If yes, how do I implement these chart types!?
Thanks in advance!
/Jacob
- Jacob Mattsson asked 8 months ago
- last active 8 months ago
I have been following the tutorials and in Tutorial 3 I have come to the point where data is added to an XyDataSeries and need to know the proper way to do it in Kotlin on Android (not Java).
In MainActivity.kt I have:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
SciChartSurface.setRuntimeLicenseKey("...");
val surface = SciChartSurface(this)
val chartLayout = findViewById<View>(R.id.chart_layout) as LinearLayout
chartLayout.addView(surface)
SciChartBuilder.init(this)
val sciChartBuilder = SciChartBuilder.instance()
val xAxis = sciChartBuilder.newNumericAxis()
.withAxisTitle("X Axis Title")
.withVisibleRange(-5.0, 15.0)
.build();
val yAxis = sciChartBuilder.newNumericAxis()
.withAxisTitle("Y Axis Title")
.withVisibleRange(0.0, 100.0)
.build();
val textAnnotation = sciChartBuilder.newTextAnnotation()
.withX1(5.0)
.withY1(55.0)
.withText("Hello World!")
.withHorizontalAnchorPoint(HorizontalAnchorPoint.Center)
.withVerticalAnchorPoint(VerticalAnchorPoint.Center)
.withFontStyle(20f, ColorUtil.White)
.build()
val chartModifiers = sciChartBuilder.newModifierGroup()
.withPinchZoomModifier().withReceiveHandledEvents(true).build()
.withZoomPanModifier().withReceiveHandledEvents(true).build()
.build()
// App crashes at the following point
val lineData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries(
Int::class.java,
Double::class.java
).build()
// I presume this is also incorrect
val scatterData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries(
Int::class.java,
Double::class.java
).build()
for (i in 0..999) {
lineData.append(i, Math.sin(i * 0.1))
scatterData.append(i, Math.cos(i * 0.1))
}
val lineSeries = sciChartBuilder.newLineSeries()
.withDataSeries(lineData)
.withStrokeStyle(ColorUtil.LightBlue, 2f, true)
.build();
surface.renderableSeries.add(lineSeries);
Collections.addAll(surface.yAxes, yAxis);
Collections.addAll(surface.xAxes, xAxis);
Collections.addAll(surface.annotations, textAnnotation);
Collections.addAll(surface.chartModifiers, chartModifiers);
}
}
The app crashes at the lines “val lineData: XyDataSeries<Int, Double> = sciChartBuilder.newXyDataSeries( …”. What is wrong here?
- David Fleener asked 8 months ago
- last active 8 months ago
Hi,
We want to implement averaging of data points when you zoom into a graph.
We have implemented pre-processed average plotting – and this works for certain cases.
Basically, you see less point markers when you zoom out a certain level (point marker will show averaged points), and when you zoom in, point markers show increased sample points – in real time.
- Is there a an API that enables this capability and determining when the averaging happens (at what zoom level) and the averaging period (to average values over)?
- If there isn’t an API, can you point us in the right direction to implement such feature?
- Eyram Dornor asked 9 months ago
- last active 8 months ago
Hi,
I have annotation, users can it drag and drop. But for it first need select this annotation and after drag it(with re-touching).
How to immediately drag annotation(without re-touching)?
Thanks in advance.
Regards,
Batyr
- Batyr Batyr asked 9 months ago
I am working on Android Application and I have a different requirement where I want to display all the values String array on XAxis, I don’t want to use DateAxis nor VisibleRange function, also no value should be hidden as we are not giving any zoom-in and out functionality in our app.
I would really appreciate if you can please assist with this
Thanks
Regard
- Yasir Ameen asked 10 months ago
- last active 9 months ago
Hello,
I am working on an android application for the tablet view I need to write and show XAxis with the following information
- 1 Day => need to show 24 XAxis ticks with 1 hour each with a difference of 10 means e.g 10:10, 11:10, 12:10 and so on
- 3 Day => need to show 4 XAxis ticks like if that covers 72 hours by showing the date
- 1 Month => need to show 30 XAxis ticks with a date, 1 day each
the difficulty I m facing is that I m not finding any starting point to do the above things properly, I tried DateSeries but the date is showing dynamically and there is no how to define starting and endpoint
Thanks
Regards
- Yasir Ameen asked 10 months ago
- last active 10 months ago
Hi,
I would like to display all the hours of the day in X axis e.g 01 to 24 and I haven’t been able to achieve it yet, I tried use date delta but I couldn’t figure out how it really works, could you please share a code snippet or some example.
Thanks
- Anas Iqbal asked 10 months ago
- last active 10 months ago
Hello, we are developing a finance application that contains sciChart. Our main chart and optionally RSI, MACD etc. There are indicators. I want the user to screenshot and share the graph and the indicators, but I’m having trouble doing this. Although I tried more than one way for this, I encountered different problems in all of them.
First of all, I take a screenshot with the createBitmap and Canvas method of the Layout where my graphics are located, but the graphic contents are not visible in the screenshot content.
As the second method, I tried the exportToBitmap method in sciChart, but here I only take a screenshot of 1 chart, I cannot take a screenshot of a graph + RSI + MACD at the same time. As another problem, the opening, closing, high, etc. of the parity on the chart. The texts containing the data are not visible in the screenshot.
Below I will share the screenshots I took with both the first method and the second method, the image on the phone at that moment, and the codes I used.
What I wanted to use was to take a screenshot of more than one graph and the data on it at the same time as in the first method. How can I do that?
Method 1
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
Method 2
surface.exportToBitmap()
- devrim çatak asked 10 months ago
- last active 10 months ago
Hi Team,
When we except this feature
- Centrl Test asked 11 months ago
- last active 11 months ago
We are testing your Android Example application, andwe are trying to find out the capabilities of the 2d Heatmap chart.
I have found in your documentation that you have the “Heatmap Texture Filtering” feature, anyways I am not able to set it as true in the heatmap plot. (found on the [WPF Heatmap Chart documentation][1 )
Is this feature disabled in Android Charts?
I am trying to enable this filtering, but the modification on your example app does not compile.
I have already tried to modify other stuff on your heatmap example chart, and it works, but particularly in our application we need as a must this kind of feature. It will be finally something that helps us to decide if your SciChart library meet our requirement.
Thanks for your attention,
- Eduardo Robles asked 11 months ago
- last active 11 months ago
Hi.
We want to use your Android Chart library in our project. I’m getting familiar with it and I don’t totally gets how to implement Scrolling Realtime (FIFO) Line Chart.
What we want to do: our copmany wants an app that will represent the data on the line charts from their sensors. I need real-time (FIFO) representation from 1 to 16 charts in RecyclerView.
The guide here doesn’t cover the whole implementation (for example, we add data to XyDataSeries, but where to add these series to surface is not indicated). And link to github is not working also.
Do you have some example code or documentation regarding it?
- Yevgenij Homyak asked 11 months ago
- last active 11 months ago
Hi Guys,
I am implementing the column chart, but the xAxis value is duplicate when I scroll the chart. Please see the images attachment.
Here are the piece of code, and wandering what cause this, thx!
package com.refinitiv.android.presentation.view.chart.stack
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.scichart.charting.ClipMode
import com.scichart.charting.Direction2D
import com.scichart.charting.model.ChartModifierCollection
import com.scichart.charting.model.dataSeries.IXyDataSeries
import com.scichart.charting.modifiers.AxisDragModifierBase
import com.scichart.charting.modifiers.XAxisDragModifier
import com.scichart.charting.modifiers.ZoomPanModifier
import com.scichart.charting.numerics.labelProviders.NumericLabelFormatter
import com.scichart.charting.numerics.labelProviders.NumericLabelProvider
import com.scichart.charting.numerics.tickProviders.NumericTickProvider
import com.scichart.charting.visuals.SciChartSurface
import com.scichart.charting.visuals.axes.AutoRange
import com.scichart.charting.visuals.axes.AxisTickLabelStyle
import com.scichart.charting.visuals.axes.IAxis
import com.scichart.charting.visuals.renderableSeries.IRenderableSeries
import com.scichart.charting.visuals.renderableSeries.StackedColumnRenderableSeries
import com.scichart.charting.visuals.renderableSeries.VerticallyStackedColumnsCollection
import com.scichart.core.framework.UpdateSuspender
import com.scichart.core.model.DoubleValues
import com.scichart.core.model.IntegerValues
import com.scichart.data.model.DoubleRange
import com.scichart.drawing.canvas.RenderSurface
import com.scichart.drawing.common.FontStyle
import com.scichart.drawing.common.PenStyle
import com.scichart.drawing.common.SolidPenStyle
import com.scichart.extensions.builders.SciChartBuilder
import timber.log.Timber
import java.util.*
import kotlin.math.roundToInt
private const val GROW_BY: Double = 0.0
private const val MAX_VISIBLE_COLUMNS = 11
private const val MIN_VISIBLE = -0.5
class StackColumnChartView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
private val chart = SciChartSurface(context)
private val typefaceSemibold =
ResourcesCompat.getFont(context, R.font.proxima_nova_fin_semibold)
private val tickFontStyle = FontStyle(
typefaceSemibold,
resources.getDimension(R.dimen.chart_axis_text_size),
getColorFromAttrOrDefault(R.attr.chartAxisTextColor, R.color.dove_grey),
true
)
private val majorGridLineAndTickStyle: PenStyle = SolidPenStyle(
getColorFromAttrOrDefault(R.attr.cardViewItemDividerBackground, R.color.desert_storm_50),
true,
resources.getDimension(R.dimen.chart_grid_line_thickness),
null
)
var xAxisLabelList = emptyList<String>()
var yAxisLabelList = mutableListOf("0%", "20%", "40%", "60%", "80%", "100%")
var dataList: List<List<Double>> = emptyList()
private lateinit var xAxisData: List<Double>
init {
chart.renderSurface = RenderSurface(context)
val params = LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
)
chart.layoutParams = params
addView(chart)
chart.theme = R.style.SciChart
}
fun buildChart() {
Timber.tag("CHART").d("CURVE CHART View build chart")
SciChartBuilder.init(context)
val sciChartBuilder: SciChartBuilder = SciChartBuilder.instance()
xAxisData = xAxisLabelList.mapIndexed { index, _ ->
index.toDouble()
}
val xAxis = initXAxis(sciChartBuilder)
val yAxis = initYAxis(sciChartBuilder)
val dataSeries = initDataSeries(context, sciChartBuilder)
val surfaceChartModifiers: ChartModifierCollection = chart.chartModifiers
val zoomPanModifier = ZoomPanModifier()
zoomPanModifier.direction = Direction2D.XDirection
zoomPanModifier.clipModeX = ClipMode.ClipAtExtents
zoomPanModifier.clipModeY = ClipMode.None
zoomPanModifier.zoomExtentsY = false
val dragModifier = XAxisDragModifier()
dragModifier.dragMode = AxisDragModifierBase.AxisDragMode.Pan
surfaceChartModifiers.add(dragModifier)
UpdateSuspender.using(chart) {
chart.xAxes.clear()
chart.yAxes.clear()
chart.annotations.clear()
chart.renderableSeries.clear()
Collections.addAll(chart.xAxes, xAxis)
Collections.addAll(chart.yAxes, yAxis)
Collections.addAll(chart.renderableSeries, dataSeries)
Collections.addAll(chart.chartModifiers, zoomPanModifier)
Collections.addAll(chart.chartModifiers, dragModifier)
}
}
fun clearChart() {
UpdateSuspender.using(chart) {
chart.xAxes.clear()
chart.yAxes.clear()
chart.annotations.clear()
chart.renderableSeries.clear()
}
}
private fun initDataSeries(
context: Context, sciChartBuilder: SciChartBuilder
): IRenderableSeries {
val verticalCollection = VerticallyStackedColumnsCollection()
val seriesList = dataList.mapIndexed { _, xValue ->
val series: IXyDataSeries<Double, Double> = sciChartBuilder.newXyDataSeries(
Double::class.javaObjectType,
Double::class.javaObjectType
).build()
for (i in xAxisData.indices) {
series.append(xAxisData[i], xValue[i])
}
series
}
val result = seriesList.mapIndexed { index, series ->
val color: Int = if (index < colorList.size) {
ContextCompat.getColor(context, colorList[index])
} else {
ContextCompat.getColor(context, colorList[index % colorList.size])
}
val stack: StackedColumnRenderableSeries =
sciChartBuilder.newStackedColumn().withDataSeries(series).withFillColor(color)
.withStrokeStyle(
ContextCompat.getColor(
context, R.color.chatline_white
), 0.2F
)
.build()
stack
}
verticalCollection.addAll(result)
verticalCollection.dataPointWidth = 0.4
verticalCollection.isOneHundredPercent = true
return verticalCollection
}
private fun initXAxis(
sciChartBuilder: SciChartBuilder
): IAxis {
val horizontalAxisTickLabelStyle = AxisTickLabelStyle(
Gravity.CENTER_VERTICAL,
0,
context.resources.getDimensionPixelSize(R.dimen.pe_firm_investment_profile_chat_view_label_margin_vertical),
0,
0,
)
val visibleMin = if (xAxisLabelList.size > MAX_VISIBLE_COLUMNS) {
(xAxisLabelList.size - MAX_VISIBLE_COLUMNS).toDouble()
} else {
MIN_VISIBLE
}
val xVisibleRange = DoubleRange(visibleMin, (xAxisLabelList.size + MIN_VISIBLE))
return sciChartBuilder
.newNumericAxis()
.build()
.apply {
axisTickLabelStyle = horizontalAxisTickLabelStyle
tickLabelStyle = tickFontStyle
drawMinorGridLines = false
drawMinorTicks = false
drawMajorTicks = false
drawMajorBands = false
drawMajorGridLines = false
autoFitMarginalLabels = true
visibleRange = xVisibleRange
// tickProvider = XTickProvider(xAxisData)
labelProvider =
NumericLabelProvider(FirmProfileDateAxisLabelFormatter(xAxisLabelList))
growBy = DoubleRange(GROW_BY, GROW_BY)
maxAutoTicks = xAxisLabelList.size
}
}
private fun initYAxis(
sciChartBuilder: SciChartBuilder
): IAxis {
val verticalAxisTickLabelStyle = AxisTickLabelStyle(
Gravity.CENTER_HORIZONTAL,
0,
0,
0,
0
)
return sciChartBuilder
.newNumericAxis()
.build()
.apply {
axisTickLabelStyle = verticalAxisTickLabelStyle
drawMajorGridLines = true
minimalZoomConstrain = 0.0
tickLabelStyle = tickFontStyle
majorTickLineStyle = majorGridLineAndTickStyle
majorGridLineStyle = majorGridLineAndTickStyle
labelProvider = FirmProfileYAxisLabelProvider(yAxisLabelList)
autoRange = AutoRange.Always
maxAutoTicks = yAxisLabelList.size
growBy = DoubleRange(GROW_BY, GROW_BY)
}
}
fun dispose() {
SciChartBuilder.dispose()
}
class XTickProvider(private val xAxisData: List<Double>) : NumericTickProvider() {
override fun updateCullingPriorities(
cullingPriorities: IntegerValues?,
majorTicks: DoubleValues?
) {
super.updateCullingPriorities(cullingPriorities, majorTicks)
}
override fun updateTicks(minorTicks: DoubleValues?, majorTicks: DoubleValues?) {
// super.updateTicks(minorTicks, majorTicks)
xAxisData.forEach {
majorTicks?.add(it)
}
}
override fun getMajorTickIndex(tick: Double): Int {
Timber.tag("StackColumn").v("getMajorTickIndex-:${tick}")
return super.getMajorTickIndex(tick)
}
override fun shouldUpdateTicks(): Boolean {
val should = super.shouldUpdateTicks()
Timber.tag("StackColumn").v("shouldUpdateTicks-:${should}")
return should
}
override fun isFirstMajorTickEven(majorTicks: DoubleValues?): Boolean {
return super.isFirstMajorTickEven(majorTicks)
}
}
class FirmProfileDateAxisLabelFormatter(private val labelTitles: List<String>) :
NumericLabelFormatter() {
private var lastFormatLabel = ""
override fun formatLabel(p0: Double): CharSequence {
Timber.tag("StackColumn").v("formatLabel-:${p0}")
if (labelTitles[p0.toInt()] == lastFormatLabel) {
return ""
}
return labelTitles[p0.toInt()]
}
override fun formatCursorLabel(p0: Double): CharSequence {
return formatLabel(p0)
}
}
class FirmProfileYAxisLabelProvider(private val labelList: List<String>) :
NumericLabelProvider() {
var index = 0
override fun formatLabel(p0: Double): CharSequence {
if (labelList.isEmpty()) {
return ""
}
val title = labelList[index]
index += 1
index = if (index < labelList.size) {
index
} else {
0
}
return title
}
override fun formatCursorLabel(p0: Double): CharSequence {
return formatLabel(p0)
}
}
companion object {
val colorList = mutableListOf(
R.color.chatline_blue_ribbon,
R.color.chatline_black,
R.color.chatline_teal,
R.color.chatline_butterfly,
R.color.chatline_olive,
R.color.chatline_grenadier,
R.color.chatline_rain_forest,
R.color.chatline_cerise_red,
R.color.chatline_scorpion,
R.color.chatline_jelly_bean,
R.color.chatline_genoa,
R.color.chatline_brown_rust,
R.color.chatline_torea_bay,
R.color.chatline_saddle_brown,
R.color.chatline_victoria,
R.color.chatline_sherpa_blue,
R.color.chatline_oregon,
R.color.chatline_kaitoke_green,
R.color.chatline_maroon_flush,
R.color.chatline_tundora,
R.color.chatline_chathams_blue,
R.color.chatline_eden,
R.color.chatline_mule_fawn,
)
}
}
- Steve Shan asked 12 months ago
- last active 11 months ago
Hello, I am developing a finance application and I am using candlestick chart here. I also use moving average and various indicators together with the chart. As the data I have shown in the chart is updated, I reflect them on the screen. My chart and indicators are updated as new data comes in, but I cannot update the value and name data that I have shown on the top left side of the chart for the indicator. Every time the data is updated, I want to take the last value of the indicator along with my graph and indicators and update it in the top left part. How can I do that? I will share with you the code of the indicator creation and indicator creation parts that I have used for the moving average. At the same time, this problem exists not only for indicators, but also for graphs. The open, close, high, low data of the chart are not updated when they should be updated every time the data comes in. I’ve added a screenshot to better explain the problem.
- devrim çatak asked 12 months ago
- last active 12 months ago
Hello, I was using version 4.2 before but I updated to version 4.4 last week. I am using candlestick chart in my project and show the chart in various time frames. These time periods include 1 day, 1 hour, 15 minutes, 1 minute and so on. Before the update to v4.4, when 1 time zone was selected, the example would show 09:00, 10:00, and on the 5 minute graph it would show as 09:00, 09:05, 09:10. After updating, it shows 09:00 instead of 09:05 when 5 minutes is selected, and 09:00 instead of 09:19 when 1 minute is selected. I want the date data that I added to the chart to be displayed as it is. I am also attaching screenshots for better understanding.
How can I fix this error I got? There is no problem with the data I have shown in the chart, it sounds as I want, but when I transfer it to the chart, it does not show as I want.
- devrim çatak asked 12 months ago
- last active 12 months ago
Hello, I was using version 4.2 before, but today I updated to version 4.4. I was using the updateCurrentPoint function in the CustomRolloverModifier in my project, but this function has changed in version 4.3. How can I use the updateCurrentPoint function in version 4.4?
- devrim çatak asked 1 year ago
- last active 1 year ago
Hello, I am a new developer who continues to develop scichart. In the currentPoint (or its name may be different) created after clicking in the developed application, the changes made on the graphic (changing the data, changing the graphic type, zooming in or out of the graphic, etc.), leaving these points where they are, breaks the graphic. In these cases, I need to either remove the point or make it move with the graph. how can I do that? I am developing with java. I uploaded the problem I encountered as a gif, you can understand it more clearly when you watch it.
- devrim çatak asked 1 year ago
- last active 1 year ago
Hi. For example, I set yAxis VisibleRange(-100, 100), but I need to see only 3 gridlines: -100, 0 and 100. I cannot find how to remove other gridlines.
- Yevhen Khomiak asked 1 year ago
- last active 1 year ago
Hello,
I was following the tutorial for building my first Chart for adroid.
I Download the newes version SciChart_ Android_v4.4.* and copy the lib in my FIles.
Since this went way to quick i opend the lib and it was empty, no .aar files.
I downloadet the adroid .zip again and still no .aar files in lib.
Then i downloadet the 4.3 version and there they are: aar files!
My Question: how do i get those files of the latest version?
- Julian Menon asked 1 year ago
- last active 1 year ago
Can I get a scroll offset of a chart and scroll a horizontal recycler simultaneously with the same offset?
- Iliya Mashin asked 1 year ago
Hi,
When using splinerenderable series, there visual issues (as if the data points are unsorted) with the spline line at certain zoom levels.
If you zoom in past a certain point, the spline line corrects itself, showing that the data points are sorted in order.
See the attached screenshot and project replicating the issue.
This issue may be related to other issues currently active:
- Eyram Dornor asked 1 year ago
- last active 1 year ago
Hi,
Our current chart setup is as follows: 2 charts, each with 2 line series (~23k data points per line series – datetime [x-axis], double[y-axis]), data is added to the line series in real-time and all data is retained (never deleted). Both charts share a motion events group (pinchzoom, rollover, xaxisdrag, zoomextents).
Of the 2 Line series, each line series can be removed or added to the chart at random.
We noticed that an index out of bounds error occurs if you quickly add/remove a new line series (plus data) and start zooming in/out quickly, as much as possible. – easiest way to replicate issue. In some cases, if you zoom in with an already loaded lines series, the error still comes up.
See attached txt logs.
I considered completely disabling chart interaction (by disabling chart modifiers) before adding or removing a line series, however, this caused other issues such as vertical annotations being removed.
- Eyram Dornor asked 1 year ago
- last active 1 year ago
Hi,
Our current chart setup is as follows: 2 charts, each with 2 line series (~23k data points per line series – datetime [x-axis], double[y-axis]), data is added to the line series in real-time and all data is retained (never deleted). Both charts share a motion events group (pinchzoom, rollover, xaxisdrag, zoomextents).
If you zoom in to the furthest zoom possible, the chart/app starts to act extremely sluggish, then crashes eventually. – see attached txt file for logs.
Questions:
- Is there a method to tackle this from a performance perspective and still enable zooming to the utmost limit?
- If 1.) is not possible, is it possible to enact a zoom limit on the charts?
Other solution suggestions are welcome.
- Eyram Dornor asked 1 year ago
- last active 1 year ago
We are working on an android based ELD application. We are looking for a ELD graph. Is it possible to accomplish this using SCICHART?
- saiesh raut asked 1 year ago
- last active 10 months ago
Is there an API of extension that would enable time-based average (e.g. average 10 minutes worth of data points) down-sampling of measurements?
Or is resorting to pre-filter provided data points the only option?
- Eyram Dornor asked 1 year ago
- last active 1 year ago
I have a strange padding in the end of the chart. I set drawLabels false and added annotations to it. And added makerPoint for the last point. So everything is clipped by this padding.
You can see this on the screenshot in the attachment
- Iliya Mashin asked 1 year ago
- last active 1 year ago
I want to format my labels after tapping a radio button. But the major labels with the “dd mm” pattern and the minor labels with the “HH:mm” pattern. If I check the radio button in the radio button group the labels will format with the others formats. It works with TradeChartAxisLabelProvider but I can’t handle it with my own formats. What I have to use?
- Iliya Mashin asked 1 year ago
- last active 1 year ago