SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0 votes
295 views

To whom this may concern:

I would like to create a custom data series where I can manipulate the X-Values more efficiently for a ColumnRenderableSeries, where if I remove a column from the chart or there is a gap in the data, I won’t have any spaces between any of the columns in the chart. I also haven’t found any documentation on creating a custom data series.

My approach is to treat the X values like a stack.
– If a point is appended, a value is pushed to the X values stack and the Y values list.
– If a point is to be removed using RemoveAt(), it only removes the Y-Axis value from the index and pops the X values stack so the order and spacing of the x-values remain the same.

This is similar to Microsoft Excel, where removing a data row linked to a chart deletes the X-axis value instead of leaving a gap.

My thinking is making the following derivation of XYDataSeries (in C# pseudocode):

ColumnDataSeries<TY> : XyDataSeries<int, TY> where TY : IComparable
{
    Stack<IComparable> XValues { get; set; }
    IList<IComparable> YValues { get; set; }

    Append (T value) 
    {
        XValues.Push (XMax + 1);
        YValues.Add (value);
    }

    RemoveAt (int index) 
    {
        XValues.Pop ();
        YValues.RemoveAt (index);
    }
}

Can you please advise or provide any documentation for this?

Thank you, and best regards!

— Ari

Edit: Sorry if the code doesn’t look right, I don’t know how to properly wrap C# code on the forums.
Edit 2: Second attempt at posting code. Should see the generics now.

  • Ari Sagiv asked 3 months ago
  • last active 3 months ago
0 votes
639 views

Hello everybody.

What is the best way to pass 3 y-values to single x-value?

Currently i’m using XyyDataSeries + XyDataSeries

Don’t know, if it’s best approach?

0 votes
756 views

I have created a SciChartSurface with the width of 200 px. I have created a data series with data that corresponds to four vertical lines at 0 %, 25 %, 50 % and 75 % of width. When I set the data series’ width to 115 points all four vertical lines are clearly visible. However when I set the width to 116 points or more, the first line (at x == 0) disappears. Data series is still smaller than the renderable series width in px, so there is no reason for any of the vertical lines to go missing. Is this a bug, or did I configure something wrong?

Here is the xml layout:

<com.scichart.charting.visuals.SciChartSurface
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/chart"
    android:layout_width="200px"
    android:layout_height="match_parent"/>

Here is the code for MainActivity:

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.scichart.charting.model.dataSeries.UniformHeatmapDataSeries
import com.scichart.charting.visuals.SciChartSurface
import com.scichart.charting.visuals.renderableSeries.ColorMap
import com.scichart.drawing.utility.ColorUtil
import com.scichart.extensions.builders.SciChartBuilder
import kotlin.math.roundToInt

const val WIDTH = 116
const val HEIGHT = 50

class MainActivity : AppCompatActivity()
{
    override fun onCreate(savedInstanceState: Bundle?)
    {
        super.onCreate(savedInstanceState)

        SciChartSurface.setRuntimeLicenseKey(getString(R.string.sciChart_license))
        SciChartBuilder.init(this)

        setContentView(R.layout.activity_main)

        val chartSurface = findViewById<SciChartSurface>(R.id.chart)
        val chartBuilder = SciChartBuilder.instance()

        val xAxis = chartBuilder.newNumericAxis().build()
        val yAxis = chartBuilder.newNumericAxis().build()

        val dataSeries = UniformHeatmapDataSeries<Int, Int, Int>(Int::class.javaObjectType, Int::class.javaObjectType, Int::class.javaObjectType, WIDTH, HEIGHT)
        for (x in 0 until WIDTH)
        {
            for (y in 0 until HEIGHT)
            {
                val value = when (x)
                {
                    0,
                    (0.25 * WIDTH).roundToInt(),
                    (0.5 * WIDTH).roundToInt(),
                    (0.75 * WIDTH).roundToInt() -> 50
                    else                        -> 0
                }
                dataSeries.updateZAt(x, y, value)
            }
        }

        val series = chartBuilder.newUniformHeatmap()
            .withColorMap(ColorMap(intArrayOf(ColorUtil.DarkBlue, ColorUtil.CornflowerBlue, ColorUtil.DarkGreen, ColorUtil.Chartreuse, ColorUtil.Yellow, ColorUtil.Red), floatArrayOf(0f, 0.2f, 0.4f, 0.6f, 0.8f, 1f)))
            .withDataSeries(dataSeries)
            .build()

        chartSurface.suspendUpdates().use {
            chartSurface.xAxes.add(xAxis)
            chartSurface.yAxes.add(yAxis)
            chartSurface.renderableSeries.add(series)
        }
    }
}
0 votes
2k views

Hi,

I have a question concerning multithreaded access to the DataSeries:

We implemented an overview for our chart as described here. This works fine when we load data, add it to the series and then display it.

Now, for a certain use case we need to display live data. We implemented this in a background thread. We noticed that after some time the application freezes when the update frequency rises. In the documentation I found this:

NOTE: Considerations when a DataSeries is shared across multiple chart surfaces. Currently only a single parent chart is tracked, so DataSeries.SuspendUpdates() where the DataSeries is shared may have unexpected results.

I guess this is what is happening here…so what is the recommended approach to achieve something like this? Do we have to add the data on the UI thread if we want to have the Overview? Here it says:

When appending Data in a background thread, you cannot share a DataSeries between more than one SciChartSurface. You can still share a DataSeries between more than one RenderableSeries.

Does that mean we should create more different RenderableSeries for the main chart surface and the overview surface that are based on the same DataSeries? Any help would be appreciated!

0 votes
3k views

Hi,

Is there any way to get back the 2D data array from the Heatmap2DArrayDataSeries object?

Full of hope for positive answer,
Mark

0 votes
6k views

Hello,

I wonder what the most efficient way is to completely reset (clean up) a SciChartGroup? I add all kinds of panes, add data series, add renderable series on different panes. Now, with a single call I like to reset the SciChartSurface to its original state (empty). I want to have all panes removed, as well as references the sciChartGroup may hold to panes, and references the panes hold to different renderable series and data series. I tried to clear ChartPaneViewModels, an observable collection that holds objects of type BaseChartPaneViewModel (which in turn implements IChildPane and ViewModelBase) but that did not have any effect. My SciChartGroup binds via ItemsSource to ChartPaneViewModels

What is your recommendation how to best reset the whole sciChartGroup?

Thanks,
Matt

  • bbmat asked 5 years ago
  • last active 5 years ago
Showing 6 results
This template supports the sidebar's widgets. Add one or use Full Width layout.
SciChart WPF v6 BETA released! Note pricing/licensing changes are coming. Contact us to beat the rise!Read more
+