- Home
- Forum
- Xamarin.Forms
- Axis grid line offset issue
Axis grid line offset issue
Hello Syncfusion Support!
I am facing issues when I have two buttons and I can change different chart type by selecting each one of them.
My code:
[XAML]
<ContentPage.BindingContext>
<vm:TestChartVM/>
</ContentPage.BindingContext>
<StackLayout
BackgroundColor="White">
<StackLayout
Orientation="Horizontal"
HorizontalOptions="Center">
<Button
Text="Column"
Command="{Binding SelectColumnCommand}"/>
<Button
Text="Radar"
Command="{Binding SelectRadarCommand}"/>
</StackLayout>
<chart:SfChart
HeightRequest="400"
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
Series="{Binding SeriesCollection}" >
<chart:SfChart.Title>
<chart:ChartTitle
Text="My chart"/>
</chart:SfChart.Title>
<chart:SfChart.ChartBehaviors>
<chart:ChartZoomPanBehavior
ZoomMode="XY"/>
</chart:SfChart.ChartBehaviors>
<chart:SfChart.PrimaryAxis >
<chart:CategoryAxis />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis
RangePadding="Normal"/>
</chart:SfChart.SecondaryAxis>
</chart:SfChart>
</StackLayout>
[ViewModel]
private ChartSeriesCollection seriesCollection;
public ChartSeriesCollection SeriesCollection
{
get { return seriesCollection; }
set { SetValue(ref seriesCollection, value); }
}
public ObservableCollection<ChartDataPoint> DataSource { get; set; }
ColumnSeries columnSeries;
RadarSeries radarSeries;
public Command SelectColumnCommand { get; private set; }
public Command SelectRadarCommand { get; private set; }
public TestChartVM()
{
SeriesCollection = new ChartSeriesCollection();
DataSource = new ObservableCollection<ChartDataPoint>()
{
new ChartDataPoint("Jan", 10),
new ChartDataPoint("Feb", 30),
new ChartDataPoint("Mar", 50),
new ChartDataPoint("Apr", 40),
new ChartDataPoint("May", 15),
};
columnSeries = new ColumnSeries()
{
ItemsSource = DataSource,
XBindingPath = "XValue",
YBindingPath = "YValue"
};
radarSeries = new RadarSeries()
{
ItemsSource = DataSource,
XBindingPath = "XValue",
YBindingPath = "YValue"
};
SelectColumnCommand = new Command(() =>
{
SeriesCollection.Clear();
SeriesCollection.Add(columnSeries);
});
SelectRadarCommand = new Command(() =>
{
SeriesCollection.Clear();
SeriesCollection.Add(radarSeries);
});
}
Issues:
On iOS => When I select radar button first, and then back to column chart, after double tap chart to zoom in will always throw an exception "Specified cast is not valid".
On Android => Same actions, in column chart, axis grid line will offset to the bottom.
Please help me fix this out and sorry for my little English.
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
SM
Saravanan Madheswaran
Syncfusion Team
March 31, 2021 12:36 PM UTC
Hi Jon,
Greetings from Syncfusion.
Your query has been validated, and we would like to inform you that the SfChart area only supports combination series with the same category series. Since the column series was a type of XYDataSeries, the chart area could only accept other XYDataSeries, the radar series is a type of PoloarRadarSeries hence we face this issue.
So, we would suggest using different chart for each type of series.
Regards,
Saravanan.
Marked as answer
SIGN IN To post a reply.