Chart Behavior

Posted by: Luis.Alvarez on 8 February 2019, 12:21 am EST

  • Posted 8 February 2019, 12:21 am EST

    Hello,

    My application uses charts to display data. The charts need to be updated when the user selects a different data source. I noticed that when the user selected a different data source by clicking on a Button which in turn calls an event handler the chart were not being updated and started to behave erratically. However, when the user selected a different set of charts by selecting a different tab of a TabControl the charts were properly updated. I created a VB application that shows the same symptoms when a button is clicked and have attached the .xaml and .vb files. Basically the charts are properly updated when I set the btnClick variable to True in the Mult_Graphs Sub. When I set it to False and the user presses the Test button, which sets the btnClick variable to True and calls the same Subroutine, the charts display the same graphic with a different color but do not display the new data. By the way I noticed that when the application runs the Visual Studio Output console displays "1"s after the C1.WPF.SpreadSheet.C1Chart.4 and C1.WPF.SpreadSheet.C1Chart3D.4 loaded messages.

    Thanks,
    Luis Alvarezchart_files.zip
  • Replied 11 February 2019, 9:13 pm EST

    Hi Luis,

    I am having no trouble updating the chart with new data. I tested the issue by updating all Spread sheets chart data in button click at one go. It works fine.
    Please refer to the attached sample application.


    Thanks,
    Deepak Sharma
    SpreadXAMLChartsPaint.zip
  • Replied 12 February 2019, 6:38 am EST

    Deepak,

    I tried your code and I see that the first set of data charts is replaced by two sets of data. One with no label and the second with a "series2" label. But when I click on the "test" button a second time the charts display three data sets, "Series1", no label, "Series2". Pressing the test button a third time adds another series to the chart. What I'm trying to do is to replace the data series that is shown with a new set of data series so that only one set of data is displayed.

    Thanks,
    Luis Alvarez
  • Replied 12 February 2019, 10:50 pm EST

    Deepak,

    Ignore my 02/12/2019 reply. I'll use the example you attached and tailor it to the needs of my application.

    Thanks,
    Luis Alvarez
  • Replied 12 February 2019, 10:56 pm EST

    Hello,

    In code, I am removing only first series, and adding two series. This is why it shows you three series on second click of button. You can remove both the series from chart in order to add fresh new series on button click everytime.
    Change this :

    For i = 1 To 8
    Dim firstSheetChart = TryCast(Me.FindName("gcSpreadSheet" & i), GcSpreadSheet).ActiveSheet.Charts(0)
    firstSheetChart.DataSeries.RemoveAt(0)



    To:


    For i = 1 To 8
    Dim firstSheetChart = TryCast(Me.FindName("gcSpreadSheet" & i), GcSpreadSheet).ActiveSheet.Charts(0)
    firstSheetChart.DataSeries.RemoveAt(1)
    firstSheetChart.DataSeries.RemoveAt(0)


    Thanks,
    Deepak Sharma
  • Replied 12 February 2019, 10:56 pm EST

    Hello,

    In code, I am removing only first series, and adding two series. This is why it shows you three series on second click of button. You can remove both the series from chart in order to add fresh new series on button click everytime.
    Change this :

    For i = 1 To 8
    Dim firstSheetChart = TryCast(Me.FindName("gcSpreadSheet" & i), GcSpreadSheet).ActiveSheet.Charts(0)
    firstSheetChart.DataSeries.RemoveAt(0)



    To:


    For i = 1 To 8
    Dim firstSheetChart = TryCast(Me.FindName("gcSpreadSheet" & i), GcSpreadSheet).ActiveSheet.Charts(0)
    firstSheetChart.DataSeries.RemoveAt(1)
    firstSheetChart.DataSeries.RemoveAt(0)


    Thanks,
    Deepak Sharma
  • Replied 14 February 2019, 11:45 pm EST

    Deepak,

    Thanks for your response. I figured it out and that's why I posted my ignore reply. By the way is there a way to speed up the chart display? I only have 8 sets of items, each has 27 data points, that I use to populate 8 charts and the code displays a noticeable delay whenever the charts are initially populated with the 27 sets and an even more noticeable, maybe a couple of seconds, when the charts are repopulated with with more data points.

    In my initial post I had also included an observation about seeing, when the application is being debugged, in the Visual Studio Output console display "1"s after the C1.WPF.SpreadSheet.C1Chart.4 and C1.WPF.SpreadSheet.C1Chart3D.4 loaded messages.

    Thanks,
    Luis Alvarez
  • Marked as Answer

    Replied 19 February 2019, 12:35 am EST

    Hi Luis,

    To improve the performance, you try suspending the events during load.
    C1.WPF.SpreadSheet.C1Chart.4 and C1.WPF.SpreadSheet.C1Chart3D.4 are the dlls used internally for gcSpreadsheet charts.

    Thanks,
    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels