{"record":{"id":"34c210b2c643f303","repo":"chartjs/Chart.js","slug":"this-method-is-not-implemented-check-that-a-compl","errorCode":null,"errorMessage":"This method is not implemented: Check that a complete date adapter is provided.","messagePattern":"This method is not implemented: Check that a complete date adapter is provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/core/core.adapters.ts","lineNumber":66,"sourceCode":"  diff(this: DateAdapter<T>, a: number, b: number, unit: TimeUnit): number;\n  /**\n   * Returns start of `unit` for the given `timestamp`.\n   * @param timestamp - the input timestamp\n   * @param unit - the unit as string\n   * @param [weekday] - the ISO day of the week with 1 being Monday\n   * and 7 being Sunday (only needed if param *unit* is `isoWeek`).\n   */\n  startOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number | boolean): number;\n  /**\n   * Returns end of `unit` for the given `timestamp`.\n   * @param timestamp - the input timestamp\n   * @param unit - the unit as string\n   */\n  endOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit): number;\n}\n\nfunction abstract<T = void>(): T {\n  throw new Error('This method is not implemented: Check that a complete date adapter is provided.');\n}\n\n/**\n * Date adapter (current used by the time scale)\n * @namespace Chart._adapters._date\n * @memberof Chart._adapters\n * @private\n */\nclass DateAdapterBase implements DateAdapter {\n\n  /**\n   * Override default date adapter methods.\n   * Accepts type parameter to define options type.\n   * @example\n   * Chart._adapters._date.override<{myAdapterOption: string}>({\n   *   init() {\n   *     console.log(this.options.myAdapterOption);\n   *   }","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/chartjs/Chart.js/blob/cb02e1d207bd4c4c40b20c259017f85f26f1e30a/src/core/core.adapters.ts#L48-L84","documentation":"Chart.js ships its base DateAdapter (DateAdapterBase) with every method (formats, parse, format, add, diff, startOf, endOf) implemented as a stub that calls the internal abstract() helper, which throws this error. The time scale depends on these methods to parse data, generate ticks, and format labels. The library throws it because Chart.js core deliberately does NOT bundle a date library; a concrete adapter (e.g. chartjs-adapter-date-fns, chartjs-adapter-luxon, chartjs-adapter-moment) must be registered separately to supply real implementations.","triggerScenarios":"Loading a time scale (type: 'time' or 'timeseries') without importing/registering a date adapter; importing the bare 'chart.js' entry instead of the 'chart.js/auto' auto-register bundle; or registering an adapter that does not override one of the seven DateAdapter methods (partial override). The throw happens the first time the time scale calls the adapter (during data parsing or tick generation in TimeScale._generate / _parse).","commonSituations":"Upgrading from Chart.js 3 (where date-fns adapter was sometimes pulled in transitively) to v4 and forgetting the adapter; using tree-shaking/bundler setups that drop the adapter side-effect import; mixing 'chart.js/auto' with a manual adapter import that gets elided; or writing a custom adapter and forgetting to implement one method (e.g. startOf) via Chart._adapters._date.override({...}).","solutions":["Install and import a date adapter: `npm i chartjs-adapter-date-fns` then `import 'chartjs-adapter-date-fns';` (or luxon/moment) BEFORE creating the chart.","If using the auto bundle, import from 'chart.js/auto' which registers scales but still requires the adapter side-effect import separately.","For a custom adapter, override ALL seven methods (formats, parse, format, add, diff, startOf, endOf) via Chart._adapters._date.override({...}) or by extending DateAdapterBase.","Verify the adapter import is not tree-shaken: place it as a top-level import with side effects, not a dynamic import that may be dropped."],"exampleFix":"// before\nimport { Chart } from 'chart.js';\nnew Chart(ctx, { type: 'line', data, options: { scales: { x: { type: 'time' } } } });\n\n// after\nimport { Chart } from 'chart.js';\nimport 'chartjs-adapter-date-fns'; // registers concrete DateAdapter methods\nnew Chart(ctx, { type: 'line', data, options: { scales: { x: { type: 'time' } } } });","handlingStrategy":"validation","validationCode":"// Detect a missing/incomplete date adapter before creating a time scale.\nimport { Chart, _adapters } from 'chart.js';\n\nfunction hasDateAdapter() {\n  const a = new Chart._adapters._date();\n  // abstract methods throw 'This method is not implemented' when not overridden\n  try {\n    a.parse(Date.now());\n    a.format(Date.now(), 'yyyy');\n    a.add(0, 1, 'day');\n    return true;\n  } catch (e) {\n    return /not implemented/.test(String(e.message));\n  }\n}\nif (!hasDateAdapter()) {\n  throw new Error('Import a date adapter (e.g. chartjs-adapter-date-fns) before using time scales.');\n}","typeGuard":"// Type-level guard ensuring the time scale is only used with a registered adapter.\nimport type { ChartOptions } from 'chart.js';\nfunction assertTimeScaleReady<T extends ChartOptions>(opts: T): T {\n  const scales = (opts.scales ?? {}) as Record<string, any>;\n  for (const [id, s] of Object.entries(scales)) {\n    if (s?.type === 'time' || s?.type === 'timeseries') {\n      // runtime reminder; real check is the adapter import above\n      if (!('chartjs-adapter-date-fns' in globalThis)) {\n        console.warn(`Scale '${id}' is type '${s.type}'; ensure a date adapter is imported.`);\n      }\n    }\n  }\n  return opts;\n}","tryCatchPattern":null,"preventionTips":["Always import the date adapter as a top-level side-effect import in the same entry that imports 'chart.js'.","Add a smoke test that constructs a tiny time-scale chart to fail builds that drop the adapter.","Document the adapter dependency in onboarding docs for any team using time scales.","Beware tree-shaking: if you import from 'chart.js' (not '/auto'), the adapter must still be imported separately."],"tags":["date-adapter","time-scale","configuration","setup","dependency"],"backgroundTag":null,"analyzedSha":"cb02e1d207bd4c4c40b20c259017f85f26f1e30a","analyzedAt":"2026-08-12T23:38:10.965Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}