How to Change Series Color for the ScatterWithSmoothLinesAndMarkers?

Point2D.Double[] usData = {
        new Point2D.Double(-54.1, 0.8),
        new Point2D.Double(-57.9, 4.7),
        new Point2D.Double(-54.5, 4.3),
        new Point2D.Double(-55.5, 1.9)
};

Point2D.Double[] caData = {
        new Point2D.Double(-37.0, -1.6),
        new Point2D.Double(-30.6, 4.7),
        new Point2D.Double(-38.1, 4.3),
        new Point2D.Double(-31.7, 7.3)
};

Point2D.Double[] euData = {
        new Point2D.Double(-73.2, 0.8),
        new Point2D.Double(-71.9, 6.6),
        new Point2D.Double(-69.1, 5.5),
        new Point2D.Double(-73.9, 3.0)
};

Presentation presentation = new Presentation();
presentation.getSlideSize().setSize(SlideSizeType.Widescreen, SlideSizeScaleType.DoNotScale);
ISlide slide = presentation.getSlides().get_Item(0);

IChart chart = slide.getShapes().addChart(
        ChartType.ScatterWithSmoothLinesAndMarkers, 28.5f, 101, 902.5f, 355);

IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
int worksheetIndex = 0;

chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
workbook.clear(0);

chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(10);

chart.getPlotArea().getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getPlotArea().getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
chart.getPlotArea().getFormat().getLine().setDashStyle(LineDashStyle.Dot);
chart.getPlotArea().getFormat().getLine().setWidth(0.75f);

IChartSeries usSeries = chart.getChartData().getSeries().add("US", chart.getType());

usSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 2, 1, usData[0].x),
        workbook.getCell(worksheetIndex, 2, 2, usData[0].y));
usSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 3, 1, usData[1].x),
        workbook.getCell(worksheetIndex, 3, 2, usData[1].y));
usSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 4, 1, usData[2].x),
        workbook.getCell(worksheetIndex, 4, 2, usData[2].y));
usSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 5, 1, usData[3].x),
        workbook.getCell(worksheetIndex, 5, 2, usData[3].y));

setArrowheadStyles(usSeries);

IChartSeries caSeries = chart.getChartData().getSeries().add("CA", chart.getType());

caSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 2, 3, caData[0].x),
        workbook.getCell(worksheetIndex, 2, 4, caData[0].y));
caSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 3, 3, caData[1].x),
        workbook.getCell(worksheetIndex, 3, 4, caData[1].y));
caSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 4, 3, caData[2].x),
        workbook.getCell(worksheetIndex, 4, 4, caData[2].y));
caSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 5, 3, caData[3].x),
        workbook.getCell(worksheetIndex, 5, 4, caData[3].y));

setArrowheadStyles(caSeries);

IChartSeries euSeries = chart.getChartData().getSeries().add("EU", chart.getType());

euSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 2, 5, euData[0].x),
        workbook.getCell(worksheetIndex, 2, 6, euData[0].y));
euSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 3, 5, euData[1].x),
        workbook.getCell(worksheetIndex, 3, 6, euData[1].y));
euSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 4, 5, euData[2].x),
        workbook.getCell(worksheetIndex, 4, 6, euData[2].y));
euSeries.getDataPoints().addDataPointForScatterSeries(workbook.getCell(worksheetIndex, 5, 5, euData[3].x),
        workbook.getCell(worksheetIndex, 5, 6, euData[3].y));

setArrowheadStyles(euSeries);

chart.getAxes().getHorizontalAxis().setCrossType(CrossesType.Custom);
chart.getAxes().getHorizontalAxis().setCrossAt(-0.5f);
chart.getAxes().getHorizontalAxis().setNumberFormat("# ##0.0\\%");
chart.getAxes().getHorizontalAxis().getTitle().addTextFrameForOverriding("Volume");
setAxisStyle(chart.getAxes().getHorizontalAxis());

chart.getAxes().getVerticalAxis().setNumberFormat("# ##0.00\\%");
chart.getAxes().getVerticalAxis().getTitle().addTextFrameForOverriding("Price");
setAxisStyle(chart.getAxes().getVerticalAxis());

presentation.save("ScatterWithSmoothLinesAndMarkers.pptx", SaveFormat.Pptx);
static void setArrowheadStyles(IChartSeries series)
{
    series.getMarker().setSymbol(MarkerStyleType.None);
    series.getFormat().getLine().setBeginArrowheadStyle(LineArrowheadStyle.Diamond);
    series.getFormat().getLine().setBeginArrowheadWidth(LineArrowheadWidth.Wide);
    series.getFormat().getLine().setBeginArrowheadLength(LineArrowheadLength.Long);
    series.getFormat().getLine().setEndArrowheadStyle(LineArrowheadStyle.Oval);
    series.getFormat().getLine().setEndArrowheadWidth(LineArrowheadWidth.Wide);
    series.getFormat().getLine().setEndArrowheadLength(LineArrowheadLength.Long);
}

static void setAxisStyle(IAxis axis)
{
    final IFontData font = new FontData("Arial");
    final int fontSize = 10;
    axis.getMajorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
    axis.getFormat().getLine().setWidth(2.0);
    axis.getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
    axis.setTickLabelPosition(TickLabelPositionType.Low);
    axis.setMajorTickMark(TickMarkType.None);
    axis.getTextFormat().getPortionFormat().setFontHeight(fontSize);
    axis.getTextFormat().getPortionFormat().setLatinFont(font);
    axis.setNumberFormatLinkedToSource(false);
    axis.setTitle(true);
    axis.getTitle().setOverlay(false);
    IParagraphFormat titlePortion = axis.getTitle().getTextFrameForOverriding().getParagraphs().get_Item(0).getParagraphFormat();
    titlePortion.getDefaultPortionFormat().setFontHeight(fontSize);
    titlePortion.getDefaultPortionFormat().setLatinFont(font);
    titlePortion.getDefaultPortionFormat().setFontBold(NullableBool.False);
}

@VaradS

To change the color of a series in a chart of type ScatterWithSmoothLinesAndMarkers using Aspose.Slides for .NET, you can set the fill color for the series using the getFormat().getFillFormat().getSolidFillColor().setColor(Color) method. Below is an example of how to modify your existing code to change the color of the usSeries, caSeries, and euSeries.

Here’s how you can do it:

// Set the color for the US series
usSeries.getFormat().getFillFormat().setFillType(FillType.Solid);
usSeries.getFormat().getFillFormat().getSolidFillColor().setColor(Color.RED); // Change to your desired color

// Set the color for the CA series
caSeries.getFormat().getFillFormat().setFillType(FillType.Solid);
caSeries.getFormat().getFillFormat().getSolidFillColor().setColor(Color.BLUE); // Change to your desired color

// Set the color for the EU series
euSeries.getFormat().getFillFormat().setFillType(FillType.Solid);
euSeries.getFormat().getFillFormat().getSolidFillColor().setColor(Color.GREEN); // Change to your desired color

In this example, the usSeries is set to red, caSeries to blue, and euSeries to green. You can replace Color.RED, Color.BLUE, and Color.GREEN with any color of your choice.

This approach allows you to customize the appearance of each series in your scatter chart effectively.

For more detailed information on working with chart series in Aspose.Slides, you can refer to the official documentation on chart series here.

Thanks for your help @Professionalize.Discourse ,

I needed code lines in Java but I managed it to achieve. But somehow with these lines of code I’m not getting the lines itself.
If we see the series configs in ppt for line I can see the solid line is selected. Do you think any extra setting I’m doing which can cause this issue?
image.png (6.5 KB)

image.png (14.6 KB)

Sharing the images for your ref.

@VaradS,
This is the same issue described in Write a Code Example to Create a Scatter Chart with Smooth Lines in Java - #9 by VaradS.
Please do not duplicate topics on the forum.