Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
how to represent boolean and enum values in a linear graph using ng-apexcharts?

I have managed to get the values to be displayed, but not to behave correctly with respect to the axis

HTML:

<apx-chart
        [series]="chartOptions.series"
        [chart]="chartOptions.chart"
        [xaxis]="chartOptions.xaxis"
        [colors]="chartOptions.colors"
        [dataLabels]="chartOptions.dataLabels"
        [markers]="chartOptions.markers"
        [yaxis]="chartOptions.yaxis"
        [title]="chartOptions.title"
></apx-chart>

TS:

let matrix = {};
        const data = this.data.map((point, index) => {
            matrix[index] = point[this.data.type + 'Value'];
            let value = this.data.type === 'number' ? point[this.data.type + 'Value'] : index;
            return {
                x: this.transformDate(point.createdAt),
                    y: value
            }
        });

        this.chartOptions = {
            series: [
                {
                    name: this.data.name,
                    data
                },
            ],
            chart: {
                height: this.chartHeight,
                width: this.chartWith,
                type: "line",
                dropShadow: {
                    enabled: true,
                    color: "#000",
                    top: 18,
                    left: 7,
                    blur: 10,
                    opacity: 0.2
                },
                toolbar: {
                    show: false
                }
            },
            colors: ["#77B6EA", "#545454"],
            dataLabels: {
                enabled: true,
                formatter: (val, index) => {
                    return this.data.type === 'number' ? val : matrix[val];
                }
            },
            title: {
                text: this.data.name,
                align: "left"
            },
            markers: {
                size: 1
            },
            xaxis: {
                title: {
                    text: "Date"
                }
            },
            yaxis: {
                labels: {
                    show: true,
                    formatter: (value, index) => {
                        return this.data.type === 'number' ? value : matrix[value];
                    }
                },
                title: {
                    text: this.data?.unit || 'Values'
                },
            },
        };

When the values are numeric there is no problem, the problem is with the boolean and the enum type, these are represented but badly they always grow on the y-axis and the values are repeated

Examples: Graph with enum values

Graph with boolean values

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda