Skip to content

How to fix the cutting graph in ESM build? #9273

@golubvladimir

Description

@golubvladimir

Expected Behavior

I want to display a bar chart of 158 values,

Current Behavior

But a cut occurs at 110.

Possible Solution

Steps to Reproduce

alt problem

<template>
  <div>
    <canvas id="myChart"></canvas>
  </div>
</template>

<script>
import { Chart, registerables } from 'chart.js3'
import ChartJsPluginDataLabels from 'chartjs-plugin-datalabels';

export default {
  props: ['items'],
  mounted() {
    var ctx = document.getElementById('myChart');

    const dataGraph = {
      labels: this.items.map(item => item['date']),
      datasets: [
        {
          data: this.items.map(item => item['actual'] || item['forecast'] || 0),
          backgroundColor: '#698ED1'
        }
      ]
    };

    const optionsGraph = {
      maintainAspectRatio: false,
      animation: {
        duration: 0
      },
      legend: {
        display: false,
      },
      scales: {
        x: {
          grid: {
            color: '#000'
          }
        },
        y: {
          ticks: {
            display: false
          },
          grid: {
            color: function(context) {
              return '#000';
            }
          }
        }
      },
      // plugins: {
      //   datalabels: {
      //     color: '#768CB7',
      //     font: {
      //       family: 'Roboto',
      //       size: '11',
      //       weight: '700'
      //     },
      //     anchor: 'end',
      //     align: 'top',
      //     textAlign: 'center',
      //     offset: '-3',
      //   }
      // }
    };

    Chart.register(...registerables);
    //Chart.register(ChartJsPluginDataLabels);

    var myChart = new Chart(ctx, {
      type: 'bar',
      data: dataGraph,
      options: optionsGraph
    });
  }
}
</script>

Context

I tried the same with the second version but got the same error.
When I use ChartJsPluginDataLabels, I have error: Cannot read property 'skip' of undefined

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions