I need to change GapWidth for one series in a combination chart. I have 7 Series (6 series type Line and 1 series type ColumnClustered) and I will like to change GapWidth for the series ColumnClustered, but not have this option. I try setting GapWidth and Overlap in the Chart, but not worked. Thanks.
Here's my code:
- Code: Select all
//insert chart
RectangleF rect = new RectangleF(convCM2Points(0.75f), convCM2Points(7f), this.ppt.SlideSize.Size.Width - (convCM2Points(0.75f)+10), convCM2Points(6.58f));
IChart chart = this.ppt.Slides[0].Shapes.AppendChart(Spire.Presentation.Charts.ChartType.Line, rect);
chart.Name = "chartPracas";
//add chart Title
chart.ChartTitle.TextProperties.Text = _titulo;
chart.ChartTitle.TextProperties.IsCentered = true;
chart.ChartTitle.Height = 30;
chart.HasTitle = false;
DataTable dtXLS = this.dsDados.Tables["tbFatos"];
int nroRec = InitChartData(chart, dtXLS);
chart.Series.SeriesLabel = chart.ChartData["B1", ((char)(64 + (dtXLS.Columns.Count - 4) + 1)).ToString() + "1"] ;
chart.Categories.CategoryLabels = chart.ChartData["A2", "A" + (nroRec + 1).ToString()];
// Criando as Series
int iSerie = 0;
var corSerie = Util.Emissora.ToColor();
var legendaSerie = Util.Emissora.ToLegenda();
List<EmissoraLegenda> lstEmissora = Util.Emissora;
chart.OverLap = 0;
chart.GapWidth = 15;
foreach (Spire.Presentation.Charts.CellRange sEmis in chart.Series.SeriesLabel)
{
string sLetra = ((char)(66 + iSerie)).ToString();
string sEmissora = sEmis.Text;
var posIni = ((char)(66 + iSerie)).ToString() + "2";
var posFim = ((char)(66 + iSerie)).ToString() + (nroRec + 1).ToString();
if (sEmis.Text.IndexOf("_") > -1)
sEmissora = sEmis.Text.Substring(0, sEmis.Text.IndexOf("_"));
var cor = lstEmissora.Find(x => x.Canal.ToLower().Contains(sEmissora.ToLower()) || x.Legenda.ToLower().Contains(sEmissora.ToLower())) != null ? lstEmissora.Find(x => x.Canal.ToLower().Contains(sEmissora.ToLower()) || x.Legenda.ToLower().Contains(sEmissora.ToLower())).Cor : new CorRGB();
chart.Series[iSerie].Values = chart.ChartData[posIni, posFim];
chart.Series[iSerie].Fill.FillType = FillFormatType.Solid;
chart.Series[iSerie].Fill.SolidColor.Color = (sEmissora.ToLower() != "shr" ? cor.FromArg : Color.FromArgb(150, 252,213,181));
chart.Series[iSerie].Line.FillType = FillFormatType.Solid;
chart.Series[iSerie].Line.FillFormat.SolidFillColor.Color = (sEmissora.ToLower() != "shr" ? cor.FromArg : Color.FromArgb(150, 252, 213, 181));
chart.Series[iSerie].Type = (sEmissora.ToLower() != "shr" ? ChartType.Line : ChartType.ColumnClustered);
chart.Series[iSerie].UseSecondAxis = (sEmissora.ToLower() == "shr");
chart.Series[iSerie].DataLabels.LabelValueVisible = true;
chart.Series[iSerie].DataLabels.NumberFormat = (sEmissora.ToLower() != "shr" ? "#" : "#\\%");
chart.Series[iSerie].DataLabels.Position = (sEmissora.ToLower() != "shr" ? ChartDataLabelPosition.Top : ChartDataLabelPosition.OutsideEnd);
chart.Series[iSerie].DataLabels.HasDataSource = false;
//set the font
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.LatinFont = new TextFont("Arial");
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.IsBold = (sEmissora.ToLower() != "shr" ? TriState.False : TriState.True);
//set the font size
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 9;
//set the font color
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = (sEmissora.ToLower() != "shr" ? cor.FromArg : Color.Orange);
chart.Series[iSerie].IsSmooth = TriState.True;
chart.Series[iSerie].Line.Width = 1.5f;
if (sEmissora.ToLower() == "globo")
{
chart.Series[iSerie].Line.Width = 2.5f;
chart.Series[iSerie].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.IsBold = TriState.True;
}
iSerie++;
}