samber / samber/chartjs-plugin-datasource-prometheus

dataSetHook has an error

Open
#39 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
123
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Hello I tried to use the dataSetHook but I am getting an error about

index.umd.ts:50 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach')
    at cn (index.umd.ts:50:18)
    at dn (index.umd.ts:50:18)
    at bn.update (index.umd.ts:50:18)
    at An.update (index.umd.ts:50:18)
    at Object.resumeRendering (prometheus-query.umd.js:7:71)
    at prometheus-query.umd.js:7:71
cn	@	index.umd.ts:50
dn	@	index.umd.ts:50
update	@	index.umd.ts:50
update	@	index.umd.ts:50
resumeRendering	@	prometheus-query.umd.js:7
(anonymous)	@	prometheus-query.umd.js:7
Promise.catch (async)		
beforeUpdate	@	prometheus-query.umd.js:7
d	@	color.esm.js:97
_notify	@	index.umd.ts:50
notify	@	index.umd.ts:50
notifyPlugins	@	index.umd.ts:50
update	@	index.umd.ts:50
An	@	index.umd.ts:50
(anonymous)	@	main.js:175

I believe that this is an error on the dataSetHook since when I remove it this error is not showing in the console.

My code for initializing the chart looks like this:

var jitterChart = new Chart(ctxjitter, {
    type: 'line',
    plugins: [ChartDatasourcePrometheusPlugin],
    options: {
      animation: {
        duration: 0,
      },
      plugins: {
        'datasource-prometheus': {
          query: [jitterQuery,maxLatencyQuery],
          timeRange: {
            type: 'absolute',
            start: startDate,
            end: endDate,
            msUpdateInterval: 5000,
          },
          dataSetHook:(datasets) => {
            console.log(datasets);
          },
        },
      },
    },
  });

NOTE: Please correct me if this is an error from my end. thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dataSetHook callback in the datasource-prometheus plugin configuration and trace the update path shown in index.umd.ts. Reproduce the issue with the provided two-query chart configuration and inspect the logged datasets; done when using dataSetHook no longer triggers the reported undefined.forEach error.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus, typescript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.