Query |
Response | |
Given the following chart how do I display the actual value of each column like in image1?
Also on this example I am saying that the PrimaryValueAxis.MinorUnit = .5 yet it is displaying in increments of 1 am I doing this wrong?
//Company Wide Average
IWorksheet sheet19 = workbook.Worksheets[18];
sheet19.Range["A1"].Text = "Company wide average for each group";
sheet19.Range["A1"].CellStyle.Font.Bold = true;
sheet19.Range["A1"].CellStyle.Font.Size = 18;
AllGroupAverages allAvg = new AllGroupAverages();
allAvg.SurveyNumber = SurveyNumber;
allAvg.SortOn = 0;
IList<AllGroupAverages_Result> AllAverage = allAvg.GroupAverages();
sheet19.ImportData(AllAverage, 3, 1, true);
IChartShape chart19 = sheet19.Charts.Add();
chart19.ChartType = ExcelChartType.Column_Clustered;
chart19.DataRange = sheet19.Range["A3:B14"];
chart19.PrimaryValueAxis.MinimumValue = 0;
chart19.PrimaryValueAxis.MaximumValue = 5.5;
chart19.PrimaryValueAxis.MinorUnit = .5;
chart19.PrimaryValueAxis.Title = "Average Answer";
chart19.ChartTitle = "";
chart19.IsSeriesInRows = false;
chart19.Legend.Position = ExcelLegendPosition.Bottom;
chart19.Legend.Delete();
chart19.TopRow = 3;
chart19.BottomRow = 30;
chart19.LeftColumn = 1;
chart19.RightColumn = 15;
FillSeriesColor(chart19);
|
Major units are the spacing between the major gridlines on the axis and minor units are the spacing between the minor gridlines on the axis. So, we request you to set the value to major unit to achieve your requirement. Please refer the following code snippet to achieve this.
Code snippet:
| |
Next.
On the next two charts I want to display percentage values both on the axis and in each column as in image 2 how do I accomplish that?
// Rate Strongly Agree
IWorksheet sheet20 = workbook.Worksheets[19];
sheet20.Range["A1"].Text = "Rate for Strongly Agree";
sheet20.Range["A1"].CellStyle.Font.Bold = true;
sheet20.Range["A1"].CellStyle.Font.Size = 18;
AllParticipantsStronglyPercentages apsp = new AllParticipantsStronglyPercentages();
apsp.SurveyNumber = SurveyNumber;
apsp.AnswerNumber = "5"; //Strongly Agree
IList<AllParticipantsStronglyPercentages_Result> AllStronglyAgree = apsp.StronglyPercentages();
sheet20.ImportData(AllStronglyAgree, 3, 1, true);
IChartShape chart20 = sheet20.Charts.Add();
chart20.ChartType = ExcelChartType.Column_Clustered;
chart20.DataRange = sheet20.Range["A3:B15"];
chart20.PrimaryValueAxis.MinimumValue = 0;
chart20.PrimaryValueAxis.MaximumValue = 100;
chart20.PrimaryValueAxis.MinorUnit = 10;
chart20.PrimaryValueAxis.Title = "Percent Strongly Agree";
chart20.ChartTitle = "";
chart20.IsSeriesInRows = false;
chart20.Legend.Position = ExcelLegendPosition.Bottom;
chart20.Legend.Delete();
chart20.TopRow = 3;
chart20.BottomRow = 30;
chart20.LeftColumn = 1;
chart20.RightColumn = 15;
IChartSerie serie1 = chart20.Series[0];
serie1.SerieFormat.Fill.ForeColor = Color.Green;
There are some zero percentage values on the 3rd chart
Attachment: Big_Tex_Bank_46742989.zip |
You can achieve your requirement by workaround method in XlsIO. Please find the workaround method from below table.
Code snippet:
|