{"record":{"id":"7a380a68ff384513","repo":"dianping/cat","slug":"time-mode-requires-the-flot-time-plugin","errorCode":null,"errorMessage":"Time mode requires the flot.time plugin.","messagePattern":"Time mode requires the flot\\.time plugin\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/flot/jquery.flot.js","lineNumber":1736,"sourceCode":"            } else {\n                size = 10;\n            }\n\n            size *= magn;\n\n            if (opts.minTickSize != null && size < opts.minTickSize) {\n                size = opts.minTickSize;\n            }\n\n            axis.delta = delta;\n            axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec);\n            axis.tickSize = opts.tickSize || size;\n\n            // Time mode was moved to a plug-in in 0.8, and since so many people use it\n            // we'll add an especially friendly reminder to make sure they included it.\n\n            if (opts.mode == \"time\" && !axis.tickGenerator) {\n                throw new Error(\"Time mode requires the flot.time plugin.\");\n            }\n\n            // Flot supports base-10 axes; any other mode else is handled by a plug-in,\n            // like flot.time.js.\n\n            if (!axis.tickGenerator) {\n\n                axis.tickGenerator = function (axis) {\n\n                    var ticks = [],\n                        start = floorInBase(axis.min, axis.tickSize),\n                        i = 0,\n                        v = Number.NaN,\n                        prev;\n\n                    do {\n                        prev = v;\n                        v = start + i * axis.tickSize;","sourceCodeStart":1718,"sourceCodeEnd":1754,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/flot/jquery.flot.js#L1718-L1754","documentation":"Since flot 0.8, time-mode axes were split into the flot.time plugin which installs a tickGenerator for mode:'time'. The core setup detects opts.mode == 'time' with no axis.tickGenerator installed — meaning the plugin never ran — and throws a friendly reminder rather than producing garbage ticks.","triggerScenarios":"$.plot(el, data, { xaxis: { mode: 'time' } }) with only jquery.flot.js loaded; including jquery.flot.time.js after the $.plot() call (too late); a typo in the plugin filename so it 404s; bundling that drops flot.time.","commonSituations":"Upgrading flot from 0.7 (time mode was built-in) to 0.8+ without adding the new plugin file; time-series dashboards where the include list was hand-maintained.","solutions":["Include jquery.flot.time.js after jquery.flot.js and before calling $.plot.","Verify the plugin file loads (Network tab) and the filename/path is correct.","Alternatively convert timestamps to plain numbers and format tick labels manually (not recommended)."],"exampleFix":"// before\n<script src=\"jquery.flot.js\"></script>\n$.plot('#chart', data, { xaxis: { mode: 'time' } }); // throws\n\n// after\n<script src=\"jquery.flot.js\"></script>\n<script src=\"jquery.flot.time.js\"></script>\n$.plot('#chart', data, { xaxis: { mode: 'time' } });","handlingStrategy":"validation","validationCode":"function flotTimeReady() {\n  // flot.time registers its axis hooks; simplest proxy: check the script loaded\n  return document.querySelector('script[src*=\"jquery.flot.time\"]') != null;\n}\nif (opts.xaxis && opts.xaxis.mode === 'time' && !flotTimeReady()) {\n  delete opts.xaxis.mode; // or abort with a clear message\n}","typeGuard":null,"tryCatchPattern":"try {\n  $.plot('#chart', data, { xaxis: { mode: 'time' } });\n} catch (e) {\n  if (/flot\\.time/.test(e.message)) {\n    console.error('Include jquery.flot.time.js before plotting time axes');\n  } else throw e;\n}","preventionTips":["Keep one shared include list: jquery.flot.js, jquery.flot.time.js, then app chart code.","After flot upgrades, re-check that mode:'time' usage still has the plugin included.","Add an integration smoke test that plots one time-series chart in CI."],"tags":["flot","time-axis","plugin","script-order","charts","vendor"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}