public void add_chart(ref List<question> questions, ref int question_no, ref int choices_no1,ref ColorDialog colordialog1, ref int data_format, ref Color[] bar_colors, ref FontDialog fontdialog1) { if (questions[question_no].show_chart == true) { objChart = objSlide.Shapes[2].OLEFormat.Object; Graph.SeriesCollection ss = objChart.SeriesCollection(); Graph.Points kj; kj = ss.Item(1).Points(); Graph.Axes kk; kk = objChart.Axes(); questions[question_no].datasheet = objChart.Application.DataSheet; /* datasheet.Cells[1, 3] = "ali"; datasheet.Cells[1, 4] = "ali"; datasheet.Cells[1, 5] = "ali"; datasheet.Cells[2, 4] = kk.Count; */ objChart.ApplyDataLabels(); for (int i = 2; i <= choices_no1 + 1; i++) { questions[question_no].datasheet.Cells[1, i] = i - 1; // kj.Item(i - 1).Interior.Color = } float total = 0; for (int i = 2; i <= choices_no1 + 1; i++) { total = (total + questions[question_no].values[i - 2]); } if (data_format == 2) { for (int i = 2; i <= choices_no1 + 1; i++) { Graph.DataLabel label = ss.Item(1).DataLabels(i - 1); questions[question_no].datasheet.Cells[2, i] = questions[question_no].values[i - 2]; kj.Item(i - 1).Interior.Color = bar_colors[i - 2]; } objShape2 = objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 435, 480, 120, 70); objShape2.TextEffect.Text = "Total" + " " + total.ToString(); objShape2.TextEffect.FontName = "Comic Sans MS"; objShape2.TextEffect.FontSize = 15; objShape2.TextEffect.FontBold = MsoTriState.msoTrue; } else if (data_format == 1) { for (int i = 2; i <= choices_no1 + 1; i++) { Graph.DataLabel label = ss.Item(1).DataLabels(i - 1); questions[question_no].datasheet.Cells[2, i] = (((questions[question_no].values[i - 2]) / total) * 100) + "%"; kj.Item(i - 1).Interior.Color = bar_colors[i - 2]; } } else if (data_format == 3) { for (int i = 2; i <= choices_no1 + 1; i++) { questions[question_no].datasheet.Cells[2, i] = questions[question_no].values[i - 2]; Graph.DataLabel label = ss.Item(1).DataLabels(i - 1); label.Text = (((questions[question_no].values[i - 2]) / total) * 100).ToString("F") + "%" + "[" + questions[question_no].values[i - 2].ToString() + "]"; kj.Item(i - 1).Interior.Color = bar_colors[i - 2]; label.Font.Size = 15; } objShape2 = objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 435, 480, 120, 70); objShape2.TextEffect.Text = "Total" + " " + total.ToString(); objShape2.TextEffect.FontName = "Comic Sans MS"; objShape2.TextEffect.FontSize = 15; objShape2.TextEffect.FontBold = MsoTriState.msoTrue; } objChart.Refresh(); objChart.Application.Update(); } }