Articles in this section
Category / Section

How to create a Tornado Chart in Xamarin.Forms

1 min read

This article explains how to create a tornado chart in Xamarin.Forms by using the existing chart types in Xamarin.Forms Charts.

 

The tornado chart is a special type of bar chart. In tornado chart, the bars can be extended from the defined baseline, which is also used to compare the data among different types of data or categories, the bars in the tornado chart are horizontal and this chart is basically used to show the impact such as how a condition will impact the result on the outcome.

 

You can achieve the tornado chart using the bar charts as shown in the following code sample.

 

[XAML]

<!--Set SideBySideSeriesPlacement as false to avoid segments arranged in side by side-->
<chart:SfChart x:Name="chart" SideBySideSeriesPlacement="False">
          <chart:SfChart.PrimaryAxis>
                    <chart:CategoryAxis LabelPlacement="BetweenTicks"/>
          </chart:SfChart.PrimaryAxis>
          <chart:SfChart.SecondaryAxis>
                    <chart:NumericalAxis LabelCreated="SecondaryAxis_LabelCreated"/>
          </chart:SfChart.SecondaryAxis>
          <chart:BarSeries  XBindingPath="Year" YBindingPath="Export" Color="Aqua" 
                                  ItemsSource="{Binding Models}" />
          <chart:BarSeries  XBindingPath="Year" YBindingPath="Import" Color="Pink" 
                                  ItemsSource="{Binding Models}" />
</chart:SfChart>

 

[C#]

void SecondaryAxis_LabelCreated (object sender, ChartAxisLabelEventArgs e)
{
       // Changes the negative values into absolute value.
       double label = Math.Abs (Convert.ToDouble(e.LabelContent));
       e.LabelContent = label.ToString ();
}

Output

Tornado Chart in Xamarin.Forms

 

 

View the sample in GitHub.

 

See also

What are the different types of axis in Charts

How to add multiple series in Xamarin.Forms Chart

How to show the provided information of the data points to user

How to add the annotations in Xamarin.Forms Chart

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied