Hello,
Using the below code I’m able to generate a Stock chart (Type.HighLowClose) using Aspose.Slides for Java API.
Need help in disabling lines from the series.
Reference link: Create or Update PowerPoint Presentation Charts in Java|Aspose.Slides Documentation
import com.aspose.cells.common.Utils;
import com.aspose.slides.ChartType;
import com.aspose.slides.FillType;
import com.aspose.slides.IChart;
import com.aspose.slides.IChartDataWorkbook;
import com.aspose.slides.IChartSeries;
import com.aspose.slides.MarkerStyleType;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
import java.awt.Color;
public class CandlestickChart{
public static void main(String[] args) throws Exception {
String dataDir = Utils.getDataDir(CandlestickChart.class);
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.HighLowClose, 50, 50, 600, 400, false);
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
IChartDataWorkbook wb = chart.getChartData().getChartDataWorkbook();
chart.getChartData().getCategories().add(wb.getCell(0, 1, 0, "A"));
chart.getChartData().getCategories().add(wb.getCell(0, 2, 0, "B"));
chart.getChartData().getCategories().add(wb.getCell(0, 3, 0, "C"));
chart.getChartData().getSeries().add(wb.getCell(0, 0, 1, "High"), chart.getType());
chart.getChartData().getSeries().add(wb.getCell(0, 0, 2, "Low"), chart.getType());
chart.getChartData().getSeries().add(wb.getCell(0, 0, 3, "Close"), chart.getType());
IChartSeries series = chart.getChartData().getSeries().get_Item(0);//high
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 1, 1, 72));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 2, 1, 25));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 3, 1, 38));
series = chart.getChartData().getSeries().get_Item(1);//low
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 1, 2, 12));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 2, 2, 12));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 3, 2, 13));
series = chart.getChartData().getSeries().get_Item(2);//close
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 1, 3, 25));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 2, 3, 38));
series.getDataPoints().addDataPointForStockSeries(wb.getCell(0, 3, 3, 50));
chart.getChartData().getSeriesGroups().get_Item(0).getHiLowLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid); //getHiLowLinesFormat
chart.getAxes().getVerticalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
chart.getAxes().getHorizontalAxis().getMinorGridLinesFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
for (int j = 0; j < chart.getChartData().getSeries().size(); j++) {
IChartSeries ser = chart.getChartData().getSeries().get_Item(j);
ser.getMarker().setSize(15);//MarkerSize
ser.getMarker().getFormat().getFill().setFillType(FillType.Solid);//MarkerFillType
ser.getMarker().getFormat().getLine().getFillFormat().setFillType(FillType.Solid);//MarkerBorderFillType
ser.getMarker().getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLACK);//MarkerBordercolor
switch (j) {
case 0://high
ser.getMarker().setSymbol(MarkerStyleType.Circle);//MarkerShape
ser.getMarker().getFormat().getFill().getSolidFillColor().setColor(getColor("#CB4B7A"));//Markercolor
break;
case 1://low
ser.getMarker().setSymbol(MarkerStyleType.Dash);
ser.getMarker().getFormat().getFill().getSolidFillColor().setColor(getColor("#FFB500"));
break;
case 2://close
ser.getMarker().setSymbol(MarkerStyleType.Square);
ser.getMarker().getFormat().getFill().getSolidFillColor().setColor(getColor("#675895"));
break;
}
}
pres.save(dataDir + "Sample-StockHLC.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
}
public static Color getColor(final String hexColor) {
final Color color = Color.decode(hexColor);
return new Color(color.getRed(), color.getGreen(), color.getBlue());
}
}
Attaching a sample PPT and the required screenshots.
Sample-StockHLC.zip (139.4 KB)
Thanks in advance