No update controls RadchartBar when update property with bindable of the control

1 Answer 82 Views
Chart
Sergio
Top achievements
Rank 1
Iron
Sergio asked on 02 Sep 2022, 09:07 PM

I have vm with property observablecollection, then xaml this

 

 <telerik:RadCartesianChart x:Name="chart" Grid.Row="0" Grid.ColumnSpan="2" BackgroundColor="{StaticResource  DarkBg1}">

  <telerik:RadCartesianChart.VerticalAxis  >
      <telerik:CategoricalAxis  LabelTextColor="White"  LineColor="White" ShowLabels="True" LabelFontSize="10"/>
  </telerik:RadCartesianChart.VerticalAxis>
  <telerik:RadCartesianChart.HorizontalAxis>
      <telerik:NumericalAxis LabelTextColor="White" LineColor="White" ShowLabels="True" LabelFontSize="10">
                    </telerik:NumericalAxis>
  </telerik:RadCartesianChart.HorizontalAxis>
  <telerik:RadCartesianChart.Series >
      <telerik:BarSeries ValueBinding="MontoVentaTiendaDia" 
                         ShowLabels="True"
                         LabelFormat="{}{0:N2}"
                              CategoryBinding="NombreTienda"
                              ItemsSource="{Binding Ventas}"  >

                    </telerik:BarSeries>
  </telerik:RadCartesianChart.Series>
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartTooltipBehavior  TriggerMode="Tap" >

                         </telerik:ChartTooltipBehavior>

            </telerik:RadCartesianChart.Behaviors>
        <telerik:RadCartesianChart.Palette>
        <telerik:ChartPalette>
            <telerik:ChartPalette.Entries>
                <telerik:PaletteEntry FillColor="#345EA8" StrokeColor="#345EA8" />               
            </telerik:ChartPalette.Entries>
        </telerik:ChartPalette>
    </telerik:RadCartesianChart.Palette>


</telerik:RadCartesianChart>

 

But when change de observablecollection don't change chart, what i'm have to do?

Thanks

 

 

                

1 Answer, 1 is accepted

Sort by
0
Accepted
Antoan
Telerik team
answered on 07 Sep 2022, 11:29 AM

Hello Sergio,

Thank you for the provided code snippet.

The issue you are experiencing comes from the sorting of the collection and not the XAML. I have attached a sample project so you can try the code I've used in your solution.

If you are still experiencing issues with the sort afterwards please modify the sample app as close to resembling your case so that we may provide a better solution

Regards,
Antoan
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Sergio
Top achievements
Rank 1
Iron
commented on 07 Sep 2022, 03:04 PM

Hello Antoan,

Thanks for your anwer!! but I need what the property add new values the chart refresh and this moment don't refresh of the chart. And the property is observablecollection and my app work in MVVM

You can help me

Sergio
Top achievements
Rank 1
Iron
commented on 07 Sep 2022, 07:05 PM

Hello, I made changes to my code as you indicated, updating the itemsource property through the event and it works, it would be nice to work with the xaml binding

Antoan
Telerik team
commented on 12 Sep 2022, 12:03 PM

Hello Sergio,

I am glad to hear the provided information helped you. Regarding the MVVM usage I have made some changes to the app so it works with MVVM and Bindings. The app adds 2 new chart bars in run time using a Dispatcher which will be rendered 2 seconds after the launch of the application.

I hope the sample helps you achieve your scenario.

Regards,
Antoan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Chart
Asked by
Sergio
Top achievements
Rank 1
Iron
Answers by
Antoan
Telerik team
Share this question
or