Candlestick chart support in Excel

Hello,

Attaching a sample excel file with the manually created chart.
Need assistance in creating a candlestick chart similar to that attached excel using Aspose.Cells for Java API.
candlestick_chart.zip (11.8 KB)

Thanks in Advance

@SrideviG,

Thanks for the sample file.

I have created a sample code to create your desired chart. Please refer to the code segment and write/update according to your needs. I have used the source data in your provided file and created the chart below your design chart:
e.g.
Sample code:

        Workbook workbook = new Workbook("f:\\files\\candlestick_chart.xlsx");
        Worksheet worksheet = workbook.getWorksheets().get(0);
        int i  = worksheet.getCharts().add(ChartType.STOCK_VOLUME_HIGH_LOW_CLOSE,20, 6, 38, 14);
        Chart chart = worksheet.getCharts().get(i);
        chart.setShowLegend(true);
        chart.getTitle().setText("Chart Title");
        chart.getTitle().setVisible(true);
        chart.getLegend().setPosition(LegendPositionType.BOTTOM);
        chart.setChartDataRange("A1:E9",true);
        chart.getNSeries().setCategoryData("A2:A9");
        for(int j = 0;j<chart.getNSeries().getCount();j++)
        {
            switch (j) {
                case 1:
                    chart.getNSeries().get(j).getMarker().setMarkerStyle(ChartMarkerType.DASH);
                    chart.getNSeries().get(j).getMarker().setMarkerSize(20);
                    chart.getNSeries().get(j).getMarker().getArea().setFormatting(FormattingType.CUSTOM);
                    chart.getNSeries().get(j).getMarker().getArea().setForegroundColor(com.aspose.cells.Color.getMaroon());
                    chart.getNSeries().get(j).getBorder().setVisible(false);
                    break;
                case 2:
                    chart.getNSeries().get(j).getMarker().setMarkerStyle(ChartMarkerType.SQUARE);
                    chart.getNSeries().get(j).getMarker().setMarkerSize(10);
                    chart.getNSeries().get(j).getMarker().getArea().setFormatting(FormattingType.CUSTOM);
                    chart.getNSeries().get(j).getMarker().getArea().setForegroundColor(com.aspose.cells.Color.getGreen());
                    chart.getNSeries().get(j).getBorder().setVisible(false);
                    break;
                case 3:
                    chart.getNSeries().get(j).getMarker().setMarkerStyle(ChartMarkerType.CIRCLE);
                    chart.getNSeries().get(j).getMarker().setMarkerSize(20);
                    chart.getNSeries().get(j).getMarker().getArea().setFormatting(FormattingType.CUSTOM);
                    chart.getNSeries().get(j).getMarker().getArea().setForegroundColor(com.aspose.cells.Color.getBlue());
                    chart.getNSeries().get(j).getBorder().setVisible(false);
                    break;
            }
        }

        chart.getPlotArea().getArea().setFormatting(FormattingType.NONE);

        workbook.save("f:\\files\\out1.xlsx");

Hope, this helps a bit.

Thanks for your response.
I’m able to generate the chart with this.

Is it possible to add the bar in this chart as a secondary axis?
or to add a candle stick chart with a combination of bar chart as a custom chart type?

@SrideviG,

If you are able to do this in MS Excel, so you can do it via Aspose.Cells for Java API. If you find any issue in doing the task, kindly create your desired chart in MS Excel and save the file to provide us. Also, share your current sample code (runnable) which is giving you undesired results, we will check it soon.

@SrideviG
Please check Stock charts in MS Excel.
And in Aspose.Cells, you can use ChartType.StockHighLowClose ,StockOpenHighLowClose, ChartType.StockVolumeHighLowClose and StockVolumeOpenHighLowClose to add stock chart.
Please check documents about plotting series to secondary axis