Change colors in treemap chart

Posted by: alfredo on 23 May 2022, 4:28 am EST

  • Posted 23 May 2022, 4:28 am EST

    Hi,

    I need to change the colors that make up the treemap graphic.

    Currently for each category/value of the chart, we have a specific color in RGB that we get from the database.

    How do we apply these colors to each chart category using Java ?

    In Excel, we do this as follows:

    In the chart, select a category manually, right click, fill, and choose a color (for each of the categories).


    // Create a new workbook
    Workbook workbook = new Workbook("License Key");

    IWorksheet worksheet = workbook.getWorksheets().get(0);
    worksheet.getRange("A1:B"+finalPosition).setValue(Values); //define o alcance de células com dados na planilha

    //Create a treemap chart.
    IShape shape = worksheet.getShapes().addChart(ChartType.Treemap, 300, 20, 300, 200);
    shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B"+finalPosition));

    //Set the parent data labels are displayed as banners.
    shape.getChart().getSeriesCollection().get(0).setParentDataLabelOption(ParentDataLabelOptions.Banner);

    //Modify chart title text.
    shape.getChart().getChartTitle().setText("Alocação por Categoria");
    shape.getChart().getChartTitle().delete(); //deleta as legendas do gráfico
    shape.getChart().getLegend().delete(); //deleta o título do gráfico

    ISeries series1 = shape.getChart().getSeriesCollection().get(0);



  • Marked as Answer

    Replied 23 May 2022, 5:57 pm EST

    Hello Alfredo,

    Your query has been replied to on your support case CAS-31494-W8T4T7.
    Please continue the thread there only to avoid confusion.

    Regards,
    Prabhat Sharma.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels