I need to reverse the order of y and x axis in the chart

Hi,


I am facing problem in reversing the y axis and x axis in the chart. I am using aspose.cells dll in which i am first inserting the values in data sheet that is 0th index sheet in which data is inserted and on the basis of that i am creating the graph. First i m looping through the column headings and than looping to rows values.
For example is i have these option in y axis like this
1) Sales and marketing
2) Services
3) Logistics

I need to show this as
1) logistics
2) Services
3) Sales and Marketing

Specific to bar chart and column chart

Thanks,
Varun

Hi,


Thanks for providing us some details.

Please provide your sample code (runnable) with template files (input (if any) and output by Aspose.Cells APIs). Also provide your expected file that contains your desired chart, you may create your desired chart manually in MS Excel. We will check and help you on how to do it via Aspose.Cells APIs.

By the way, we recommend you to kindly browse the documents/articles in the section for your reference:


Thank you.

// Loop for the creating table columns in excel and assigning the values in cells
for (i = 0; i <= widget.Views[viewIndex].Data.Table.ColumnHeadings.Count - 1; i++)
{
cells[0, i].PutValue(widget.Views[viewIndex].Data.Table.ColumnHeadings[i]);
Style style = cells[0, i].GetStyle();
style.Font.IsBold = true;
//style.BackgroundColor = Color.Gray;
cells[0, i].SetStyle(CreateBorderForTable(style));
}

int j = 0;
int z = 0;
// Loop for the creating table rows in excel and assigning the values in cells
for (i = 1; i <= widget.Views[viewIndex].Data.Table.Rows.Count; i++)
{
for (j = 0; j <= widget.Views[viewIndex].Data.Table.ColumnHeadings.Count - 1; j++)
{
string[] result = widget.Views[viewIndex].Data.Table.Rows[z];
if (j == 0)
{
if (result[j] != null && result[j] != "null")
{
checkCellValue = result[j];
if (checkCellValue.Contains("%"))
{
string cellValue = checkCellValue.Replace("%", "");
decimal temp = 0m;
if (decimal.TryParse(cellValue, out temp))
{
cells[i, j].PutValue((Convert.ToDecimal(cellValue)) / 100);
Style st = cells[i, j].GetStyle();
if (widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatPercentiles || widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatPercentile)
{
st.Number = 10;
}
else if (widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatDecimal)
{
st.Number = 2;
}
else
{

}

cells[i, j].SetStyle(CreateBorderForTable(st));
}
else
{
cells[i, j].PutValue(checkCellValue);
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
}
else
{
DateTime dDate;

if (DateTime.TryParse(checkCellValue, out dDate))
{
String.Format("{0:d/MM/yyyy}", dDate);
// change the string in to date format
string[] dateArray = checkCellValue.Split('/');
DateTime dt = new DateTime(Convert.ToInt16(dateArray[2]), Convert.ToInt16(dateArray[1]), Convert.ToInt16(dateArray[0]));
string date = String.Format("{0:y}", dt);
// again changing the date to liek March,2010 format
cells[i, j].PutValue(date);
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
else
{
cells[i, j].PutValue(result[j]);
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
}
}
else
{
cells[i, j].PutValue(0.0);
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
}
else
{

if (result[j] != null && result[j] != "null")
{
if (result[j].Contains("%"))
{
string cellValue = result[j].Replace("%", "");
cells[i, j].PutValue((Convert.ToDecimal(cellValue)) / 100);
Style st = cells[i, j].GetStyle();
if (widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatPercentiles || widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatPercentile)
{
st.Number = 10;
}
else if (widget.Views[viewIndex].Data.ValueFormat == ChartTypeValueFormatDecimal)
{
st.Number = 2;
}
else
{

}
cells[i, j].SetStyle(CreateBorderForTable(st));
}
else
{
cells[i, j].PutValue(Convert.ToDecimal(result[j]));
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
}
else
{
cells[i, j].PutValue(0.0);
Style st = cells[i, j].GetStyle();
cells[i, j].SetStyle(CreateBorderForTable(st));
}
}
}
z++;
}

rowIndex = widget.Views[viewIndex].Data.Table.Rows.Count + 1;

string cellname = CellsHelper.CellIndexToName(widget.Views[viewIndex].Data.Table.Rows.Count, widget.Views[viewIndex].Data.Table.ColumnHeadings.Count - 1);
chart.NSeries.Add("Data!B2:" + cellname, true);
chart.NSeries.CategoryData = "Data!A2:A" + rowIndex.ToString();
chart.NSeries.IsColorVaried = false;

Hi,


Thanks for sharing your code segment.

I am afraid, your code segment is not much helpful as I am not sure about the underlying data and objects to generate your desired chart. We appreciate if you could create a separate console application (you may even use a template file (input file) to place your source data into the cells), zip it and post us here, we will check it soon. Moreover, please also attach your output Excel file by Aspose.Cells and your expected output Excel file that you could create in MS Excel manually.

Thank you.

Sorry due to security in office i am not able to upload the xls and screen shot. Bu i have attached screen shot in my first reply. Please let me know how i can achieve that.




Thanks
Varun

I tried these properties. but not able to do


// chart.ValueAxis.IsPlotOrderReversed = true;
// chart.ValueAxis.CrossType = CrossType.Maximum;

could you please let me know

Hi,


I am afraid, we need at least your expected output Excel file which contains your desired chart, you may create it in MS Excel manually and provide us here. If you have security concerns, you may create your desired chart with dummy data in MS Excel manually, so we could evaluate your issue and help you through.

Thank you.