Default Markers in LineWithMarkers chart

Hello,

Using the following code (sample) I create a LineWithMarkers…

PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];
ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.LineWithMarkers, 10, 10, 400, 400);

chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[0];

chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C1”));
series.Values.Add(fact.GetCell(0, 1, 1, 24));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C2”));
series.Values.Add(fact.GetCell(0, 2, 1, 23));
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “C3”));
series.Values.Add(fact.GetCell(0, 3, 1, -10));
chart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, “C4”));
series.Values.Add(fact.GetCell(0, 4, 1, null));

chart.ChartData.Series.Add(fact.GetCell(0, 0, 2, “Series 2”), chart.Type);
//Take second chart series
ChartSeriesEx series2 = chart.ChartData.Series[1];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, 2, 30));
series2.Values.Add(fact.GetCell(0, 2, 2, 10));
series2.Values.Add(fact.GetCell(0, 3, 2, 60));
series2.Values.Add(fact.GetCell(0, 4, 2, 40));

chart.HasLegend = true;
chart.Legend.Overlay = false;

pres.Write(@“C:\PKCS\PKCS_Online\PKCS_Online\Results\TESTS.pptx”);

Is there a way to have automatic markers ? (I know how to change the symbol of each serie but don’t want to do it)

Powerpoint does it when you create a new chart… (as illustrated in the joined document)

Cdlt,
Bertrand.

Hi Cdlt,

I have worked with the sample code shared by you and have observed the requirement shared. Actually, Aspose.Slides sets square as default symbol for every series. I have created an issue with ID SLIDESNET-34685 as new feature request to further investigate the possibility of implementing the requested feature support as available in PowerPoint. This thread has been linked with the issue so that you may be automatically notified once the feature support will be available.

Many Thanks,

Thank You Mussadir.

Hi Mussadir,

As a workaround, waiting for resolution, I decided to attribute myself the markers using the following code :

// TODO ==> Remove when bug will be corrected by aspose
switch (i)
{
case 1:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Circle;
break;
case 2:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Square;
break;
case 3:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Diamond;
break;
case 4:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Triangle;
break;
case 5:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Plus;
break;
case 6:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Dash;
break;
case 7:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Dot;
break;
case 8:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Star;
break;
case 9:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.X;
break;
default:
series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Circle;
break;
}


This works… but not all MarkerStyleTypeEx are rendered!
The reason seems to be that the symbols are not in the PPTX file when chart is generated by aspose :

But they are all there when the chart is inserted manually in PowerPoint :


Best Regards,
Bertrand.

Hi Betrand,

I have observed the sample code shared by you and tried setting all marker symbols as shared by you. It worked on my end and I have been able to set all of them. Can you please share which symbol is not being applied so that I may add ticket for this.

public static void AddChartWithMarker()
{
PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];
ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.LineWithMarkers, 10, 10, 400, 400);

chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[0];
///
SetMarker( series, 1);

int i = 1;
///
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C1”));
series.Values.Add(fact.GetCell(0, 1, 1, 24));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C2”));
series.Values.Add(fact.GetCell(0, 2, 1, 23));
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “C3”));
series.Values.Add(fact.GetCell(0, 3, 1, -10));
chart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, “C4”));
series.Values.Add(fact.GetCell(0, 4, 1, null));

chart.ChartData.Series.Add(fact.GetCell(0, 0, 2, “Series 2”), chart.Type);
//Take second chart series
ChartSeriesEx series2 = chart.ChartData.Series[1];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, 2, 30));
series2.Values.Add(fact.GetCell(0, 2, 2, 10));
series2.Values.Add(fact.GetCell(0, 3, 2, 60));
series2.Values.Add(fact.GetCell(0, 4, 2, 40));

SetMarker(series2, 2);

i = 3;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 3”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[2];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 40));
series2.Values.Add(fact.GetCell(0, 2, i, 20));
series2.Values.Add(fact.GetCell(0, 3, i, 50));
series2.Values.Add(fact.GetCell(0, 4, i, 20));

SetMarker(series2, i);

i = 4;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 4”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[3];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 34));
series2.Values.Add(fact.GetCell(0, 2, i, 41));
series2.Values.Add(fact.GetCell(0, 3, i, 56));
series2.Values.Add(fact.GetCell(0, 4, i, 10));

SetMarker(series2, i);

i = 5;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 5”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[4];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 3));
series2.Values.Add(fact.GetCell(0, 2, i, 1));
series2.Values.Add(fact.GetCell(0, 3, i, 6));
series2.Values.Add(fact.GetCell(0, 4, i, 4));

SetMarker(series2, i);


i = 6;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 6”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[5];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 20));
series2.Values.Add(fact.GetCell(0, 2, i, 15));
series2.Values.Add(fact.GetCell(0, 3, i, 26));
series2.Values.Add(fact.GetCell(0, 4, i, 14));

SetMarker(series2, i);

i = 7;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 7”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[6];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 40));
series2.Values.Add(fact.GetCell(0, 2, i, 20));
series2.Values.Add(fact.GetCell(0, 3, i, 60));
series2.Values.Add(fact.GetCell(0, 4, i, 10));

SetMarker(series2, i);

i = 8;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 8”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[7];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 23));
series2.Values.Add(fact.GetCell(0, 2, i, 17));
series2.Values.Add(fact.GetCell(0, 3, i, 46));
series2.Values.Add(fact.GetCell(0, 4, i, 56));

SetMarker(series2, i);

i=9;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 9”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[8];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 45));
series2.Values.Add(fact.GetCell(0, 2, i, -56));
series2.Values.Add(fact.GetCell(0, 3, i, 23));
series2.Values.Add(fact.GetCell(0, 4, i, -30));

SetMarker(series2, i);

i=10;
chart.ChartData.Series.Add(fact.GetCell(0, 0, i, “Series 10”), chart.Type);
//Take second chart series
series2 = chart.ChartData.Series[9];

//Now populating series data
series2.Values.Add(fact.GetCell(0, 1, i, 130));
series2.Values.Add(fact.GetCell(0, 2, i, 50));
series2.Values.Add(fact.GetCell(0, 3, i, 160));
series2.Values.Add(fact.GetCell(0, 4, i, 140));

SetMarker(series2,i );


pres.Write(@“D:\Aspose Data\TESTS.pptx”);



}
public static void SetMarker(ChartSeriesEx series, int i)
{
// TODO ==> Remove when bug will be corrected by aspose
switch (i)
{
case 1:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Circle;
series.MarkerSymbol = MarkerStyleTypeEx.Circle;
break;
case 2:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Square;
series.MarkerSymbol = MarkerStyleTypeEx.Square;
break;
case 3:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Diamond;
series.MarkerSymbol = MarkerStyleTypeEx.Diamond;
break;
case 4:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Triangle;
series.MarkerSymbol = MarkerStyleTypeEx.Triangle;
break;
case 5:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Plus;
series.MarkerSymbol = MarkerStyleTypeEx.Plus;
break;
case 6:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Dash;
series.MarkerSymbol = MarkerStyleTypeEx.Dash;
break;
case 7:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Dot;
series.MarkerSymbol = MarkerStyleTypeEx.Dot;
break;
case 8:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Star;
series.MarkerSymbol = MarkerStyleTypeEx.Star;
break;
case 9:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.X;
series.MarkerSymbol = MarkerStyleTypeEx.X;
break;
default:
// series[i - 1].MarkerSymbol = MarkerStyleTypeEx.Circle;
series.MarkerSymbol = MarkerStyleTypeEx.Circle;
break;
}
}


The sample code used and generated presentation are attached for your kind reference.

Many Thanks,

Hi Mussadir!

I can confirm that using your code, it works for all the symbols.

Mine is not as direct and simple as this one… I’ll try and take time to debug…

Thank You.

Hi Betrand,


You may please try the sample code on your end and share with us if there is any incurring issue on your end. I will try my best to help you further.

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-34685) have been fixed in this update.