Xamarin Forms Create Horizontal Bar Graphs UltimateXF

  • by
Xamarin forms Horizontal Bar graphs - UltimateXF

Hi Friends,

In this post we will see how we can create horizontal bar graphs using Ultimate XF library. UltimateXF is a library for creating different graphs, charts and pie charts in Xamarin forms. It is available on Github and also you can add nuget package in your Xamarin form application.

Add Nuget package to your project:

Install-Package UltimateXF -Version 2.3.2

In your Project create a new Content page with name HorizontalBarchart.xaml and edit it as below:


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
Title="Horizontal Bar Chart"
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand"
<Label Text="Line Chart in Xamarin Form"
VerticalOptions="Start" />

<Button Margin="5" Text="Load" HorizontalOptions="Start"
VerticalOptions="Start" x:Name="btnLoad" Clicked="BtnLoad_Clicked"/>
<ultimateChart:SupportHorizontalBarChartExtended x:Name="chart"
DrawBorders="false" Legend="true"
DoubleTapToZoomEnabled="false" />

This form contains the Horizontal Barchart from UltimateXF library and a button to load the same.

Edit the code file as below:


using System;
using System.Collections.Generic;
using UltimateXF.Widget.Charts.Models;
using UltimateXF.Widget.Charts.Models.BarChart;
using UltimateXF.Widget.Charts.Models.Formatters;
using UltimateXF.Widget.Charts.Models.Legend;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace XamarinGraphsPieCharts
public partial class HorizontalBarchart : ContentPage
String[] products = new string[] {"Mobiles","Tablets","Earphones","Headphones","Speakers",
"USB Cables","Laptops","Backcase","Screencover" };

public HorizontalBarchart ()
InitializeComponent ();

private void BtnLoad_Clicked(object sender, EventArgs e)

public void LoadChart()
var entries = new List<EntryChart>();
var labels = new List<string>();
var legendsXF = new List<LegendXF>();

Random random = new Random();
for (int i = 0; i < 8; i++)
entries.Add(new EntryChart(i, random.Next(20)));
// legendsXF.Add(new LegendXF());

var dataSet4 = new BarDataSet(entries, "Products Summary")
Colors = new List<Color>(){
Color.FromHex("#3696e0"), Color.FromHex("#9958bc"),
Color.FromHex("#35ad54"), Color.FromHex("#2d3e52"),
Color.FromHex("#e55137"), Color.FromHex("#ea9940"),

var data4 = new BarChartData(new List<IBarDataSet>() { dataSet4 });

chart.ChartData = data4;
chart.DescriptionChart.Text = "Test label chart description";

chart.AxisLeft.DrawGridLines = false;
chart.AxisLeft.DrawAxisLine = true;
chart.AxisLeft.Enabled = true;

chart.AxisRight.DrawAxisLine = false;
chart.AxisRight.DrawGridLines = false;
chart.AxisRight.Enabled = false;

chart.XAxis.XAXISPosition = XAXISPosition.BOTTOM;
chart.XAxis.DrawGridLines = false;
chart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);

catch(Exception ex)


Now run the app by setting the start page as our graph page in App.xaml.cs file

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace XamarinGraphsPieCharts
public partial class App : Application
public App()
MainPage = new NavigationPage(new HorizontalBarchart());

Final screen:

Xamarin forms Horizontal Bar graphs - UltimateXF

Xamarin forms Horizontal Bar graphs – UltimateXF

Also see:
Xamarin Forms – How to create CandleStick Charts using UltimateXF

How to create Pie charts in Xamarin forms?

How to create Bar charts in Xamarin forms?

How to create Line charts in Xamarin forms? 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.