How to change ag-charts bar chart's column color?

Discussão em 'Angular' iniciado por Cronos, Outubro 28, 2024.

  1. Cronos

    Cronos Guest

    I am using ag-charts for my project. This is an example from the internet, what is very similar to my code:

    import { AgChartOptions, AgCharts } from "ag-charts-community";

    const options: AgChartOptions = {
    container: document.getElementById("myChart"),
    data: [
    { os: "Windows", share: 0.88 },
    { os: "macOS", share: 0.094 },
    { os: "Linux", share: 0.187 },
    ],
    title: {
    text: "Desktop Operating Systems",
    },
    series: [
    {
    type: "bar",
    xKey: "os",
    yKey: "share",
    },
    ],
    axes: [
    {
    type: "category",
    position: "bottom",
    label: {
    formatter: ({ value }) => {
    return value == "Windows" ? "== Windows ==" : value;
    },
    },
    },
    {
    type: "number",
    position: "left",
    label: {
    formatter: (params) => {
    return params.value * 100 + "%";
    },
    },
    },
    ],
    };

    const chart = AgCharts.create(options);


    link

    But I want to change the color of the columns separately! How is it possible? I tried to use series for each column and then the 'fill' property, which is works, but then I am not able to write out the x axis labels...

    please help me!

    Continue reading...

Compartilhe esta Página