How can we implement horizontal bar graphs using aspose charts?Is there any property available?
Thanks for your query.
See the documents in the section on how to create, manipulate, customize and render charts for your reference (you got to choose your desired Bar graph type from available Bar charts types (list)):
Also, see the sample code on how to create a simple Bar cart for your reference:
e.g
Sample code:
//Create a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Set the name of worksheet
sheet.Name = "Data";
//Get the cells collection in the sheet.
Cells cells = workbook.Worksheets[0].Cells;
//Put some values into a cells of the Data sheet.
cells["A1"].PutValue("Region");
cells["A2"].PutValue("A");
cells["A3"].PutValue("B");
cells["A4"].PutValue("C");
cells["A5"].PutValue("D");
cells["A6"].PutValue("E");
cells["A7"].PutValue("F");
cells["A8"].PutValue("G");
cells["B1"].PutValue("Sale");
cells["B2"].PutValue(70000);
cells["B3"].PutValue(55000);
cells["B4"].PutValue(30000);
cells["B5"].PutValue(40000);
cells["B6"].PutValue(35000);
cells["B7"].PutValue(32000);
cells["B8"].PutValue(10000);
//Add a chart sheet.
int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
sheet = workbook.Worksheets[sheetIndex];
//Set the name of worksheet
sheet.Name = "Chart";
//Create chart
int chartIndex = 0;
chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Bar, 1, 1, 25, 10);
Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];
//Set properties of chart title
chart.Title.Text = "Sales By Region";
chart.Title.TextFont.Color = Color.Blue;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;
//Set properties of nseries
chart.NSeries.Add("Data!B2:B8", true);
chart.NSeries.CategoryData = "Data!A2:A8";
chart.NSeries.IsColorVaried = true;
//Set the DataLabels in the chart
Aspose.Cells.Charts.DataLabels datalabels;
for (int i = 0; i < chart.NSeries.Count; i++)
{
datalabels = chart.NSeries[i].DataLabels;
}
//Save the excel file
workbook.Save("e:\\test2\\outbarchart1.xlsx");
Hope, this helps a bit.
Thank You.Actually I was trying column graph.
You got it right now. If you need to render horizontal bars, kindly use Bar chart type(s) for your needs.
Have a good day!