Free Support Forum - aspose.com

Custom Chart Marker

Dear,


I have created a .pptx presentation using aspose.slide version 6.7.0.0 in which i added a “Scatter with only Marker” chart. I want to change the marker of one of the series to a custom shape (“Smiley Face” for example). I want my chart to look something similar to the attached picture. Could you please provide me with a code that allows me to do that?

Thank you in advance,
Sami Simon

Hi Sami Simon,


I have observed your requirement and like to share that with image shared it seems you are trying to set the custom symbol for your chart series marker. I like to share that in order to achieve this, you need to add a circle shape for series marker and fill it with smiley symbol. The following code snippet will serve the purpose in this regard for you. However, I have observe the issue while setting the image for marker symbol and an image with ID SLIDESJAVA-33617 have been created in our issue tracking system to resolve the issue. I also like to share that similar issue has been reported in Aspose.Slides for .NET as well so it will be resolved first in Aspose.Slides for .NET and will then be ported to Aspose.Slides for Java.


public static void setCustomMarker()throws Exception
{
PresentationEx pres = new PresentationEx();
SlideEx slide = pres.getSlides().get_Item(0);
ChartEx chart = slide.getShapes().addChart(ChartTypeEx.LineWithMarkers, 50, 50, 500, 400);

//working with chart series
ChartSeriesEx series = chart.getChartData().getSeries().getItem(0);


//Setting series marker and its properties for series
series.setMarkerSymbol(MarkerStyleTypeEx.Circle);
series.setMarkerSize((byte)20);
//Set the picture
//Creating a Buffered Image object to hold the image file
BufferedImage image=null;

try {
image = ImageIO.read(new File(“C:\Users\Public\Pictures\Sample Pictures\Desert.jpg”));
} catch (IOException e) {
}

ImageEx imgx = pres.getImages().addImage(image);

/// series.setMarkerSymbol(MarkerStyleTypeEx.Picture);
series.getMarkerFill().getFill().setFillType(FillTypeEx.Picture);
series.getMarkerFill().getFill().getPictureFillFormat().getPicture().setImage(imgx);

series.getMarkerFill().getLine().setWidth(2);
series.getMarkerFill().getLine().getFillFormat().setFillType(FillTypeEx.Solid);
series.getMarkerFill().getLine().getFillFormat().getSolidFillColor().setColor(java.awt.Color.RED);


//Saving Presentation
pres.write(“D:\Aspose Data\AxisValue.pptx”);
}

We are sorry for your inconvenience,

Dear,


Thank you for your reply. In fact I am using Aspose.Slide for .Net and not for Java. If you could provide me with a .Net code snippet that allow me to fulfill my request.

You also mentioned in your email the following line: I like to share that in order to achieve this, you need to add a circle shape for series marker and fill it with smiley symbol.

Could you please provide me with a code that allows me to do that.

Thanks you in advance
Sami SImon

Hi Sami Simon,


I am sorry for the inconvenience. The following code snippet in .NET will be used to serve the purpose. I have shared in my previous post that same issue is there in .NET as well and an issue with ID SLIDESNET-33819 has been created to resolve the issue. The following code snippet will be used once issue will be resolved. Secondly, in the following code, I have used Desert.jpg. You can use any image file with smiley face and set it accordingly to full fill your requirements.

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

//working with chart series
ChartSeriesEx series = chart.ChartData.Series[0];

//Setting series marker and its properties for series
series.MarkerSymbol = MarkerStyleTypeEx.Circle;
series.MarkerSize = 20;
//Set the picture
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(@“D:\Aspose Data<b>Desert.jpg”);
ImageEx image = pres.Images.AddImage(img);
series.MarkerFill.Fill.FillType = FillTypeEx.Picture;
series.MarkerFill.Fill.PictureFillFormat.Picture.Image = image;

series.MarkerFill.Line.Width = 2;
series.MarkerFill.Line.FillFormat.FillType = FillTypeEx.Solid;
series.MarkerFill.Line.FillFormat.SolidFillColor.Color = Color.Chocolate;

//Saving Presentation
pres.Write(“D:\Aspose Data\AxisValue.pptx”);

Please share, I may help you further in this regard.

Many Thanks,

Dear,


Any news regarding this request?

Thanks you in advance
Sami Simon

Hi Sami Simon,


I have observed the issue status from our issue tracking system and regret to share that the issue has not yet been resolved. However, I have requested our development team to kindly observe and schedule the issue. I will share the further information with you as soon as it will be shared by our development team.

Many Thanks,

Hi Sami Simon,


The issue shared by you has been scheduled for investigation during week 03/2013. We will share the notification with you as soon as the issue will be resolved.

Many Thanks,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Dear,


Thank you so much for the fix. The code you shared with me in the above message sets a custom picture for all points in the same series. This works great.

What I am trying to do now is to set a different picture for each point in the same series and not the same picture for all points. The code I am using looks something like this:

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

//working with chart series
ChartSeriesEx series = chart.ChartData.Series[0];

//Setting series marker and its properties for series
series.MarkerSymbol = MarkerStyleTypeEx.Circle;
series.MarkerSize = 20;

//Set the pictures
System.Drawing.Image imgBlue = (System.Drawing.Image)new Bitmap(@“c:<b>Blue.jpg”);
System.Drawing.Image imgGreen = (System.Drawing.Image)new Bitmap(@“c:</span>Green.jpg”);
ImageEx imageBlue = pres.Images.AddImage(imgBlue);
ImageEx imageGreen = pres.Images.AddImage(imgGreen);

//I need to set the picture per point and not per series
//series.MarkerFill.Fill.FillType = FillTypeEx.Picture;
//series.MarkerFill.Fill.PictureFillFormat.Picture.Image = image;

for (int i =0; i<4; i++)
{
if (i == 0 || i == 2)
{
//Set imageGreen for points 0 and 2
}
else
{
//Set imageBlue for points 1 and 3
}
}
pres.Write(“c:\CustomMarker.pptx”);

Could you please share with me a code snippet that allows me to set custom markers per series points.
I have attaches “Custom Markers.png” screenshot that shows (approximately) how I need to format the custom markers.

Thank you in advance,
Sami Simon

Hi Sami Simon,


Can you please share the sample presentation with us so that I may investigate the requirement on my end.

Many Thanks,

Dear Mudassir,


Kindly find attached “CustomMarker.pptx” presentation. It contains a “Line Chart” with custom markers. I have used two different marker pictures in the same series (green and blue). Is there any way to do that using ASPose?

Thank you in advance
Sami Simon

Dear Sami,


I have observed the requirements shared by you. You are actually looking for setting the chart series marker on individual series data point. At the moment, Aspose.Slides offers to add the makers on chart series level which is shared for all data points inside that particular series. I have created an issue with ID SLIDESNET-34083 as new feature request in our issue tracking system to further investigate and resolve the requirements shared. I have linked this thread with issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

The way you described can’t be used version 15.6.0.0. The only thing that comes close seems to be IChartSeries.Format.Fill.PictureFillFormat.Picture, which is read only. How do i set an shape or image as marker for a series in the afromentioned version?

Hi Frieder,

I have worked over the shared requirements using Aspose.Slides for .NET 15.6.0 on my end. Please try using the following sample code to set the image symbol for different data points inside the same series. I hope this will be helpful. Please share, if I may help you further in this regard.

public static void TestChartSymbol()
{
Presentation pres = new Presentation();

ISlide slide = pres.Slides[0];

//Creating the default chart
IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 0, 0, 400, 400);

//Getting the default chart data worksheet index
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

//Delete demo series
chart.ChartData.Series.Clear();

//Add new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, “Series 1”), chart.Type);

String imagePath = @“C:\Users\Public\Pictures\Sample Pictures”;
//Set the picture
System.Drawing.Image img = (System.Drawing.Image)new Bitmap(imagePath + “Desert.jpg”);
IPPImage imgx1 = pres.Images.AddImage(img);

//Set the picture
System.Drawing.Image img2 = (System.Drawing.Image)new Bitmap(imagePath + “Tulips.jpg”);
IPPImage imgx2 = pres.Images.AddImage(img2);

//Take first chart series
IChartSeries series = chart.ChartData.Series[0];

//Add new point (1:3) there.
IChartDataPoint point= series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, (double)4.5));
point.Marker.Format.Fill.FillType = FillType.Picture;
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;

point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, (double)2.5));
point.Marker.Format.Fill.FillType = FillType.Picture;
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;


point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, (double)3.5));
point.Marker.Format.Fill.FillType = FillType.Picture;
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;


point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, (double)4.5));
point.Marker.Format.Fill.FillType = FillType.Picture;
point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;


//Changing the chart series marker
series.Marker.Size = 15;

pres.Save(“D:\Aspose Data\AsposeScatterChart.pptx”, SaveFormat.Pptx);
}

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-34083) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz