chartjs-chart-error-bars icon indicating copy to clipboard operation
chartjs-chart-error-bars copied to clipboard

lineWithErrorBars

Open mahadev-Pandhare opened this issue 3 years ago • 5 comments

Hi Team, We are facing issue to create Line chart with error bars(lineWithErrorBars). We are getting issue with canvas context issue s undefined, Where same configuration working with barWithErrorBars. So if possible can you provide the reference code for lineWithErrorBars . We are using chart js 3.6.0 version and chartjs-chart-error-bars/v/3.6.0 version. above mentioned npm packges we are using with angular 12.

Thanks, M.dev

mahadev-Pandhare avatar Jan 03 '22 13:01 mahadev-Pandhare

without code it is impossible to tell what is going on, since https://codepen.io/sgratzl/pen/rNGvqXb image works just fine

sgratzl avatar Jan 04 '22 14:01 sgratzl

We are using angular 12 with chart js 3.6.2 version. For the error bars we r using version ^3.6.0. npm package, As suggested in link below: https://www.npmjs.com/package/chartjs-chart-error-bars

We are taking canvas reference using @viewChild decorator in Angular. We r able to render barWithErrorBrs controller bar chrt , But when we use lineWithErrorBars , its having error as undefined context.

So please suggest if we need to do any config changes.

mahadev-Pandhare avatar Jan 04 '22 14:01 mahadev-Pandhare

Continue to @mahadev-Pandhare comment, we are getting below error in console. It is happening with only lineWithErrorBars image

barWithErrorBrs is working fine.

const tempChart: any = {
      type: 'barWithErrorBars',
      data: {
        labels: ['A', 'B'],
        datasets: [
          {
            data: [
              {
                y: 4,
                yMin: 1,
                yMax: 6,
              },
              {
                y: 2,
                yMin: 1,
                yMax: 4,
              },
            ],
          },
        ],
      },
      options: {
        scales: {
          y: {
            ticks: {
              beginAtZero: true,
            },
          },
        },
      },
      plugins: [BarWithErrorBarsController]
    }

    this.canvas = this.resourceComboChartEl.nativeElement;
    this.ctx = this.canvas.getContext('2d');
    this.resourceComboChart = new Chart(this.ctx, tempChart);
    this.resourceComboChart.update();

image

FrontlineWarrior avatar Jan 05 '22 11:01 FrontlineWarrior

While doing analysis we found that DatasetController getting called twice for lineWithErrorBars, any idea why it is getting called twice? does any configuration is required to stop second call?

image

FrontlineWarrior avatar Jan 05 '22 12:01 FrontlineWarrior

can you create a codesandbox or similar with a setup that is showing this error? Otherwise, I don't know how to investigate this error since it works fine in the codepen I sent before

sgratzl avatar Jan 05 '22 14:01 sgratzl