Hi,
We are using Xamarin forms controls of telerik UI for Xamarin.
Bar series in Charts is not rendering it's bars in iOS. This is a case where I first bind chart to a collection with Zero Values(for Numberic Axis) and change data of values to Non-Zero values, then it does not redraw Bars but it shows labels (data points) with updated numbers/values.
In other case, i.e., bind chart to collection with Non-zero values first then change to zero values, works fine.
I am able to reproduce this with your samples (SDKBrowser). Is there any way to force redraw bars??
Thanks,
Ram prasad
10 Answers, 1 is accepted
Thank you for contacting us.
Indeed there is an issue where chart axis is not updated when the data has changed. I have logged it in our feedback portal where you can track its status. I have also added points to your account as a token of gratitude for bringing this issue to our attention.
As a workaround, you can reset the chart axis to force the chart to update its data.
chart.Series[0].ItemsSource = GetCategoricalData();
chart.VerticalAxis =
new
NumericalAxis();
Please, let us know if you have further questions.
Regards,
Rosy Topchiyska
Telerik by Progress
Hello,
The above solution does not seem to work. Is there any fix or update on this issue?
Thanks,
Ram prasad
Please, use the following approach -- clear the series source explicitly before assigning the new one:
chart.Series[0].ItemsSource =
null
;
chart.Series[0].ItemsSource = GetCategoricalData();
chart.VerticalAxis =
new
NumericalAxis();
In addition, please make sure you use the latest release -- version 2017.2.626.
Best regards,
Ves
Progress Telerik
Hi Ves,
How would resetting the source work if the ItemSource is bound to an observable collection in Xaml?
Thanks
You can set the binding programmatically as you would normally do in any XAML framework, using the DependencyProperty in the SetBinding method. In Xamarin.Forms, the SetBinding method is used as well, see the Xamarin.Forms documentation here.
The LineSeries object, inherits from ChartSeries (see the class hierarchy here). ChartSeries has a property named ItemsSource (the DependencyProperty is named ItemsSourceProperty).
Thus, you can use the following SetBinding implementation:
// In XAML <telerikChart:LineSeries x:Name="MyLineSeries"
// ItemsSource = "{Binding DataItems}" >
// In C#
MyLineSeries.SetBinding(ChartSeries.ItemsSourceProperty,
new
Binding(
"DataItems"
));
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Hi,
I have the same issue, I am unable to show Bar graphs according to my Data from server.
I am adding the data to observable collection after server call in viewmodel, But the bar graphs are not drawing.
I am using the latest dll.
let me know how to update the bars according to the data after server call.
Thank you,
See Rosy's or Ves's reply above, this is what you'll currently need to do in order to re-draw the series after an items update.
We are aware of the issue and are working on a fix that will be in an upcoming release. This is a high priority item and you can track the status of the issue here in our feedback portal.
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Hello,
I have the same problem but with the line chart and Android. If I change the ItemSource the chart is not updated. I'm using version 2017.3.1018.240. According to the feedback portal this bug should be fixed but it's still not working. Or am I missing something?
Kind regards,
Felix
I've asked for clarification from the dev team on exactly what the fix entailed. However, I can confirm that if you replace the collection, instead of using Clear() and Add() methods, it will now redraw the series.
Here is the example code from my attached demo:
<
telerikChart:RadCartesianChart
x:Name
=
"chart"
>
<
telerikChart:RadCartesianChart.HorizontalAxis
>
<
telerikChart:CategoricalAxis
/>
</
telerikChart:RadCartesianChart.HorizontalAxis
>
<
telerikChart:RadCartesianChart.VerticalAxis
>
<
telerikChart:NumericalAxis
/>
</
telerikChart:RadCartesianChart.VerticalAxis
>
<
telerikChart:RadCartesianChart.Series
>
<
telerikChart:BarSeries
ItemsSource
=
"{Binding Data}"
CategoryBinding
=
"Category"
ValueBinding
=
"Value"
/>
</
telerikChart:RadCartesianChart.Series
>
</
telerikChart:RadCartesianChart
>
View model collection the series is bound to:
private
ObservableCollection<CategoricalData> data;
public
ObservableCollection<CategoricalData> Data
{
get
{
return
data; }
set
{ data = value; OnPropertyChanged();}
}
View model method that updates the Data collection:
private
void
GenerateData()
{
var items =
new
ObservableCollection<CategoricalData>();
for
(
int
i = 0; i < 5; i++)
{
items.Add(
new
CategoricalData
{
Category = $
"Item {i}"
,
Value = random.NextDouble()
});
}
Data = items;
}
If you have any implementation specific questions, please open a support ticket here (you have a valid support license during your trial). We'll be able to follow up with you directly and continue the conversation there.
Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Hello Lance,
thanks for your answer. I found the answer of my
problem. The problem was that I set the binding context inside the chart
like in the line chart example of your documentation.
<
telerikChart:RadCartesianChart
x:Name
=
"Chart"
>
<
telerikChart:RadCartesianChart.BindingContext
>
<
viewModels:ViewModel
/>
</
telerikChart:RadCartesianChart.BindingContext
>
</
telerikChart:RadCartesianChart
>
If I comment the binding context everthing works fine. Unfortunatly I don't know why this is a problem, because I'm quite new in the Xamarin Forms space.