chartjs-chart-treemap 5.0.0-next.9 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/chartjs-chart-treemap.cjs +24 -8
- package/dist/chartjs-chart-treemap.esm.js +24 -8
- package/dist/chartjs-chart-treemap.min.js +2 -2
- package/dist/chartjs-chart-treemap.min.js.map +1 -1
- package/dist/controller.d.cts +64 -0
- package/dist/controller.d.ts +4 -2
- package/dist/element.d.cts +65 -0
- package/dist/element.d.ts +1 -1
- package/dist/geometry.d.cts +38 -0
- package/dist/geometry.d.ts +3 -3
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.d.cts +4 -0
- package/dist/index.esm.d.ts +4 -4
- package/dist/layout.d.cts +29 -0
- package/dist/layout.d.ts +2 -2
- package/dist/options.d.cts +15 -0
- package/dist/options.d.ts +1 -1
- package/dist/rect.d.cts +18 -0
- package/dist/squarify.d.cts +21 -0
- package/dist/statArray.d.cts +18 -0
- package/dist/text/draw.d.ts +3 -3
- package/dist/text/fit.d.ts +3 -3
- package/dist/text/index.d.ts +2 -2
- package/dist/text/wrap.d.ts +1 -1
- package/dist/types.d.cts +167 -0
- package/dist/utils.d.cts +17 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +20 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartjs-chart-treemap.min.js","sources":["../src/helpers/index.ts","../src/options.ts","../src/rect.ts","../src/statArray.ts","../src/utils.ts","../src/squarify.ts","../src/text/measure.ts","../src/text/draw.ts","../src/text/fit.ts","../src/text/wrap.ts","../src/text/index.ts","../src/layout.ts","../src/controller.ts","../src/geometry.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["export function scaleRect(sq: any, xScale: any, yScale: any, sp: number) {\n const sp2 = sp * 2\n const x = xScale.getPixelForValue(sq.x)\n const y = yScale.getPixelForValue(sq.y)\n const w = xScale.getPixelForValue(sq.x + sq.w) - x\n const h = yScale.getPixelForValue(sq.y + sq.h) - y\n return {\n height: h - sp2,\n hidden: sp2 > w || sp2 > h,\n width: w - sp2,\n x: x + sp,\n y: y + sp,\n }\n}\n\nexport function rectNotEqual(r1: any, r2: any) {\n return (\n !r1 ||\n !r2 ||\n r1.x !== r2.x ||\n r1.y !== r2.y ||\n r1.w !== r2.w ||\n r1.h !== r2.h ||\n r1.rtl !== r2.rtl ||\n r1.unsorted !== r2.unsorted\n )\n}\n\nexport function arrayNotEqual(a: any[], b: any[]) {\n let i: number\n let n: number\n\n if (!a || !b) {\n return true\n }\n\n if (a === b) {\n return false\n }\n\n if (a.length !== b.length) {\n return true\n }\n\n for (i = 0, n = a.length; i < n; ++i) {\n if (a[i] !== b[i]) {\n return true\n }\n }\n return false\n}\n","import type {\n TreemapBorderRadius,\n TreemapBorderWidth,\n TreemapLayoutOptions,\n TreemapOptions,\n} from './types'\n\nimport { toTRBL, toTRBLCorners } from 'chart.js/helpers'\n\n/**\n * Options that shape the whole dataset's layout rather than a single element.\n * They live in the controller's defaults; the element receives the resolved\n * values as an argument to `draw`.\n */\nexport const layoutDefaults: TreemapLayoutOptions = {\n displayMode: 'containerBoxes',\n rtl: false,\n spacing: 0.5,\n}\n\nexport type ParsedBorderWidth = {\n b: number\n l: number\n r: number\n t: number\n}\n\nfunction limit(value: number, min: number, max: number) {\n return Math.max(Math.min(value, max), min)\n}\n\nexport function parseBorderWidth(\n value: TreemapBorderWidth,\n maxW: number,\n maxH: number\n): ParsedBorderWidth {\n const o = toTRBL(value as Parameters<typeof toTRBL>[0])\n\n return {\n b: limit(o.bottom, 0, maxH),\n l: limit(o.left, 0, maxW),\n r: limit(o.right, 0, maxW),\n t: limit(o.top, 0, maxH),\n }\n}\n\nexport function parseBorderRadius(\n value: TreemapOptions['borderRadius'],\n maxW: number,\n maxH: number\n): TreemapBorderRadius {\n const o = toTRBLCorners(value as Parameters<typeof toTRBLCorners>[0])\n const maxR = Math.min(maxW, maxH)\n\n return {\n bottomLeft: limit(o.bottomLeft, 0, maxR),\n bottomRight: limit(o.bottomRight, 0, maxR),\n topLeft: limit(o.topLeft, 0, maxR),\n topRight: limit(o.topRight, 0, maxR),\n }\n}\n","function getDims(itm: any, w2: number, s2: number, key: string) {\n const a = itm._normalized\n if (!a) {\n // A zero-area item would divide by its own zero side and produce NaN\n // coordinates. It has nothing to draw, so give it nothing.\n return { d1: 0, d2: 0, h: 0, w: 0 }\n }\n const ar = (w2 * a) / s2\n const d1 = Math.sqrt(a * ar)\n const d2 = a / d1\n const w = key === '_ix' ? d1 : d2\n const h = key === '_ix' ? d2 : d1\n\n return { d1, d2, h, w }\n}\n\nconst getX = (rect: Rect, w: number) => (rect.rtl ? rect.x + rect.iw - w : rect.x + rect._ix)\n\n/** Writes the geometry of one packed row onto the nodes themselves. */\nfunction assignRow(rect: Rect, itm: any, dims: any, sum: number) {\n itm.a = itm._normalized\n itm.h = dims.h\n itm.s = sum\n itm.w = dims.w\n itm.x = getX(rect, dims.w)\n itm.y = rect.y + rect._iy\n delete itm._normalized\n}\n\nexport default class Rect {\n [key: string]: any\n rtl: boolean\n unsorted: boolean\n x: number\n y: number\n _ix: number\n _iy: number\n w: number\n h: number\n\n constructor(r?: any) {\n r = r || { h: 1, w: 1 }\n this.rtl = !!r.rtl\n this.unsorted = !!r.unsorted\n this.x = r.x || r.left || 0\n this.y = r.y || r.top || 0\n this._ix = 0\n this._iy = 0\n this.w = r.w || r.width || r.right - r.left\n this.h = r.h || r.height || r.bottom - r.top\n }\n\n get area() {\n return this.w * this.h\n }\n\n get iw() {\n return this.w - this._ix\n }\n\n get ih() {\n return this.h - this._iy\n }\n\n get dir() {\n const ih = this.ih\n return ih <= this.iw && ih > 0 ? 'y' : 'x'\n }\n\n get side() {\n return this.dir === 'x' ? this.iw : this.ih\n }\n\n map(arr: any) {\n const { dir, side } = this\n const key = dir === 'x' ? '_ix' : '_iy'\n const sum = arr.nsum\n const row = arr.get()\n const w2 = side * side\n const s2 = sum * sum\n let maxd2 = 0\n let totd1 = 0\n for (const itm of row) {\n const dims = getDims(itm, w2, s2, key)\n totd1 += dims.d1\n maxd2 = Math.max(maxd2, dims.d2)\n assignRow(this, itm, dims, arr.sum)\n this[key] += dims.d1\n }\n\n this[dir === 'x' ? '_iy' : '_ix'] += maxd2\n this[key] -= totd1\n }\n}\n","const min = Math.min\nconst max = Math.max\n\nfunction getStat(sa: StatArray) {\n return {\n max: sa.max,\n min: sa.min,\n nmax: sa.nmax,\n nmin: sa.nmin,\n nsum: sa.nsum,\n sum: sa.sum,\n }\n}\n\nfunction getNewStat(sa: StatArray, o: any) {\n const v = +o[sa.key]\n const n = v * sa.ratio\n o._normalized = n\n\n return {\n max: max(sa.max, v),\n min: min(sa.min, v),\n nmax: max(sa.nmax, n),\n nmin: min(sa.nmin, n),\n nsum: sa.nsum + n,\n sum: sa.sum + v,\n }\n}\n\nfunction setStat(sa: StatArray, stat: any) {\n Object.assign(sa, stat)\n}\n\nfunction push(sa: StatArray, o: any, stat: any) {\n sa._arr.push(o)\n setStat(sa, stat)\n}\n\nexport default class StatArray {\n key: string\n ratio: number\n _arr: any[] = []\n _hist: any[] = []\n sum = 0\n nsum = 0\n min = Infinity\n max = -Infinity\n nmin = Infinity\n nmax = -Infinity\n\n constructor(key: string, ratio: number) {\n this.key = key\n this.ratio = ratio\n this.reset()\n }\n\n get length() {\n return this._arr.length\n }\n\n reset() {\n this._arr = []\n this._hist = []\n this.sum = 0\n this.nsum = 0\n this.min = Infinity\n this.max = -Infinity\n this.nmin = Infinity\n this.nmax = -Infinity\n }\n\n push(o: any) {\n push(this, o, getNewStat(this, o))\n }\n\n pushIf(o: any, fn: any, ...args: any[]) {\n const nstat = getNewStat(this, o)\n if (!fn(getStat(this), nstat, args)) {\n return o\n }\n push(this, o, nstat)\n }\n\n get() {\n return this._arr\n }\n}\n","import type { AnyObject } from './types'\n\nimport { isObject } from 'chart.js/helpers'\n\nconst isOlderPart = (act: string, req: string) =>\n req > act || (act.length > req.length && act.startsWith(req))\n\nexport const getGroupKey = (lvl: unknown) => String(lvl)\n\nconst hasGroupValue = (value: unknown) => value !== undefined && value !== null && value !== ''\n\nfunction scanTreeObject(\n keys: string[],\n leafKey: string,\n obj: Record<string, any>,\n tree: string[] = [],\n lvl = 0,\n result: Record<string, any>[] = []\n) {\n const objIndex = lvl - 1\n if (keys[0] in obj && lvl > 0) {\n const record = tree.reduce<Record<string, any>>((reduced, item, i) => {\n if (i !== objIndex) {\n reduced[getGroupKey(i)] = item\n }\n return reduced\n }, {})\n record[leafKey] = tree[objIndex]\n keys.forEach((k) => {\n record[k] = obj[k]\n })\n result.push(record)\n } else {\n for (const childKey of Object.keys(obj)) {\n const child = obj[childKey]\n if (isObject(child)) {\n tree.push(childKey)\n scanTreeObject(keys, leafKey, child, tree, lvl + 1, result)\n }\n }\n }\n tree.splice(objIndex, 1)\n return result\n}\n\n/**\n * Flattens a nested object into the array form of `data`.\n *\n * The controller does this at runtime, so JavaScript configurations never need\n * it. TypeScript users who would rather pass an array than a generic can call\n * it up front.\n */\nexport function flattenTree<T = AnyObject>(tree: AnyObject, keys: string[], leafKey: string): T[] {\n return normalizeTreeToArray(keys, leafKey, tree) as T[]\n}\n\nexport function normalizeTreeToArray(keys: string[], leafKey: string, obj: Record<string, any>) {\n const data = scanTreeObject(keys, leafKey, obj)\n if (!data.length) {\n return data\n }\n const max = data.reduce((maxVal, element) => {\n // minus 2 because _leaf and value properties are added\n // on top to groups ones\n const ikeys = Object.keys(element).length - 2\n return Math.max(maxVal, ikeys)\n }, 0)\n data.forEach((element) => {\n for (let i = 0; i < max; i++) {\n const groupKey = getGroupKey(i)\n if (!element[groupKey]) {\n element[groupKey] = ''\n }\n }\n })\n return data\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\nexport function flatten(input: any[]) {\n const stack = [...input]\n const res = []\n while (stack.length) {\n // pop value from stack\n const next = stack.pop()\n if (Array.isArray(next)) {\n // push back array items, won't modify the original input\n stack.push(...next)\n } else {\n res.push(next)\n }\n }\n // reverse to restore input order\n return res.reverse()\n}\n\nfunction getPath(groups: string[], value: Record<string, any>, defaultValue: string) {\n const path = []\n for (const grp of groups) {\n const item = value[grp]\n if (!hasGroupValue(item)) {\n continue\n }\n path.push(item)\n }\n return path.length ? path.join('.') : defaultValue\n}\n\nfunction resolveGroup(\n value: Record<string, any>,\n leafKey: string,\n allGroups: string[],\n groupIndex: number\n) {\n for (let idx = groupIndex; idx < allGroups.length; idx++) {\n const groupKey = getGroupKey(allGroups[idx])\n if (hasGroupValue(value[groupKey])) {\n return { group: groupKey, groupIndex: idx, value: value[groupKey] }\n }\n }\n if (hasGroupValue(value[leafKey])) {\n return { group: leafKey, groupIndex, value: value[leafKey] }\n }\n return undefined\n}\n\nfunction ensureGroup(\n tmp: Record<string, any>,\n data: Record<string, any[]>,\n groupValue: string,\n addKeys: string[]\n) {\n if (groupValue in tmp) {\n return\n }\n tmp[groupValue] = { value: 0 }\n const tmpRef = tmp[groupValue]\n addKeys.forEach((k) => {\n tmpRef[k] = 0\n })\n data[groupValue] = []\n}\n\nexport function group(\n values: Record<string, any>[],\n grp: string,\n keys: string[],\n leafKey: string,\n mainGrp?: string,\n mainValue?: any,\n groups: string[] = [],\n allGroups: string[] = groups,\n groupIndex = groups.length - 1\n) {\n const key = keys[0]\n const addKeys = keys.slice(1)\n const tmp: Record<string, any> = Object.create(null)\n const data: Record<string, any[]> = Object.create(null)\n const ret: Record<string, any>[] = []\n const resolvedAllGroups = allGroups.length ? allGroups : [grp]\n const resolvedGroupIndex = allGroups.length ? groupIndex : 0\n let i: number\n let n: number\n for (i = 0, n = values.length; i < n; ++i) {\n const v = values[i]\n if (mainGrp && v[mainGrp] !== mainValue) {\n continue\n }\n const itemGroup = resolveGroup(v, leafKey, resolvedAllGroups, resolvedGroupIndex)\n if (!itemGroup) {\n return []\n }\n const g = itemGroup.value\n ensureGroup(tmp, data, g, addKeys)\n tmp[g].value += +v[key]\n tmp[g].label = g\n tmp[g].group = itemGroup.group\n tmp[g].groupIndex = itemGroup.groupIndex\n const tmpRef = tmp[g]\n addKeys.forEach((k) => {\n tmpRef[k] += v[k]\n })\n tmp[g].path = getPath(resolvedAllGroups.slice(0, itemGroup.groupIndex + 1), v, g)\n data[g].push(v)\n }\n\n Object.keys(tmp).forEach((k) => {\n const v: Record<string, any> = { children: data[k] }\n v[key] = +tmp[k].value\n addKeys.forEach((ak) => {\n v[ak] = +tmp[k][ak]\n })\n v[grp] = tmp[k].label\n v.group = tmp[k].group\n v.groupIndex = tmp[k].groupIndex\n v.label = k\n v.path = tmp[k].path\n\n if (mainGrp) {\n v[mainGrp] = mainValue\n }\n ret.push(v)\n })\n\n return ret\n}\n\nexport function index(values: any[], key: string) {\n let n = values.length\n let i: number\n\n if (!n) {\n return key\n }\n\n const obj = isObject(values[0])\n key = obj ? key : 'v'\n\n for (i = 0, n = values.length; i < n; ++i) {\n if (obj) {\n values[i]._idx = i\n } else {\n values[i] = { _idx: i, v: values[i] }\n }\n }\n return key\n}\n\nexport function sort(values: any[], key?: string) {\n if (key) {\n values.sort((a, b) => +b[key] - +a[key])\n } else {\n values.sort((a, b) => +b - +a)\n }\n}\n\nexport function sum(values: any[], key?: string) {\n let s: number\n let i: number\n let n: number\n\n for (s = 0, i = 0, n = values.length; i < n; ++i) {\n s += key ? +values[i][key] : +values[i]\n }\n\n return s\n}\n\nexport function requireVersion(pkg: string, min: string, ver: string, strict = true) {\n const parts = ver.split('.')\n let i = 0\n for (const req of min.split('.')) {\n const act = parts[i++]\n if (Number.parseInt(req, 10) < Number.parseInt(act, 10)) {\n break\n }\n if (isOlderPart(act, req)) {\n if (strict) {\n throw new Error(`${pkg} v${ver} is not supported. v${min} or newer is required.`)\n } else {\n return false\n }\n }\n }\n return true\n}\n","import Rect from './rect'\nimport StatArray from './statArray'\nimport { index, sort, sum } from './utils'\n\n/**\n * Where the layout weight lives when `valueScale` is not linear. Non-enumerable\n * on the node, so `ctx.raw` keeps the shape it has always had.\n */\nexport const WEIGHT_KEY = '_weight'\n\nfunction compareAspectRatio(oldStat: any, newStat: any, args: any[]) {\n if (oldStat.sum === 0) {\n return true\n }\n\n const [length] = args\n const os2 = oldStat.nsum * oldStat.nsum\n const ns2 = newStat.nsum * newStat.nsum\n const l2 = length * length\n const or = Math.max((l2 * oldStat.nmax) / os2, os2 / (l2 * oldStat.nmin))\n const nr = Math.max((l2 * newStat.nmax) / ns2, ns2 / (l2 * newStat.nmin))\n return nr <= or\n}\n\n/**\n * Builds the nodes for one set of siblings, without any geometry.\n *\n * Everything here depends only on the data: which item a node came from, its\n * value, its group and level. The rectangle is not involved, which is what lets\n * the controller know how many elements it needs before the chart area is known.\n */\nexport function toNodes(values: any[], keys: string[], grp?: string, lvl?: number) {\n const items = values ? values.slice() : []\n const key = index(items, keys[0])\n\n return items.map((item: any) => {\n const node: any = {\n _data: values[item._idx],\n v: key ? +item[key] : +item,\n vs: undefined,\n }\n if (grp) {\n node.g = item[grp]\n node.gs = undefined\n node.l = item.groupIndex ?? lvl\n node.vs = keys.reduce<Record<string, number>>((obj, k) => {\n obj[k] = +item[k]\n return obj\n }, {})\n }\n return node\n })\n}\n\n/** Orders a set of siblings the way the layout draws them: largest first. */\nexport function sortNodes(nodes: any[], weighted = false) {\n sort(nodes, weighted ? WEIGHT_KEY : 'v')\n}\n\n/**\n * Packs already-ordered nodes into the rectangle, writing `x`, `y`, `w`, `h`,\n * the row sum `s` and the normalized area `a` onto them.\n */\nexport function packInto(nodes: any[], rectangle: any, weighted = false) {\n const n = nodes.length\n if (!n) {\n return\n }\n const key = weighted ? WEIGHT_KEY : 'v'\n const rect = new Rect(rectangle)\n const row = new StatArray(key, rect.area / sum(nodes, key))\n let length = rect.side\n let o: any\n\n for (let i = 0; i < n; ++i) {\n o = row.pushIf(nodes[i], compareAspectRatio, length)\n if (o) {\n rect.map(row)\n length = rect.side\n row.reset()\n row.push(o)\n }\n }\n if (row.length) {\n rect.map(row)\n }\n}\n\nexport default function squarify(\n values: any[],\n rectangle: any,\n keys: string[] = [],\n grp?: string,\n lvl?: number,\n gsum?: number\n) {\n const nodes = toNodes(values || [], keys, grp, lvl)\n if (grp) {\n for (const node of nodes) {\n node.gs = gsum\n }\n }\n if (!rectangle?.unsorted) {\n sortNodes(nodes)\n }\n packInto(nodes, rectangle)\n return nodes\n}\n","import { toFont } from 'chart.js/helpers'\n\nexport type Font = ReturnType<typeof toFont>\n\nexport type LabelSize = {\n height: number\n width: number\n}\n\n// Capped so a chart with many distinct labels cannot grow it without bound.\nconst WIDTH_CACHE_LIMIT = 4096\nconst widthCache = new Map<string, LabelSize>()\n\nexport const fontFor = (fonts: Font[], index: number) => fonts[Math.min(index, fonts.length - 1)]\n\nexport function measureLabelSize(\n ctx: CanvasRenderingContext2D & { _measureText?: unknown },\n lines: string[],\n fonts: Font[]\n) {\n const fontsKey = fonts.reduce((prev, item) => {\n prev += item.string\n return prev\n }, '')\n const mapKey = lines.join() + fontsKey + (ctx._measureText ? '-spriting' : '')\n let size = widthCache.get(mapKey)\n if (!size) {\n ctx.save()\n const count = lines.length\n let width = 0\n let height = 0\n for (let i = 0; i < count; i++) {\n const font = fonts[Math.min(i, fonts.length - 1)]\n ctx.font = font.string\n const text = lines[i]\n width = Math.max(width, ctx.measureText(text).width)\n height += font.lineHeight\n }\n ctx.restore()\n size = { height, width }\n if (widthCache.size >= WIDTH_CACHE_LIMIT) {\n widthCache.clear()\n }\n widthCache.set(mapKey, size)\n }\n return size\n}\n\nexport /** Measures a set of lines whose fonts are indexed by paragraph. */\nfunction measureLines(\n ctx: CanvasRenderingContext2D,\n lines: string[],\n styles: number[],\n fonts: Font[]\n): LabelSize {\n let width = 0\n let height = 0\n lines.forEach((line, i) => {\n const font = fontFor(fonts, styles[i])\n width = Math.max(width, measureLabelSize(ctx, [line], [font]).width)\n height += font.lineHeight\n })\n return { height, width }\n}\n\nexport function toFonts(fonts: Font[], fitRatio: number) {\n return fonts.map((f) => {\n const { lineHeight: _lineHeight, ...font } = f\n return toFont({ ...font, size: Math.floor(f.size * fitRatio) })\n })\n}\n","import type { Color } from 'chart.js'\nimport type { DrawRect } from '../geometry'\nimport type { TreemapLabelsOptions } from '../types'\nimport type { Font, LabelSize } from './measure'\n\nimport { fontFor } from './measure'\n\n/**\n * One block of text ready to draw: the lines, the styles they are drawn with,\n * and where the block's top edge sits. Captions and labels differ only in how\n * they arrive at this, which is why they can share the drawing code.\n */\nexport type TextBlock = {\n /** Where the block sits inside the padded rect. */\n align: CanvasTextAlign\n /** Vertical clip inset. Zero where the box was sized to hold the text. */\n clipY: number\n colors: Color[]\n fonts: Font[]\n lines: string[]\n padding: number\n /** Paragraph each line belongs to, which is what indexes fonts and colours. */\n styles: number[]\n /** How each line sits inside the block. Follows `align` when undefined. */\n textAlign: CanvasTextAlign | undefined\n top: number\n /** Width of the widest line, which is the block's own width. */\n width: number\n}\n\nexport /**\n * Text is clipped at the padding, not at the element's border (#135).\n * `overflow: 'cut'` used to run into the padding region, which made the padding\n * mean one thing for placement and nothing for clipping.\n *\n * The vertical inset is separate because a headerBoxes caption sits in a strip\n * whose height was derived from that caption's own line height. There is no\n * vertical overflow to prevent there, and insetting would slice the glyphs of\n * any font whose ascender and descender exceed its line height.\n */\nfunction clipToPadding(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n padding: number,\n clipY: number\n) {\n const x = Math.max(0, padding)\n const y = Math.max(0, clipY)\n ctx.beginPath()\n ctx.rect(rect.x + x, rect.y + y, Math.max(0, rect.w - 2 * x), Math.max(0, rect.h - 2 * y))\n ctx.clip()\n}\n\nexport function drawTextBlock(ctx: CanvasRenderingContext2D, rect: DrawRect, block: TextBlock) {\n const { align, colors, fonts, lines, padding, styles, textAlign, top, width } = block\n // `align` places the block in the rect, `textAlign` places each line in the\n // block. When they agree, which is the default, this is the same arithmetic\n // v4 did with a single x.\n const lineAlign = textAlign || align\n const x = calculateLineX(rect, align, lineAlign, padding, width)\n ctx.textAlign = lineAlign\n ctx.textBaseline = 'middle'\n let offset = 0\n lines.forEach((line, i) => {\n const style = styles[i]\n const font = fontFor(fonts, style)\n ctx.font = font.string\n ctx.fillStyle = colors[Math.min(style, colors.length - 1)]\n ctx.fillText(line, x, top + offset + font.lineHeight / 2)\n offset += font.lineHeight\n })\n}\n\nexport function calculateBlockTop(\n rect: DrawRect,\n options: TreemapLabelsOptions,\n labelSize: LabelSize\n) {\n const { position, padding } = options\n if (position === 'top') {\n return rect.y + padding\n }\n if (position === 'bottom') {\n return rect.y + rect.h - padding - labelSize.height\n }\n return rect.y + (rect.h - labelSize.height) / 2 + padding\n}\n\n/** The block's left edge inside the padded rect. */\nfunction calculateBlockLeft(\n rect: DrawRect,\n align: CanvasTextAlign,\n padding: number,\n width: number\n) {\n if (align === 'left') {\n return rect.x + padding\n }\n if (align === 'right') {\n return rect.x + rect.w - padding - width\n }\n return rect.x + (rect.w - width) / 2\n}\n\nexport /**\n * The x every line is drawn at, given the canvas `textAlign` that will be in\n * effect. When the two alignments agree this reduces to v4's single x, so the\n * default output is unchanged.\n */\nfunction calculateLineX(\n rect: DrawRect,\n align: CanvasTextAlign,\n lineAlign: CanvasTextAlign,\n padding: number,\n width: number\n) {\n if (align === lineAlign) {\n if (align === 'left') {\n return rect.x + padding\n }\n if (align === 'right') {\n return rect.x + rect.w - padding\n }\n return rect.x + rect.w / 2\n }\n const left = calculateBlockLeft(rect, align, padding, width)\n if (lineAlign === 'left') {\n return left\n }\n if (lineAlign === 'right') {\n return left + width\n }\n return left + width / 2\n}\n","import type { DrawRect } from '../geometry'\nimport type { TreemapLabelsOptions } from '../types'\nimport type { Font, LabelSize } from './measure'\n\nimport { fontFor, measureLabelSize } from './measure'\n\nexport function sliceTextToFitWidth(\n ctx: CanvasRenderingContext2D,\n text: string,\n width: number,\n fonts: Font[]\n) {\n const ellipsis = '...'\n const ellipsisWidth = measureLabelSize(ctx, [ellipsis], fonts).width\n if (ellipsisWidth >= width) {\n return ''\n }\n let lowerBoundLen = 1\n let upperBoundLen = text.length\n let currentWidth: number\n while (lowerBoundLen <= upperBoundLen) {\n const currentLen = Math.floor((lowerBoundLen + upperBoundLen) / 2)\n const currentText = text.slice(0, currentLen)\n currentWidth = measureLabelSize(ctx, [currentText], fonts).width\n if (currentWidth + ellipsisWidth > width) {\n upperBoundLen = currentLen - 1\n } else {\n lowerBoundLen = currentLen + 1\n }\n }\n const slicedText = text.slice(0, Math.max(0, lowerBoundLen - 1))\n return slicedText ? slicedText + ellipsis : ''\n}\n\nexport /**\n * Keeps as many whole lines as fit, and marks the truncation with an ellipsis:\n * on any line too wide for the box, and on the last line kept when there were\n * more below it.\n */\nfunction applyEllipsis(\n ctx: CanvasRenderingContext2D,\n lines: string[],\n styles: number[],\n fonts: Font[],\n maxWidth: number,\n maxHeight: number\n) {\n const keptLines: string[] = []\n const keptStyles: number[] = []\n let used = 0\n for (let i = 0; i < lines.length; i++) {\n const font = fontFor(fonts, styles[i])\n if (keptLines.length && used + font.lineHeight > maxHeight) {\n break\n }\n used += font.lineHeight\n keptLines.push(lines[i])\n keptStyles.push(styles[i])\n }\n\n const dropped = keptLines.length < lines.length\n const last = keptLines.length - 1\n for (let i = 0; i < keptLines.length; i++) {\n const font = fontFor(fonts, keptStyles[i])\n const tooWide = measureLabelSize(ctx, [keptLines[i]], [font]).width > maxWidth\n if (tooWide || (dropped && i === last)) {\n keptLines[i] = sliceTextToFitWidth(ctx, keptLines[i], maxWidth, [font])\n }\n }\n return { lines: keptLines, styles: keptStyles }\n}\n\nexport function labelToDraw(rect: DrawRect, options: TreemapLabelsOptions, labelSize: LabelSize) {\n const { overflow, padding } = options\n const { width, height } = labelSize\n if (overflow === 'hidden') {\n return !(width + padding * 2 > rect.w || height + padding * 2 > rect.h)\n } else if (overflow === 'fit') {\n const ratio = Math.min(rect.w / (width + padding * 2), rect.h / (height + padding * 2))\n if (ratio < 1) {\n return ratio\n }\n }\n return true\n}\n","import type { Font } from './measure'\n\nimport { isArray } from 'chart.js/helpers'\n\nimport { fontFor, measureLabelSize } from './measure'\n\nexport /**\n * Breaks one piece of text to `width`, greedily on spaces. A single word wider\n * than the width is broken by character, because leaving it to overflow would\n * defeat the point of asking for wrapping.\n */\nfunction wrapToWidth(ctx: CanvasRenderingContext2D, text: string, font: Font, width: number) {\n if (width <= 0) {\n return [text]\n }\n const fits = (value: string) => measureLabelSize(ctx, [value], [font]).width <= width\n const lines: string[] = []\n let line = ''\n\n const pushWord = (word: string) => {\n if (fits(word)) {\n line = word\n return\n }\n let chunk = ''\n for (const char of word) {\n if (chunk && !fits(chunk + char)) {\n lines.push(chunk)\n chunk = ''\n }\n chunk += char\n }\n line = chunk\n }\n\n for (const word of text.split(' ')) {\n const candidate = line ? `${line} ${word}` : word\n if (fits(candidate)) {\n line = candidate\n continue\n }\n if (line) {\n lines.push(line)\n line = ''\n }\n pushWord(word)\n }\n if (line) {\n lines.push(line)\n }\n return lines.length ? lines : ['']\n}\n\nexport /**\n * Formatter output as drawable lines.\n *\n * An array is one paragraph per entry and a string breaks on newlines, which\n * canvas would otherwise draw as a stray glyph. Colours and fonts are indexed\n * by paragraph, so a wrapped paragraph keeps one style throughout.\n */\nfunction toLines(\n ctx: CanvasRenderingContext2D,\n content: string | string[],\n fonts: Font[],\n width: number,\n wrap: boolean\n) {\n const paragraphs = (isArray(content) ? content : [content]).map((entry) => `${entry}`)\n const lines: string[] = []\n const styles: number[] = []\n\n paragraphs.forEach((paragraph, index) => {\n const font = fontFor(fonts, index)\n for (const piece of paragraph.split('\\n')) {\n for (const line of wrap ? wrapToWidth(ctx, piece, font, width) : [piece]) {\n lines.push(line)\n styles.push(index)\n }\n }\n })\n return { lines, styles }\n}\n","import type { Element } from 'chart.js'\nimport type { DrawRect } from '../geometry'\nimport type {\n TreemapCaptionsOptions,\n TreemapConfig,\n TreemapDataPoint,\n TreemapDisplayMode,\n TreemapLabelsOptions,\n TreemapLayoutOptions,\n TreemapOptions,\n TreemapScriptableContext,\n} from '../types'\nimport type { TextBlock } from './draw'\nimport type { Font } from './measure'\n\nimport { defined, isArray, isNumber, toFont, valueOrDefault } from 'chart.js/helpers'\n\nimport { calculateBlockTop, clipToPadding, drawTextBlock } from './draw'\nimport { applyEllipsis, labelToDraw, sliceTextToFitWidth } from './fit'\nimport { measureLabelSize, measureLines, toFonts } from './measure'\nimport { toLines } from './wrap'\n\ntype RectSize = {\n h: number\n w: number\n}\n\ntype RectHeight = {\n h: number\n}\n\ntype TextElement = Element<TreemapConfig, TreemapOptions> & {\n $context?: TreemapScriptableContext\n}\n\nexport function shouldDrawCaption(\n displayMode: TreemapDisplayMode,\n rect: RectSize,\n options?: Partial<TreemapCaptionsOptions>\n) {\n if (!options || options.display === false) {\n return false\n }\n if (displayMode === 'headerBoxes') {\n return true\n }\n const { w, h } = rect\n const font = toFont(options.font || {})\n const min = font.lineHeight\n const padding = Math.max(Math.min(valueOrDefault(options.padding, 3) * 2, Math.min(w, h)), 0)\n return w - padding > min && h - padding > min\n}\n\nexport function getCaptionHeight(\n displayMode: TreemapDisplayMode,\n rect: RectHeight,\n font: { lineHeight: number },\n padding: number\n) {\n if (displayMode !== 'headerBoxes') {\n return font.lineHeight + padding * 2\n }\n const captionHeight = font.lineHeight + padding * 2\n return rect.h < 2 * captionHeight ? rect.h / 3 : captionHeight\n}\n\nexport function drawText(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement,\n layout: TreemapLayoutOptions\n) {\n const { captions, labels } = options\n const { displayMode } = layout\n const isLeaf = item && (!defined(item.l) || item.isLeaf)\n\n // Resolve the text before touching the canvas. Most elements in a large\n // treemap draw no text at all, and clipping is not free: this is the\n // difference between five canvas calls per element and none.\n let block: TextBlock | undefined\n if (isLeaf) {\n if (labels.display) {\n block = labelBlock(ctx, rect, options, item, element)\n }\n } else if (shouldDrawCaption(displayMode, rect, captions)) {\n block = captionBlock(ctx, rect, options, item, element, layout)\n }\n if (!block) {\n return\n }\n\n ctx.save()\n clipToPadding(ctx, rect, block.padding, block.clipY)\n drawTextBlock(ctx, rect, block)\n ctx.restore()\n}\n\nfunction callbackContext(element: TextElement, item: TreemapDataPoint): TreemapScriptableContext {\n const context =\n element.$context ||\n ({ active: !!element.active, raw: item, type: 'data' } as TreemapScriptableContext)\n context.active = !!element.active\n context.raw = item\n return context\n}\n\nfunction resolveOption<T>(\n option: T | ((context: TreemapScriptableContext) => T) | undefined,\n context: TreemapScriptableContext\n) {\n return typeof option === 'function'\n ? (option as (context: TreemapScriptableContext) => T)(context)\n : option\n}\n\nfunction resolveCaptionText(\n captions: TreemapCaptionsOptions,\n element: TextElement,\n item: TreemapDataPoint\n) {\n return resolveOption(captions.formatter, callbackContext(element, item)) || item.g || ''\n}\n\n/** The caption's text, truncated with an ellipsis when it does not fit. */\nfunction captionText(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n captions: TreemapCaptionsOptions,\n element: TextElement,\n item: TreemapDataPoint,\n fonts: Font[]\n) {\n const text = resolveCaptionText(captions, element, item)\n if (!text) {\n return undefined\n }\n const padding = captions.padding\n if (measureLabelSize(ctx, [text], fonts).width + 2 * padding <= rect.w) {\n return text\n }\n // `ellipsis` is the default and is what v4 always did; the other modes leave\n // the clip to tell the whole story.\n const overflow = captions.overflow || 'ellipsis'\n if (overflow === 'hidden') {\n return undefined\n }\n if (overflow === 'cut') {\n return text\n }\n return sliceTextToFitWidth(ctx, text, rect.w - 2 * padding, fonts)\n}\n\nfunction captionBlock(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement,\n layout: TreemapLayoutOptions\n): TextBlock | undefined {\n const { displayMode, rtl, spacing } = layout\n const { captions } = options\n const { color, hoverColor, font, hoverFont, padding, align } = captions\n const optFont = (rect.active ? hoverFont : font) || font\n const oFont = toFont(optFont)\n if (oFont.lineHeight > rect.h) {\n return\n }\n const text = captionText(ctx, rect, captions, element, item, [oFont])\n if (text === undefined) {\n return\n }\n const fonts = [oFont]\n // A caption is a single line, centred in the header strip in headerBoxes mode\n // and sitting under the top padding otherwise.\n const top =\n displayMode === 'headerBoxes'\n ? rect.y + (rect.h - oFont.lineHeight) / 2\n : rect.y + padding + spacing\n return {\n align: align || (rtl ? 'right' : 'left'),\n clipY: displayMode === 'headerBoxes' ? 0 : padding,\n colors: [(rect.active ? hoverColor : color) || color],\n fonts,\n lines: [text],\n padding,\n styles: [0],\n textAlign: captions.textAlign,\n top,\n width: measureLabelSize(ctx, [text], fonts).width,\n }\n}\n\nfunction labelBlock(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement\n): TextBlock | undefined {\n const labels = options.labels\n const content = resolveOption(labels.formatter, callbackContext(element, item))\n if (!content) {\n return\n }\n const { align, color, hoverColor, overflow, padding, wrap } = labels\n const maxWidth = rect.w - padding * 2\n const maxHeight = rect.h - padding * 2\n\n let fonts = getFontFromOptions(rect, labels)\n let { lines, styles } = toLines(ctx, content, fonts, maxWidth, !!wrap)\n let labelSize = measureLines(ctx, lines, styles, fonts)\n\n const lblToDraw = labelToDraw(rect, labels, labelSize)\n if (!lblToDraw) {\n return\n }\n if (isNumber(lblToDraw)) {\n fonts = toFonts(fonts, lblToDraw)\n if (wrap) {\n // Shorter lines pack into fewer rows, so wrap once more at the smaller\n // size rather than iterating towards a fixed point.\n const rewrapped = toLines(ctx, content, fonts, maxWidth, true)\n lines = rewrapped.lines\n styles = rewrapped.styles\n labelSize = measureLines(ctx, lines, styles, fonts)\n } else {\n labelSize = { height: labelSize.height * lblToDraw, width: labelSize.width * lblToDraw }\n }\n }\n\n if (overflow === 'ellipsis') {\n const trimmed = applyEllipsis(ctx, lines, styles, fonts, maxWidth, maxHeight)\n lines = trimmed.lines\n styles = trimmed.styles\n labelSize = measureLines(ctx, lines, styles, fonts)\n }\n\n const optColor = (rect.active ? hoverColor : color) || color\n return {\n align,\n clipY: padding,\n colors: isArray(optColor) ? optColor : [optColor],\n fonts,\n lines,\n padding,\n styles,\n textAlign: labels.textAlign,\n top: calculateBlockTop(rect, labels, labelSize),\n width: labelSize.width,\n }\n}\n\nfunction getFontFromOptions(rect: DrawRect, labels: TreemapLabelsOptions) {\n const { font, hoverFont } = labels\n const optFont = (rect.active ? hoverFont : font) || font\n return Array.isArray(optFont) ? optFont.map((f) => toFont(f)) : [toFont(optFont)]\n}\n","import type { DrawRect } from './geometry'\nimport type {\n TreemapDataPoint,\n TreemapDisplayMode,\n TreemapOthers,\n TreemapValueScale,\n} from './types'\n\nimport { isObject, toFont, valueOrDefault } from 'chart.js/helpers'\n\nimport { parseBorderWidth } from './options'\nimport { packInto, sortNodes, toNodes, WEIGHT_KEY } from './squarify'\nimport { getCaptionHeight, shouldDrawCaption } from './text'\nimport { getGroupKey, group, normalizeTreeToArray } from './utils'\n\nexport type LayoutOptions = {\n borderWidth: any\n captions: any\n displayMode: TreemapDisplayMode\n groups: any[]\n leafKey: string\n others: false | TreemapOthers\n spacing: number\n unsorted: boolean\n valueScale: TreemapValueScale\n}\n\n/** A node while the layout is being built; `_children` is dropped before use. */\nexport type LayoutNode = TreemapDataPoint & { _children?: LayoutNode[] }\n\n/**\n * Pass one: the hierarchy.\n *\n * Groups the items level by level and orders each set of siblings. Nothing here\n * depends on the chart area, so the number of nodes and their order are known\n * before the layout has a rectangle to fill.\n */\nfunction buildHierarchy(\n values: any[],\n gidx: number,\n keys: string[],\n layout: LayoutOptions,\n weighted: boolean,\n parentGroupValue?: string\n): LayoutNode[] {\n const { groups, leafKey, unsorted } = layout\n const glen = groups.length\n const g = getGroupKey(groups[gidx])\n const gdata = group(\n values,\n g,\n keys,\n leafKey,\n undefined,\n parentGroupValue,\n groups.filter((_item: any, index: number) => index <= gidx),\n groups,\n gidx\n )\n const nodes = toNodes(gdata, keys, g, gidx) as LayoutNode[]\n\n for (const node of nodes) {\n const record = node._data as any\n const nextGroupIndex = record.groupIndex + 1\n const children =\n gidx < glen - 1 && nextGroupIndex < glen\n ? buildHierarchy(record.children, nextGroupIndex, keys, layout, weighted, node.g)\n : []\n // Non-enumerable: the geometry pass needs it on every layout, but it\n // must not show up in ctx.raw.\n Object.defineProperty(node, '_children', {\n configurable: true,\n value: children,\n writable: true,\n })\n node.isLeaf = !children.length\n }\n\n // Weights depend on the children, so they are set before the siblings are\n // ordered: a scaled group can rank differently from a raw one.\n if (weighted) {\n applyValueScale(nodes, scaleFor(layout))\n }\n const withOthers = layout.others ? applyOthers(nodes, layout.others, weighted) : nodes\n if (!unsorted) {\n sortNodes(withOthers, weighted)\n }\n return withOthers\n}\n\n/**\n * The layout weight of every node, when `valueScale` is not linear.\n *\n * A leaf's weight is its scaled value; a group's is the sum of its children's,\n * so a group still covers exactly the area its contents do. `v` is untouched:\n * tooltips, labels and `sumKeys` stay in the units the data came in.\n */\nfunction applyValueScale(nodes: LayoutNode[], scale: (value: number, item: any) => number) {\n for (const node of nodes) {\n const children = node._children\n let weight: number\n if (children?.length) {\n applyValueScale(children, scale)\n weight = children.reduce((total, child) => total + (child as any)[WEIGHT_KEY], 0)\n } else {\n const scaled = scale(node.v, node._data)\n weight = Number.isFinite(scaled) && scaled > 0 ? scaled : 0\n }\n Object.defineProperty(node, WEIGHT_KEY, { configurable: true, value: weight, writable: true })\n }\n}\n\n/**\n * Replaces the leaves too small to see with one tile that stands for all of\n * them.\n *\n * The question behind #213 is \"where did my small items go\", and a compressed\n * scale answers it by distorting the areas. This answers it by admitting the\n * items are too small and naming them instead. Groups are never bucketed: a\n * group is already a summary.\n */\nfunction applyOthers(nodes: LayoutNode[], others: TreemapOthers, weighted: boolean) {\n const { label = 'Other', minCount = 2, threshold } = others\n // A node with children is a group, and a group is already a summary.\n if (!(threshold > 0) || nodes.some((node) => node._children?.length)) {\n return nodes\n }\n\n const weightOf = (node: LayoutNode) => (weighted ? (node as any)[WEIGHT_KEY] : node.v)\n const total = nodes.reduce((sum, node) => sum + weightOf(node), 0)\n if (!(total > 0)) {\n return nodes\n }\n\n const small = nodes.filter((node) => weightOf(node) / total < threshold)\n if (small.length < Math.max(2, minCount)) {\n return nodes\n }\n\n const kept = nodes.filter((node) => !small.includes(node))\n const bucket: LayoutNode = {\n _data: { label, others: small.map((node) => node._data) },\n h: 0,\n isLeaf: true,\n isOthers: true,\n s: 0,\n v: small.reduce((sum, node) => sum + node.v, 0),\n vs: sumValues(small),\n w: 0,\n x: 0,\n y: 0,\n }\n const grouped = nodes.find((node) => node.g !== undefined)\n if (grouped) {\n bucket.g = label\n bucket.l = grouped.l\n }\n if (weighted) {\n Object.defineProperty(bucket, WEIGHT_KEY, {\n configurable: true,\n value: small.reduce((sum, node) => sum + weightOf(node), 0),\n writable: true,\n })\n }\n kept.push(bucket)\n return kept\n}\n\n/** The `sumKeys` totals of the absorbed items, so the bucket carries them too. */\nfunction sumValues(nodes: LayoutNode[]) {\n const totals: Record<string, number> = {}\n for (const node of nodes) {\n for (const [key, value] of Object.entries(node.vs || {})) {\n totals[key] = (totals[key] || 0) + (value as number)\n }\n }\n return Object.keys(totals).length ? totals : undefined\n}\n\nconst VALUE_SCALES: Record<string, (value: number) => number> = {\n log: (value) => Math.log1p(Math.max(value, 0)),\n sqrt: (value) => Math.sqrt(Math.max(value, 0)),\n}\n\n/** Draw order: a set of siblings, then the descendants of each in turn. */\nexport function flattenNodes(nodes: LayoutNode[]): LayoutNode[] {\n const flat = nodes.slice()\n for (const node of nodes) {\n if (node._children?.length) {\n flat.push(...flattenNodes(node._children))\n }\n }\n return flat\n}\n\n/**\n * Pass two: the geometry.\n *\n * Packs each set of siblings into its parent's rectangle, writing the\n * coordinates onto the nodes the first pass produced.\n */\nfunction layoutLevel(\n nodes: LayoutNode[],\n rect: any,\n layout: LayoutOptions,\n weighted: boolean,\n parentSum?: number\n) {\n if (parentSum !== undefined) {\n for (const node of nodes) {\n node.gs = parentSum\n }\n }\n packInto(nodes, rect, weighted)\n\n for (const node of nodes) {\n if (node._children?.length) {\n layoutLevel(node._children, getSubRect(node, rect, layout), layout, weighted, node.s)\n }\n }\n}\n\n/** Writes the geometry for a whole tree of nodes, then applies headerBoxes. */\nexport function layoutNodes(nodes: LayoutNode[], rect: any, layout: LayoutOptions) {\n layoutLevel(nodes, rect, layout, isWeighted(layout))\n applyHeaderBoxes(flattenNodes(nodes), layout)\n}\n\n/** Linear is the default and needs no weights, so it keeps v4's arithmetic. */\nfunction isWeighted(layout: LayoutOptions) {\n const scale = layout.valueScale\n return scale !== 'linear' && scale !== undefined\n}\n\nfunction scaleFor(layout: LayoutOptions) {\n const scale = layout.valueScale\n if (typeof scale === 'function') {\n return scale\n }\n return VALUE_SCALES[scale as string] || ((value: number) => value)\n}\n\n/** The rectangle left for a group's children once its border and caption are taken. */\nfunction getSubRect(sq: any, rect: any, layout: LayoutOptions) {\n const { borderWidth, captions, displayMode } = layout\n const sp = displayMode === 'headerBoxes' ? 0 : layout.spacing\n const bw =\n displayMode === 'headerBoxes'\n ? { b: 0, l: 0, r: 0, t: 0 }\n : parseBorderWidth(borderWidth, sq.w / 2, sq.h / 2)\n const subRect = {\n ...rect,\n h: sq.h - 2 * sp - bw.t - bw.b,\n w: sq.w - 2 * sp - bw.l - bw.r,\n x: sq.x + sp + bw.l,\n y: sq.y + sp + bw.t,\n }\n if (shouldDrawCaption(displayMode, subRect, captions)) {\n const captionHeight = getCaptionHeight(\n displayMode,\n subRect,\n toFont(captions.font),\n valueOrDefault(captions.padding, 3)\n )\n subRect.y += captionHeight\n subRect.h -= captionHeight\n }\n return subRect\n}\n\n/**\n * The hierarchy pass on its own: the nested nodes, in draw order, with no\n * geometry. Takes no rectangle, which is the whole point - the controller needs\n * the node count before the chart area is known.\n */\nexport function buildNodes(tree: any, keys: string[], layout: LayoutOptions): LayoutNode[] {\n const { groups, leafKey, unsorted } = layout\n const input = isObject(tree) ? normalizeTreeToArray(keys, leafKey, tree) : tree\n\n const weighted = isWeighted(layout)\n let nodes: LayoutNode[]\n if (groups.length) {\n nodes = buildHierarchy(input, 0, keys, layout, weighted)\n } else {\n nodes = toNodes(input || [], keys) as LayoutNode[]\n if (weighted) {\n applyValueScale(nodes, scaleFor(layout))\n }\n if (layout.others) {\n nodes = applyOthers(nodes, layout.others, weighted)\n }\n if (!unsorted) {\n sortNodes(nodes, weighted)\n }\n }\n return nodes\n}\n\n/**\n * In headerBoxes mode a group is drawn as a header strip rather than a box\n * around its children, and a group whose caption does not fit is not drawn at\n * all. It is marked hidden rather than removed: the number of parsed nodes must\n * not depend on the size of the chart area.\n */\nfunction applyHeaderBoxes(nodes: LayoutNode[], layout: LayoutOptions) {\n const { captions, displayMode } = layout\n if (displayMode !== 'headerBoxes') {\n return\n }\n const font = toFont(captions.font)\n const padding = valueOrDefault(captions.padding, 3)\n for (const node of nodes) {\n if (node.isLeaf) {\n continue\n }\n if (shouldDrawCaption(displayMode, node, captions)) {\n node.h = getCaptionHeight(displayMode, node, font, padding)\n node.hidden = false\n } else {\n node.hidden = true\n }\n }\n}\n\n/** Turns the user's input into the flat list of rectangles the chart draws. */\nexport function buildData(\n tree: any,\n keys: string[],\n mainRect: DrawRect,\n layout: LayoutOptions\n): TreemapDataPoint[] {\n const nodes = buildNodes(tree, keys, layout)\n layoutNodes(nodes, mainRect, layout)\n return flattenNodes(nodes)\n}\n","import type { LayoutNode, LayoutOptions } from './layout'\n\nimport { Chart, DatasetController, registry } from 'chart.js'\nimport { clipArea, unclipArea, valueOrDefault } from 'chart.js/helpers'\n\nimport { version } from '../package.json'\nimport { rectNotEqual, scaleRect } from './helpers/index'\nimport { buildNodes, flattenNodes, layoutNodes } from './layout'\nimport { layoutDefaults } from './options'\nimport { requireVersion } from './utils'\n\n/** Region fractions are shares of the chart area, so outside 0..1 means nothing. */\nfunction clampFraction(value: number | undefined, fallback: number) {\n return value === undefined ? fallback : Math.min(Math.max(value, 0), 1)\n}\n\nfunction registerTooltipPositioner() {\n const tooltipPlugin = registry.plugins.get('tooltip') as any\n if (!tooltipPlugin || tooltipPlugin.positioners.treemap) {\n return\n }\n tooltipPlugin.positioners.treemap = (active: any[]) => {\n if (!active.length) {\n return false\n }\n\n const item = active.at(-1)\n return item.element.tooltipPosition()\n }\n}\n\nexport default class TreemapController extends DatasetController {\n declare static readonly id: string\n declare static readonly defaults: Record<string, unknown>\n declare static readonly descriptors: Record<string, unknown>\n declare static readonly overrides: Record<string, unknown>\n declare static readonly beforeRegister: () => void\n declare static readonly afterRegister: () => void\n declare static readonly afterUnregister: () => void\n\n // Chart.js assigns this on the class when the controller is registered; its\n // type definitions do not describe it.\n declare dataElementType: new () => any\n\n options: any\n _rect: any\n _rectChanged: boolean\n _nodes: LayoutNode[]\n _regionWarned: boolean\n _layoutDirty: boolean\n _fingerprint: string | undefined\n\n constructor(chart: any, datasetIndex: number) {\n super(chart, datasetIndex)\n\n this._rect = undefined\n this._rectChanged = true\n this._regionWarned = false\n this._nodes = []\n this._layoutDirty = true\n this._fingerprint = undefined\n }\n\n override initialize() {\n // The tooltip can be registered after the treemap controller. At chart creation time all\n // components are available, so retry here to make registration order irrelevant.\n registerTooltipPositioner()\n this.enableOptionSharing = true\n super.initialize()\n }\n\n override getMinMax(scale: any) {\n return {\n max: scale.axis === 'x' ? scale.right - scale.left : scale.bottom - scale.top,\n min: 0,\n }\n }\n\n override configure() {\n super.configure()\n const { xScale, yScale } = this.getMeta() as any\n if (!xScale || !yScale) {\n // configure is called once before `linkScales`, and at that call we don't have any scales linked yet\n return\n }\n\n const w = xScale.right - xScale.left\n const h = yScale.bottom - yScale.top\n const rect = {\n ...this._regionBounds(w, h),\n rtl: !!this.options.rtl,\n unsorted: !!this.options.unsorted,\n }\n\n if (rectNotEqual(this._rect, rect)) {\n this._rect = rect\n this._rectChanged = true\n }\n\n if (this._rectChanged) {\n xScale.max = w\n xScale.configure()\n yScale.max = h\n yScale.configure()\n }\n }\n\n /**\n * The part of the chart area this dataset lays out into.\n *\n * Every dataset shares the chart's single pair of linear scales, whose max is\n * the full chart area in pixels, so a region is just a rectangle in that\n * space and no scale has to change.\n */\n _regionBounds(w: number, h: number) {\n const region = this.options.region\n if (!region) {\n return { h, w, x: 0, y: 0 }\n }\n const left = clampFraction(region.left, 0)\n const top = clampFraction(region.top, 0)\n const width = clampFraction(region.width, 1)\n const height = clampFraction(region.height, 1)\n\n if (!this._regionWarned && (left + width > 1 || top + height > 1)) {\n this._regionWarned = true\n console.warn(\n 'chartjs-chart-treemap: a dataset region reaches outside the chart area and is clipped to it.'\n )\n }\n return {\n h: h * Math.min(height, 1 - top),\n w: w * Math.min(width, 1 - left),\n x: w * left,\n y: h * top,\n }\n }\n\n /**\n * Options that shape the layout rather than a single rectangle, resolved once\n * per dataset. Reading them from `this.options` rather than from the raw\n * dataset is what makes `options.datasets.treemap` work for all of them.\n */\n _layoutOptions(): LayoutOptions {\n const dataset = this.getDataset() as any\n const options = this.options\n return {\n // Still raw: resolving these with the dataset context is feature 2's\n // change, and doing it here would move pixels in this refactor.\n borderWidth: dataset.borderWidth,\n captions: dataset.captions || {},\n displayMode: options.displayMode,\n groups: options.groups || [],\n leafKey: options.leafKey,\n others: options.others || false,\n // Deliberately NOT options.spacing. The child rectangle calculation has\n // always defaulted spacing to 0 while the drawn rectangle defaults it to\n // 0.5, so reading the resolved value here would inset every nested group\n // by an extra 0.5 and move 11 fixtures. Unifying the two is a visual\n // change that deserves its own pull request.\n spacing: valueOrDefault(dataset.spacing, 0),\n unsorted: !!options.unsorted,\n valueScale: options.valueScale || 'linear',\n }\n }\n\n /**\n * Chart.js calls this before `configure()`, so the chart area is not\n * available here - see the hierarchy pass in `./layout`, which does not need\n * one. Elements are created from the parsed nodes rather than from\n * `dataset.data`, because a treemap with groups has more rectangles than the\n * user supplied rows.\n */\n override buildOrUpdateElements(_resetNewElements?: boolean) {\n this.parse(0, 0)\n\n const meta = this.getMeta() as any\n const count = (meta._parsed as unknown[]).length\n const elements = meta.data as unknown[]\n if (elements.length > count) {\n elements.splice(count, elements.length - count)\n }\n while (elements.length < count) {\n elements.push(new this.dataElementType())\n }\n }\n\n override parse(_start: number, _count: number) {\n const dataset = this.getDataset() as any\n if (dataset.tree !== undefined) {\n throw new Error(\n 'chartjs-chart-treemap v5: the \"tree\" option was renamed to \"data\". ' +\n 'See https://chartjs-chart-treemap.pages.dev/usage/'\n )\n }\n\n const options = this.options\n const keys = [options.key || ''].concat(options.sumKeys || [])\n const nodes = buildNodes(dataset.data || [], keys, this._layoutOptions())\n const flat = flattenNodes(nodes)\n\n // A `chart.update('none')` per wheel event must not re-run the layout when\n // nothing about the data changed, so keep the previous nodes - and with\n // them their geometry - when the hierarchy is identical.\n const fingerprint = flat.map((node) => `${node.v}\\u0000${node.g}\\u0000${node.l}`).join('\\u0001')\n if (this._fingerprint === fingerprint) {\n return\n }\n\n this._fingerprint = fingerprint\n this._nodes = nodes\n ;(this.getMeta() as any)._parsed = flat\n this._layoutDirty = true\n }\n\n // `getContext` exists on DatasetController at runtime but not in its type\n // definitions, so this cannot be declared as an override.\n getContext(index: number, active?: boolean, mode?: string) {\n const base = (DatasetController.prototype as any).getContext\n const context = base.call(this, index, active, mode)\n const parsed = typeof index === 'number' ? this.getParsed(index) : undefined\n if (parsed) {\n context.raw = parsed\n context.parsed = parsed\n }\n return context\n }\n\n override getLabelAndValue(index: number) {\n const node = this.getParsed(index) as any\n if (!node) {\n return { label: '', value: '' }\n }\n const dataset = this.getDataset() as any\n const label = node.g ?? node._data?.label ?? dataset.label\n const text = label === undefined ? '' : `${label}`\n const others = node.isOthers ? node._data?.others?.length : undefined\n return {\n label: others ? `${text} (${others} items)` : text,\n value: `${node.v}`,\n }\n }\n\n override update(mode: any) {\n const { data } = this.getMeta()\n\n if (mode === 'reset') {\n // reset is called before 2nd configure and is only called if animations are enabled. So wen need an extra configure call here.\n this.configure()\n }\n\n if (this._layoutDirty || this._rectChanged) {\n layoutNodes(this._nodes, this._rect, this._layoutOptions())\n this._layoutDirty = false\n this._rectChanged = false\n }\n\n this.updateElements(data, 0, data.length, mode)\n }\n\n override updateElements(rects: any[], start: number, count: number, mode: any) {\n const reset = mode === 'reset'\n const firstOpts = this.resolveDataElementOptions(start, mode)\n this._rect.options = firstOpts\n const sharedOptions = this.getSharedOptions(firstOpts)\n const includeOptions = this.includeOptions(mode, sharedOptions || {})\n const { xScale, yScale } = this.getMeta() as any\n const spacing = this.options.spacing\n\n for (let i = start; i < start + count; i++) {\n const options = sharedOptions || this.resolveDataElementOptions(i, mode)\n const node = this.getParsed(i) as any\n const properties: any = scaleRect(node, xScale, yScale, spacing)\n properties.hidden = properties.hidden || !!node.hidden\n if (reset) {\n properties.width = 0\n properties.height = 0\n }\n\n if (includeOptions) {\n properties.options = options\n }\n this.updateElement(rects[i], i, properties, mode)\n }\n\n this.updateSharedOptions(sharedOptions || {}, mode, firstOpts)\n }\n\n override draw() {\n const { ctx, chartArea } = this.chart\n const metadata = ((this.getMeta() as any).data || []) as any[]\n const { displayMode, rtl, spacing } = this.options\n const layout = { displayMode, rtl, spacing }\n\n clipArea(ctx, chartArea)\n for (let i = 0, ilen = metadata.length; i < ilen; ++i) {\n const rect = metadata[i]\n if (!rect.hidden) {\n rect.draw(ctx, this.getParsed(i) as any, layout)\n }\n }\n unclipArea(ctx)\n }\n}\n\n;(TreemapController as any).id = 'treemap'\n\n;(TreemapController as any).version = version\n\n;(TreemapController as any).defaults = {\n animations: {\n numbers: {\n properties: ['x', 'y', 'width', 'height'],\n type: 'number',\n },\n },\n dataElementType: 'treemap',\n displayMode: layoutDefaults.displayMode,\n groups: [],\n key: '',\n leafKey: '_leaf',\n others: false,\n region: undefined,\n rtl: layoutDefaults.rtl,\n spacing: layoutDefaults.spacing,\n sumKeys: [],\n unsorted: false,\n valueScale: 'linear',\n}\n\n;(TreemapController as any).descriptors = {\n _indexable: false,\n _scriptable: true,\n captions: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n labels: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n}\n\n;(TreemapController as any).overrides = {\n hover: {},\n interaction: {\n includeInvisible: true,\n intersect: true,\n mode: 'point',\n },\n\n plugins: {\n tooltip: {\n callbacks: {\n label(item: any) {\n const node = item.parsed\n const label = node.g || node._data?.label || item.dataset.label\n return (label ? `${label}: ` : '') + node.v\n },\n title(items: any[]) {\n if (items.length) {\n const item = items[0]\n return item.dataset.key || ''\n }\n return ''\n },\n },\n intersect: true,\n position: 'treemap',\n },\n },\n scales: {\n x: {\n alignToPixels: true,\n bounds: 'data',\n display: false,\n type: 'linear',\n },\n y: {\n alignToPixels: true,\n bounds: 'data',\n display: false,\n reverse: true,\n type: 'linear',\n },\n },\n}\n\n;(TreemapController as any).beforeRegister = () => {\n requireVersion('chart.js', '4.0', Chart.version)\n}\n\n;(TreemapController as any).afterRegister = () => {\n registerTooltipPositioner()\n}\n\n;(TreemapController as any).afterUnregister = () => {\n const tooltipPlugin = registry.plugins.get('tooltip') as any\n if (tooltipPlugin) {\n delete tooltipPlugin.positioners.treemap\n }\n}\n","import type { Element } from 'chart.js'\nimport type { TreemapBorderRadius, TreemapConfig, TreemapOptions } from './types'\n\nimport { parseBorderRadius, parseBorderWidth } from './options'\n\nexport type DrawRect = {\n active?: boolean\n h: number\n radius: TreemapBorderRadius\n w: number\n x: number\n y: number\n}\n\ntype TreemapElementBase = Element<TreemapConfig, TreemapOptions>\n\nfunction getBounds(rect: TreemapElementBase, useFinalPosition?: boolean) {\n const { x, y, width, height } = rect.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return { bottom: y + height, left: x, right: x + width, top: y }\n}\n\nexport function boundingRects(rect: TreemapElementBase) {\n const bounds = getBounds(rect)\n const width = bounds.right - bounds.left\n const height = bounds.bottom - bounds.top\n const border = parseBorderWidth(rect.options.borderWidth, width / 2, height / 2)\n const radius = parseBorderRadius(rect.options.borderRadius, width / 2, height / 2)\n const outer = {\n active: rect.active,\n h: height,\n radius,\n w: width,\n x: bounds.left,\n y: bounds.top,\n }\n\n return {\n inner: {\n active: rect.active,\n h: outer.h - border.t - border.b,\n radius: {\n bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),\n bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r)),\n topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),\n topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),\n },\n w: outer.w - border.l - border.r,\n x: outer.x + border.l,\n y: outer.y + border.t,\n },\n outer,\n }\n}\n\nexport function inRange(\n rect: TreemapElementBase,\n x: number | null,\n y: number | null,\n useFinalPosition?: boolean\n) {\n const skipX = x === null\n const skipY = y === null\n const bounds = !rect || (skipX && skipY) ? false : getBounds(rect, useFinalPosition)\n\n return (\n bounds &&\n (skipX || (x >= bounds.left && x <= bounds.right)) &&\n (skipY || (y >= bounds.top && y <= bounds.bottom))\n )\n}\n\nexport function hasRadius(radius: TreemapBorderRadius) {\n return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight\n}\n\nexport function addNormalRectPath(ctx: CanvasRenderingContext2D, rect: DrawRect) {\n ctx.rect(rect.x, rect.y, rect.w, rect.h)\n}\n","import type {\n TreemapConfig,\n TreemapDataPoint,\n TreemapLayoutOptions,\n TreemapOptions,\n TreemapScriptableContext,\n} from './types'\n\nimport { Element } from 'chart.js'\nimport { addRoundedRectPath } from 'chart.js/helpers'\n\nimport { addNormalRectPath, boundingRects, hasRadius, inRange } from './geometry'\nimport { layoutDefaults } from './options'\nimport { drawText } from './text'\n\nexport default class TreemapElement extends Element<TreemapConfig, TreemapOptions> {\n static readonly id = 'treemap'\n\n static override readonly defaults = {\n borderRadius: 0,\n borderWidth: 0,\n captions: {\n align: undefined,\n color: 'black',\n display: true,\n font: {},\n formatter: (ctx: TreemapScriptableContext) => {\n const label = ctx.raw._data?.label\n return ctx.raw.g || (typeof label === 'string' ? label : '')\n },\n overflow: 'ellipsis',\n padding: 3,\n textAlign: undefined,\n },\n labels: {\n align: 'center',\n color: 'black',\n display: false,\n font: {},\n formatter(ctx: TreemapScriptableContext) {\n const label = ctx.raw._data?.label\n if (ctx.raw.g) {\n return [ctx.raw.g, `${ctx.raw.v}`]\n }\n return typeof label === 'string' ? [label, `${ctx.raw.v}`] : `${ctx.raw.v}`\n },\n overflow: 'cut',\n padding: 3,\n position: 'middle',\n textAlign: undefined,\n wrap: false,\n },\n }\n\n static readonly descriptors = {\n _indexable: false,\n _scriptable: true,\n captions: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n labels: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n }\n\n static override readonly defaultRoutes = {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor',\n }\n\n $context?: TreemapScriptableContext\n width: number | undefined\n height: number | undefined\n\n constructor(cfg?: Partial<TreemapConfig> & { options?: TreemapOptions }) {\n super()\n\n this.width = undefined\n this.height = undefined\n\n if (cfg) {\n Object.assign(this, cfg)\n }\n }\n\n draw(\n ctx: CanvasRenderingContext2D,\n data?: TreemapDataPoint,\n layout: TreemapLayoutOptions = layoutDefaults\n ) {\n if (!data) {\n return\n }\n const options = this.options\n const { inner, outer } = boundingRects(this)\n const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath\n\n ctx.save()\n\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath()\n addRectPath(ctx, outer)\n ctx.clip()\n addRectPath(ctx, inner)\n ctx.fillStyle = options.borderColor\n ctx.fill('evenodd')\n }\n\n ctx.beginPath()\n addRectPath(ctx, inner)\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n\n drawText(ctx, inner, options, data, this, layout)\n ctx.restore()\n }\n\n inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, mouseY, useFinalPosition)\n }\n\n inXRange(mouseX: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, null, useFinalPosition)\n }\n\n inYRange(mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, null, mouseY, useFinalPosition)\n }\n\n getCenterPoint(useFinalPosition?: boolean) {\n const { x, y, width, height } = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return {\n x: x + width / 2,\n y: y + height / 2,\n }\n }\n\n override tooltipPosition() {\n return this.getCenterPoint()\n }\n}\n","import { Chart } from 'chart.js'\n\nimport TreemapController from './controller'\nimport TreemapElement from './element'\n\nChart.register(TreemapController as any, TreemapElement as any)\n\nexport type {\n LabelAlign,\n LabelOverflow,\n LabelPosition,\n TreemapConfig,\n TreemapControllerDatasetOptions,\n TreemapDataPoint,\n TreemapElement as TreemapElementType,\n TreemapOptions,\n} from './types'\n\nexport * from './utils'\nexport { TreemapController, TreemapElement }\n"],"names":["scaleRect","sq","xScale","yScale","sp","sp2","x","getPixelForValue","y","w","h","height","hidden","width","layoutDefaults","displayMode","rtl","spacing","limit","value","min","max","Math","parseBorderWidth","maxW","maxH","o","toTRBL","b","bottom","l","left","r","right","t","top","getDims","itm","w2","s2","key","a","_normalized","d1","d2","ar","sqrt","assignRow","rect","dims","sum","s","iw","_ix","getX","_iy","Rect","area","this","ih","dir","side","map","arr","nsum","row","get","maxd2","totd1","constructor","unsorted","getNewStat","sa","v","n","ratio","nmax","nmin","push","stat","_arr","Object","assign","setStat","StatArray","length","reset","_hist","Infinity","pushIf","fn","args","nstat","isOlderPart","act","req","startsWith","getGroupKey","lvl","String","hasGroupValue","scanTreeObject","keys","leafKey","obj","tree","result","objIndex","record","reduce","reduced","item","i","forEach","k","childKey","child","isObject","splice","normalizeTreeToArray","data","maxVal","element","ikeys","groupKey","getPath","groups","defaultValue","path","grp","join","resolveGroup","allGroups","groupIndex","idx","group","ensureGroup","tmp","groupValue","addKeys","tmpRef","values","mainGrp","mainValue","slice","create","ret","resolvedAllGroups","resolvedGroupIndex","itemGroup","g","label","children","ak","index","_idx","sort","requireVersion","pkg","ver","strict","parts","split","Number","parseInt","Error","WEIGHT_KEY","compareAspectRatio","oldStat","newStat","os2","ns2","l2","or","toNodes","items","node","_data","vs","undefined","gs","sortNodes","nodes","weighted","widthCache","Map","fontFor","fonts","measureLabelSize","ctx","lines","fontsKey","prev","string","mapKey","_measureText","size","save","count","font","text","measureText","lineHeight","restore","clear","set","measureLines","styles","line","drawTextBlock","block","align","colors","padding","textAlign","lineAlign","calculateBlockLeft","calculateLineX","textBaseline","offset","style","fillStyle","fillText","calculateBlockTop","options","labelSize","position","sliceTextToFitWidth","ellipsisWidth","currentWidth","lowerBoundLen","upperBoundLen","currentLen","floor","slicedText","wrapToWidth","fits","pushWord","word","chunk","char","candidate","toLines","content","wrap","paragraphs","isArray","entry","paragraph","piece","shouldDrawCaption","display","toFont","valueOrDefault","getCaptionHeight","captionHeight","drawText","layout","captions","labels","defined","isLeaf","resolveOption","formatter","callbackContext","color","hoverColor","overflow","maxWidth","maxHeight","hoverFont","optFont","active","Array","f","getFontFromOptions","lblToDraw","labelToDraw","isNumber","fitRatio","_lineHeight","toFonts","rewrapped","trimmed","keptLines","keptStyles","used","dropped","last","applyEllipsis","optColor","clipY","labelBlock","oFont","resolveCaptionText","captionText","captionBlock","beginPath","clip","clipToPadding","context","$context","raw","type","option","buildHierarchy","gidx","parentGroupValue","glen","gdata","filter","_item","nextGroupIndex","defineProperty","configurable","writable","applyValueScale","scaleFor","withOthers","others","applyOthers","scale","_children","weight","total","scaled","isFinite","minCount","threshold","some","weightOf","small","kept","includes","bucket","isOthers","sumValues","grouped","find","totals","entries","VALUE_SCALES","log","log1p","flattenNodes","flat","layoutLevel","parentSum","rectangle","packInto","getSubRect","layoutNodes","isWeighted","applyHeaderBoxes","valueScale","borderWidth","bw","subRect","buildNodes","input","clampFraction","fallback","registerTooltipPositioner","tooltipPlugin","registry","plugins","positioners","treemap","at","tooltipPosition","TreemapController","DatasetController","initialize","enableOptionSharing","super","getMinMax","axis","configure","getMeta","_regionBounds","r1","r2","_rect","_rectChanged","region","_regionWarned","console","warn","_layoutOptions","dataset","getDataset","buildOrUpdateElements","_resetNewElements","parse","meta","_parsed","elements","dataElementType","_start","_count","concat","sumKeys","fingerprint","_fingerprint","_nodes","_layoutDirty","getContext","mode","prototype","call","parsed","getParsed","getLabelAndValue","update","updateElements","rects","start","firstOpts","resolveDataElementOptions","sharedOptions","getSharedOptions","includeOptions","properties","updateElement","updateSharedOptions","draw","chartArea","chart","metadata","clipArea","ilen","unclipArea","datasetIndex","getBounds","useFinalPosition","getProps","boundingRects","bounds","border","radius","toTRBLCorners","maxR","bottomLeft","bottomRight","topLeft","topRight","parseBorderRadius","borderRadius","outer","inner","inRange","skipX","skipY","addNormalRectPath","id","version","defaults","animations","numbers","descriptors","_indexable","_scriptable","_fallback","name","overrides","hover","interaction","includeInvisible","intersect","tooltip","callbacks","title","scales","alignToPixels","reverse","beforeRegister","Chart","afterRegister","afterUnregister","TreemapElement","Element","addRectPath","addRoundedRectPath","borderColor","fill","backgroundColor","mouseX","mouseY","inXRange","inYRange","getCenterPoint","cfg","defaultRoutes","register","stack","res","next","pop"],"mappings":";;;;;;yWAAO,SAASA,EAAUC,EAASC,EAAaC,EAAaC,GAC3D,MAAMC,EAAW,EAALD,EACNE,EAAIJ,EAAOK,iBAAiBN,EAAGK,GAC/BE,EAAIL,EAAOI,iBAAiBN,EAAGO,GAC/BC,EAAIP,EAAOK,iBAAiBN,EAAGK,EAAIL,EAAGQ,GAAKH,EAC3CI,EAAIP,EAAOI,iBAAiBN,EAAGO,EAAIP,EAAGS,GAAKF,EACjD,MAAO,CACLG,OAAQD,EAAIL,EACZO,OAAQP,EAAMI,GAAKJ,EAAMK,EACzBG,MAAOJ,EAAIJ,EACXC,EAAGA,EAAIF,EACPI,EAAGA,EAAIJ,EAEX,CCCO,MAAMU,EAAuC,CAClDC,YAAa,iBACbC,KAAK,EACLC,QAAS,IAUX,SAASC,EAAMC,EAAeC,EAAaC,GACzC,OAAOC,KAAKD,IAAIC,KAAKF,IAAID,EAAOE,GAAMD,EACxC,CAEO,SAASG,EACdJ,EACAK,EACAC,GAEA,MAAMC,EAAIC,EAAAA,OAAOR,GAEjB,MAAO,CACLS,EAAGV,EAAMQ,EAAEG,OAAQ,EAAG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yDX0ElC,SAAiBxH,GACtB,MAAMuI,EAAQ,IAAIvI,GACZwI,EAAM,GACZ,KAAOD,EAAMzZ,QAAQ,CAEnB,MAAM2Z,EAAOF,EAAMG,MACfhO,MAAM3B,QAAQ0P,GAEhBF,EAAMha,QAAQka,GAEdD,EAAIja,KAAKka,EAEb,CAEA,OAAOD,EAAIrB,SACb,gBA1CO,SAAoCjX,EAAiBH,EAAgBC,GAC1E,OAAOgB,EAAqBjB,EAAMC,EAASE,EAC7C"}
|
|
1
|
+
{"version":3,"file":"chartjs-chart-treemap.min.js","sources":["../src/helpers/index.ts","../src/options.ts","../src/rect.ts","../src/statArray.ts","../src/utils.ts","../src/squarify.ts","../src/text/measure.ts","../src/text/draw.ts","../src/text/fit.ts","../src/text/wrap.ts","../src/text/index.ts","../src/layout.ts","../src/controller.ts","../src/geometry.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["export function scaleRect(sq: any, xScale: any, yScale: any, sp: number) {\n const sp2 = sp * 2\n const x = xScale.getPixelForValue(sq.x)\n const y = yScale.getPixelForValue(sq.y)\n const w = xScale.getPixelForValue(sq.x + sq.w) - x\n const h = yScale.getPixelForValue(sq.y + sq.h) - y\n return {\n height: h - sp2,\n hidden: sp2 > w || sp2 > h,\n width: w - sp2,\n x: x + sp,\n y: y + sp,\n }\n}\n\nexport function rectNotEqual(r1: any, r2: any) {\n return (\n !r1 ||\n !r2 ||\n r1.x !== r2.x ||\n r1.y !== r2.y ||\n r1.w !== r2.w ||\n r1.h !== r2.h ||\n r1.rtl !== r2.rtl ||\n r1.unsorted !== r2.unsorted\n )\n}\n\nexport function arrayNotEqual(a: any[], b: any[]) {\n let i: number\n let n: number\n\n if (!a || !b) {\n return true\n }\n\n if (a === b) {\n return false\n }\n\n if (a.length !== b.length) {\n return true\n }\n\n for (i = 0, n = a.length; i < n; ++i) {\n if (a[i] !== b[i]) {\n return true\n }\n }\n return false\n}\n","import type {\n TreemapBorderRadius,\n TreemapBorderWidth,\n TreemapLayoutOptions,\n TreemapOptions,\n} from './types.js'\n\nimport { toTRBL, toTRBLCorners } from 'chart.js/helpers'\n\n/**\n * Options that shape the whole dataset's layout rather than a single element.\n * They live in the controller's defaults; the element receives the resolved\n * values as an argument to `draw`.\n */\nexport const layoutDefaults: TreemapLayoutOptions = {\n displayMode: 'containerBoxes',\n rtl: false,\n spacing: 0.5,\n}\n\nexport type ParsedBorderWidth = {\n b: number\n l: number\n r: number\n t: number\n}\n\nfunction limit(value: number, min: number, max: number) {\n return Math.max(Math.min(value, max), min)\n}\n\nexport function parseBorderWidth(\n value: TreemapBorderWidth,\n maxW: number,\n maxH: number\n): ParsedBorderWidth {\n const o = toTRBL(value as Parameters<typeof toTRBL>[0])\n\n return {\n b: limit(o.bottom, 0, maxH),\n l: limit(o.left, 0, maxW),\n r: limit(o.right, 0, maxW),\n t: limit(o.top, 0, maxH),\n }\n}\n\nexport function parseBorderRadius(\n value: TreemapOptions['borderRadius'],\n maxW: number,\n maxH: number\n): TreemapBorderRadius {\n const o = toTRBLCorners(value as Parameters<typeof toTRBLCorners>[0])\n const maxR = Math.min(maxW, maxH)\n\n return {\n bottomLeft: limit(o.bottomLeft, 0, maxR),\n bottomRight: limit(o.bottomRight, 0, maxR),\n topLeft: limit(o.topLeft, 0, maxR),\n topRight: limit(o.topRight, 0, maxR),\n }\n}\n","function getDims(itm: any, w2: number, s2: number, key: string) {\n const a = itm._normalized\n if (!a) {\n // A zero-area item would divide by its own zero side and produce NaN\n // coordinates. It has nothing to draw, so give it nothing.\n return { d1: 0, d2: 0, h: 0, w: 0 }\n }\n const ar = (w2 * a) / s2\n const d1 = Math.sqrt(a * ar)\n const d2 = a / d1\n const w = key === '_ix' ? d1 : d2\n const h = key === '_ix' ? d2 : d1\n\n return { d1, d2, h, w }\n}\n\nconst getX = (rect: Rect, w: number) => (rect.rtl ? rect.x + rect.iw - w : rect.x + rect._ix)\n\n/** Writes the geometry of one packed row onto the nodes themselves. */\nfunction assignRow(rect: Rect, itm: any, dims: any, sum: number) {\n itm.a = itm._normalized\n itm.h = dims.h\n itm.s = sum\n itm.w = dims.w\n itm.x = getX(rect, dims.w)\n itm.y = rect.y + rect._iy\n delete itm._normalized\n}\n\nexport default class Rect {\n [key: string]: any\n rtl: boolean\n unsorted: boolean\n x: number\n y: number\n _ix: number\n _iy: number\n w: number\n h: number\n\n constructor(r?: any) {\n r = r || { h: 1, w: 1 }\n this.rtl = !!r.rtl\n this.unsorted = !!r.unsorted\n this.x = r.x || r.left || 0\n this.y = r.y || r.top || 0\n this._ix = 0\n this._iy = 0\n this.w = r.w || r.width || r.right - r.left\n this.h = r.h || r.height || r.bottom - r.top\n }\n\n get area() {\n return this.w * this.h\n }\n\n get iw() {\n return this.w - this._ix\n }\n\n get ih() {\n return this.h - this._iy\n }\n\n get dir() {\n const ih = this.ih\n return ih <= this.iw && ih > 0 ? 'y' : 'x'\n }\n\n get side() {\n return this.dir === 'x' ? this.iw : this.ih\n }\n\n map(arr: any) {\n const { dir, side } = this\n const key = dir === 'x' ? '_ix' : '_iy'\n const sum = arr.nsum\n const row = arr.get()\n const w2 = side * side\n const s2 = sum * sum\n let maxd2 = 0\n let totd1 = 0\n for (const itm of row) {\n const dims = getDims(itm, w2, s2, key)\n totd1 += dims.d1\n maxd2 = Math.max(maxd2, dims.d2)\n assignRow(this, itm, dims, arr.sum)\n this[key] += dims.d1\n }\n\n this[dir === 'x' ? '_iy' : '_ix'] += maxd2\n this[key] -= totd1\n }\n}\n","const min = Math.min\nconst max = Math.max\n\nfunction getStat(sa: StatArray) {\n return {\n max: sa.max,\n min: sa.min,\n nmax: sa.nmax,\n nmin: sa.nmin,\n nsum: sa.nsum,\n sum: sa.sum,\n }\n}\n\nfunction getNewStat(sa: StatArray, o: any) {\n const v = +o[sa.key]\n const n = v * sa.ratio\n o._normalized = n\n\n return {\n max: max(sa.max, v),\n min: min(sa.min, v),\n nmax: max(sa.nmax, n),\n nmin: min(sa.nmin, n),\n nsum: sa.nsum + n,\n sum: sa.sum + v,\n }\n}\n\nfunction setStat(sa: StatArray, stat: any) {\n Object.assign(sa, stat)\n}\n\nfunction push(sa: StatArray, o: any, stat: any) {\n sa._arr.push(o)\n setStat(sa, stat)\n}\n\nexport default class StatArray {\n key: string\n ratio: number\n _arr: any[] = []\n _hist: any[] = []\n sum = 0\n nsum = 0\n min = Infinity\n max = -Infinity\n nmin = Infinity\n nmax = -Infinity\n\n constructor(key: string, ratio: number) {\n this.key = key\n this.ratio = ratio\n this.reset()\n }\n\n get length() {\n return this._arr.length\n }\n\n reset() {\n this._arr = []\n this._hist = []\n this.sum = 0\n this.nsum = 0\n this.min = Infinity\n this.max = -Infinity\n this.nmin = Infinity\n this.nmax = -Infinity\n }\n\n push(o: any) {\n push(this, o, getNewStat(this, o))\n }\n\n pushIf(o: any, fn: any, ...args: any[]) {\n const nstat = getNewStat(this, o)\n if (!fn(getStat(this), nstat, args)) {\n return o\n }\n push(this, o, nstat)\n }\n\n get() {\n return this._arr\n }\n}\n","import type { AnyObject } from './types.js'\n\nimport { isObject } from 'chart.js/helpers'\n\nconst isOlderPart = (act: string, req: string) =>\n req > act || (act.length > req.length && act.startsWith(req))\n\nexport const getGroupKey = (lvl: unknown) => String(lvl)\n\nconst hasGroupValue = (value: unknown) => value !== undefined && value !== null && value !== ''\n\nfunction scanTreeObject(\n keys: string[],\n leafKey: string,\n obj: Record<string, any>,\n tree: string[] = [],\n lvl = 0,\n result: Record<string, any>[] = []\n) {\n const objIndex = lvl - 1\n if (keys[0] in obj && lvl > 0) {\n const record = tree.reduce<Record<string, any>>((reduced, item, i) => {\n if (i !== objIndex) {\n reduced[getGroupKey(i)] = item\n }\n return reduced\n }, {})\n record[leafKey] = tree[objIndex]\n keys.forEach((k) => {\n record[k] = obj[k]\n })\n result.push(record)\n } else {\n for (const childKey of Object.keys(obj)) {\n const child = obj[childKey]\n if (isObject(child)) {\n tree.push(childKey)\n scanTreeObject(keys, leafKey, child, tree, lvl + 1, result)\n }\n }\n }\n tree.splice(objIndex, 1)\n return result\n}\n\n/**\n * Flattens a nested object into the array form of `data`.\n *\n * The controller does this at runtime, so JavaScript configurations never need\n * it. TypeScript users who would rather pass an array than a generic can call\n * it up front.\n */\nexport function flattenTree<T = AnyObject>(tree: AnyObject, keys: string[], leafKey: string): T[] {\n return normalizeTreeToArray(keys, leafKey, tree) as T[]\n}\n\nexport function normalizeTreeToArray(keys: string[], leafKey: string, obj: Record<string, any>) {\n const data = scanTreeObject(keys, leafKey, obj)\n if (!data.length) {\n return data\n }\n const max = data.reduce((maxVal, element) => {\n // minus 2 because _leaf and value properties are added\n // on top to groups ones\n const ikeys = Object.keys(element).length - 2\n return Math.max(maxVal, ikeys)\n }, 0)\n data.forEach((element) => {\n for (let i = 0; i < max; i++) {\n const groupKey = getGroupKey(i)\n if (!element[groupKey]) {\n element[groupKey] = ''\n }\n }\n })\n return data\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat\nexport function flatten(input: any[]) {\n const stack = [...input]\n const res = []\n while (stack.length) {\n // pop value from stack\n const next = stack.pop()\n if (Array.isArray(next)) {\n // push back array items, won't modify the original input\n stack.push(...next)\n } else {\n res.push(next)\n }\n }\n // reverse to restore input order\n return res.reverse()\n}\n\nfunction getPath(groups: string[], value: Record<string, any>, defaultValue: string) {\n const path = []\n for (const grp of groups) {\n const item = value[grp]\n if (!hasGroupValue(item)) {\n continue\n }\n path.push(item)\n }\n return path.length ? path.join('.') : defaultValue\n}\n\nfunction resolveGroup(\n value: Record<string, any>,\n leafKey: string,\n allGroups: string[],\n groupIndex: number\n) {\n for (let idx = groupIndex; idx < allGroups.length; idx++) {\n const groupKey = getGroupKey(allGroups[idx])\n if (hasGroupValue(value[groupKey])) {\n return { group: groupKey, groupIndex: idx, value: value[groupKey] }\n }\n }\n if (hasGroupValue(value[leafKey])) {\n return { group: leafKey, groupIndex, value: value[leafKey] }\n }\n return undefined\n}\n\nfunction ensureGroup(\n tmp: Record<string, any>,\n data: Record<string, any[]>,\n groupValue: string,\n addKeys: string[]\n) {\n if (groupValue in tmp) {\n return\n }\n tmp[groupValue] = { value: 0 }\n const tmpRef = tmp[groupValue]\n addKeys.forEach((k) => {\n tmpRef[k] = 0\n })\n data[groupValue] = []\n}\n\nexport function group(\n values: Record<string, any>[],\n grp: string,\n keys: string[],\n leafKey: string,\n mainGrp?: string,\n mainValue?: any,\n groups: string[] = [],\n allGroups: string[] = groups,\n groupIndex = groups.length - 1\n) {\n const key = keys[0]\n const addKeys = keys.slice(1)\n const tmp: Record<string, any> = Object.create(null)\n const data: Record<string, any[]> = Object.create(null)\n const ret: Record<string, any>[] = []\n const resolvedAllGroups = allGroups.length ? allGroups : [grp]\n const resolvedGroupIndex = allGroups.length ? groupIndex : 0\n let i: number\n let n: number\n for (i = 0, n = values.length; i < n; ++i) {\n const v = values[i]\n if (mainGrp && v[mainGrp] !== mainValue) {\n continue\n }\n const itemGroup = resolveGroup(v, leafKey, resolvedAllGroups, resolvedGroupIndex)\n if (!itemGroup) {\n return []\n }\n const g = itemGroup.value\n ensureGroup(tmp, data, g, addKeys)\n tmp[g].value += +v[key]\n tmp[g].label = g\n tmp[g].group = itemGroup.group\n tmp[g].groupIndex = itemGroup.groupIndex\n const tmpRef = tmp[g]\n addKeys.forEach((k) => {\n tmpRef[k] += v[k]\n })\n tmp[g].path = getPath(resolvedAllGroups.slice(0, itemGroup.groupIndex + 1), v, g)\n data[g].push(v)\n }\n\n Object.keys(tmp).forEach((k) => {\n const v: Record<string, any> = { children: data[k] }\n v[key] = +tmp[k].value\n addKeys.forEach((ak) => {\n v[ak] = +tmp[k][ak]\n })\n v[grp] = tmp[k].label\n v.group = tmp[k].group\n v.groupIndex = tmp[k].groupIndex\n v.label = k\n v.path = tmp[k].path\n\n if (mainGrp) {\n v[mainGrp] = mainValue\n }\n ret.push(v)\n })\n\n return ret\n}\n\nexport function index(values: any[], key: string) {\n let n = values.length\n let i: number\n\n if (!n) {\n return key\n }\n\n const obj = isObject(values[0])\n key = obj ? key : 'v'\n\n for (i = 0, n = values.length; i < n; ++i) {\n if (obj) {\n values[i]._idx = i\n } else {\n values[i] = { _idx: i, v: values[i] }\n }\n }\n return key\n}\n\nexport function sort(values: any[], key?: string) {\n if (key) {\n values.sort((a, b) => +b[key] - +a[key])\n } else {\n values.sort((a, b) => +b - +a)\n }\n}\n\nexport function sum(values: any[], key?: string) {\n let s: number\n let i: number\n let n: number\n\n for (s = 0, i = 0, n = values.length; i < n; ++i) {\n s += key ? +values[i][key] : +values[i]\n }\n\n return s\n}\n\nexport function requireVersion(pkg: string, min: string, ver: string, strict = true) {\n const parts = ver.split('.')\n let i = 0\n for (const req of min.split('.')) {\n const act = parts[i++]\n if (Number.parseInt(req, 10) < Number.parseInt(act, 10)) {\n break\n }\n if (isOlderPart(act, req)) {\n if (strict) {\n throw new Error(`${pkg} v${ver} is not supported. v${min} or newer is required.`)\n } else {\n return false\n }\n }\n }\n return true\n}\n","import Rect from './rect.js'\nimport StatArray from './statArray.js'\nimport { index, sort, sum } from './utils.js'\n\n/**\n * Where the layout weight lives when `valueScale` is not linear. Non-enumerable\n * on the node, so `ctx.raw` keeps the shape it has always had.\n */\nexport const WEIGHT_KEY = '_weight'\n\nfunction compareAspectRatio(oldStat: any, newStat: any, args: any[]) {\n if (oldStat.sum === 0) {\n return true\n }\n\n const [length] = args\n const os2 = oldStat.nsum * oldStat.nsum\n const ns2 = newStat.nsum * newStat.nsum\n const l2 = length * length\n const or = Math.max((l2 * oldStat.nmax) / os2, os2 / (l2 * oldStat.nmin))\n const nr = Math.max((l2 * newStat.nmax) / ns2, ns2 / (l2 * newStat.nmin))\n return nr <= or\n}\n\n/**\n * Builds the nodes for one set of siblings, without any geometry.\n *\n * Everything here depends only on the data: which item a node came from, its\n * value, its group and level. The rectangle is not involved, which is what lets\n * the controller know how many elements it needs before the chart area is known.\n */\nexport function toNodes(values: any[], keys: string[], grp?: string, lvl?: number) {\n const items = values ? values.slice() : []\n const key = index(items, keys[0])\n\n return items.map((item: any) => {\n const node: any = {\n _data: values[item._idx],\n v: key ? +item[key] : +item,\n vs: undefined,\n }\n if (grp) {\n node.g = item[grp]\n node.gs = undefined\n node.l = item.groupIndex ?? lvl\n node.vs = keys.reduce<Record<string, number>>((obj, k) => {\n obj[k] = +item[k]\n return obj\n }, {})\n }\n return node\n })\n}\n\n/** Orders a set of siblings the way the layout draws them: largest first. */\nexport function sortNodes(nodes: any[], weighted = false) {\n sort(nodes, weighted ? WEIGHT_KEY : 'v')\n}\n\n/**\n * Packs already-ordered nodes into the rectangle, writing `x`, `y`, `w`, `h`,\n * the row sum `s` and the normalized area `a` onto them.\n */\nexport function packInto(nodes: any[], rectangle: any, weighted = false) {\n const n = nodes.length\n if (!n) {\n return\n }\n const key = weighted ? WEIGHT_KEY : 'v'\n const rect = new Rect(rectangle)\n const row = new StatArray(key, rect.area / sum(nodes, key))\n let length = rect.side\n let o: any\n\n for (let i = 0; i < n; ++i) {\n o = row.pushIf(nodes[i], compareAspectRatio, length)\n if (o) {\n rect.map(row)\n length = rect.side\n row.reset()\n row.push(o)\n }\n }\n if (row.length) {\n rect.map(row)\n }\n}\n\nexport default function squarify(\n values: any[],\n rectangle: any,\n keys: string[] = [],\n grp?: string,\n lvl?: number,\n gsum?: number\n) {\n const nodes = toNodes(values || [], keys, grp, lvl)\n if (grp) {\n for (const node of nodes) {\n node.gs = gsum\n }\n }\n if (!rectangle?.unsorted) {\n sortNodes(nodes)\n }\n packInto(nodes, rectangle)\n return nodes\n}\n","import { toFont } from 'chart.js/helpers'\n\nexport type Font = ReturnType<typeof toFont>\n\nexport type LabelSize = {\n height: number\n width: number\n}\n\n// Capped so a chart with many distinct labels cannot grow it without bound.\nconst WIDTH_CACHE_LIMIT = 4096\nconst widthCache = new Map<string, LabelSize>()\n\nexport const fontFor = (fonts: Font[], index: number) => fonts[Math.min(index, fonts.length - 1)]\n\nexport function measureLabelSize(\n ctx: CanvasRenderingContext2D & { _measureText?: unknown },\n lines: string[],\n fonts: Font[]\n) {\n const fontsKey = fonts.reduce((prev, item) => {\n prev += item.string\n return prev\n }, '')\n const mapKey = lines.join() + fontsKey + (ctx._measureText ? '-spriting' : '')\n let size = widthCache.get(mapKey)\n if (!size) {\n ctx.save()\n const count = lines.length\n let width = 0\n let height = 0\n for (let i = 0; i < count; i++) {\n const font = fonts[Math.min(i, fonts.length - 1)]\n ctx.font = font.string\n const text = lines[i]\n width = Math.max(width, ctx.measureText(text).width)\n height += font.lineHeight\n }\n ctx.restore()\n size = { height, width }\n if (widthCache.size >= WIDTH_CACHE_LIMIT) {\n widthCache.clear()\n }\n widthCache.set(mapKey, size)\n }\n return size\n}\n\nexport /** Measures a set of lines whose fonts are indexed by paragraph. */\nfunction measureLines(\n ctx: CanvasRenderingContext2D,\n lines: string[],\n styles: number[],\n fonts: Font[]\n): LabelSize {\n let width = 0\n let height = 0\n lines.forEach((line, i) => {\n const font = fontFor(fonts, styles[i])\n width = Math.max(width, measureLabelSize(ctx, [line], [font]).width)\n height += font.lineHeight\n })\n return { height, width }\n}\n\nexport function toFonts(fonts: Font[], fitRatio: number) {\n return fonts.map((f) => {\n const { lineHeight: _lineHeight, ...font } = f\n return toFont({ ...font, size: Math.floor(f.size * fitRatio) })\n })\n}\n","import type { Color } from 'chart.js'\nimport type { DrawRect } from '../geometry.js'\nimport type { TreemapLabelsOptions } from '../types.js'\nimport type { Font, LabelSize } from './measure.js'\n\nimport { fontFor } from './measure.js'\n\n/**\n * One block of text ready to draw: the lines, the styles they are drawn with,\n * and where the block's top edge sits. Captions and labels differ only in how\n * they arrive at this, which is why they can share the drawing code.\n */\nexport type TextBlock = {\n /** Where the block sits inside the padded rect. */\n align: CanvasTextAlign\n /** Vertical clip inset. Zero where the box was sized to hold the text. */\n clipY: number\n colors: Color[]\n fonts: Font[]\n lines: string[]\n padding: number\n /** Paragraph each line belongs to, which is what indexes fonts and colours. */\n styles: number[]\n /** How each line sits inside the block. Follows `align` when undefined. */\n textAlign: CanvasTextAlign | undefined\n top: number\n /** Width of the widest line, which is the block's own width. */\n width: number\n}\n\nexport /**\n * Text is clipped at the padding, not at the element's border (#135).\n * `overflow: 'cut'` used to run into the padding region, which made the padding\n * mean one thing for placement and nothing for clipping.\n *\n * The vertical inset is separate because a headerBoxes caption sits in a strip\n * whose height was derived from that caption's own line height. There is no\n * vertical overflow to prevent there, and insetting would slice the glyphs of\n * any font whose ascender and descender exceed its line height.\n */\nfunction clipToPadding(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n padding: number,\n clipY: number\n) {\n const x = Math.max(0, padding)\n const y = Math.max(0, clipY)\n ctx.beginPath()\n ctx.rect(rect.x + x, rect.y + y, Math.max(0, rect.w - 2 * x), Math.max(0, rect.h - 2 * y))\n ctx.clip()\n}\n\nexport function drawTextBlock(ctx: CanvasRenderingContext2D, rect: DrawRect, block: TextBlock) {\n const { align, colors, fonts, lines, padding, styles, textAlign, top, width } = block\n // `align` places the block in the rect, `textAlign` places each line in the\n // block. When they agree, which is the default, this is the same arithmetic\n // v4 did with a single x.\n const lineAlign = textAlign || align\n const x = calculateLineX(rect, align, lineAlign, padding, width)\n ctx.textAlign = lineAlign\n ctx.textBaseline = 'middle'\n let offset = 0\n lines.forEach((line, i) => {\n const style = styles[i]\n const font = fontFor(fonts, style)\n ctx.font = font.string\n ctx.fillStyle = colors[Math.min(style, colors.length - 1)]\n ctx.fillText(line, x, top + offset + font.lineHeight / 2)\n offset += font.lineHeight\n })\n}\n\nexport function calculateBlockTop(\n rect: DrawRect,\n options: TreemapLabelsOptions,\n labelSize: LabelSize\n) {\n const { position, padding } = options\n if (position === 'top') {\n return rect.y + padding\n }\n if (position === 'bottom') {\n return rect.y + rect.h - padding - labelSize.height\n }\n return rect.y + (rect.h - labelSize.height) / 2 + padding\n}\n\n/** The block's left edge inside the padded rect. */\nfunction calculateBlockLeft(\n rect: DrawRect,\n align: CanvasTextAlign,\n padding: number,\n width: number\n) {\n if (align === 'left') {\n return rect.x + padding\n }\n if (align === 'right') {\n return rect.x + rect.w - padding - width\n }\n return rect.x + (rect.w - width) / 2\n}\n\nexport /**\n * The x every line is drawn at, given the canvas `textAlign` that will be in\n * effect. When the two alignments agree this reduces to v4's single x, so the\n * default output is unchanged.\n */\nfunction calculateLineX(\n rect: DrawRect,\n align: CanvasTextAlign,\n lineAlign: CanvasTextAlign,\n padding: number,\n width: number\n) {\n if (align === lineAlign) {\n if (align === 'left') {\n return rect.x + padding\n }\n if (align === 'right') {\n return rect.x + rect.w - padding\n }\n return rect.x + rect.w / 2\n }\n const left = calculateBlockLeft(rect, align, padding, width)\n if (lineAlign === 'left') {\n return left\n }\n if (lineAlign === 'right') {\n return left + width\n }\n return left + width / 2\n}\n","import type { DrawRect } from '../geometry.js'\nimport type { TreemapLabelsOptions } from '../types.js'\nimport type { Font, LabelSize } from './measure.js'\n\nimport { fontFor, measureLabelSize } from './measure.js'\n\nexport function sliceTextToFitWidth(\n ctx: CanvasRenderingContext2D,\n text: string,\n width: number,\n fonts: Font[]\n) {\n const ellipsis = '...'\n const ellipsisWidth = measureLabelSize(ctx, [ellipsis], fonts).width\n if (ellipsisWidth >= width) {\n return ''\n }\n let lowerBoundLen = 1\n let upperBoundLen = text.length\n let currentWidth: number\n while (lowerBoundLen <= upperBoundLen) {\n const currentLen = Math.floor((lowerBoundLen + upperBoundLen) / 2)\n const currentText = text.slice(0, currentLen)\n currentWidth = measureLabelSize(ctx, [currentText], fonts).width\n if (currentWidth + ellipsisWidth > width) {\n upperBoundLen = currentLen - 1\n } else {\n lowerBoundLen = currentLen + 1\n }\n }\n const slicedText = text.slice(0, Math.max(0, lowerBoundLen - 1))\n return slicedText ? slicedText + ellipsis : ''\n}\n\nexport /**\n * Keeps as many whole lines as fit, and marks the truncation with an ellipsis:\n * on any line too wide for the box, and on the last line kept when there were\n * more below it.\n */\nfunction applyEllipsis(\n ctx: CanvasRenderingContext2D,\n lines: string[],\n styles: number[],\n fonts: Font[],\n maxWidth: number,\n maxHeight: number\n) {\n const keptLines: string[] = []\n const keptStyles: number[] = []\n let used = 0\n for (let i = 0; i < lines.length; i++) {\n const font = fontFor(fonts, styles[i])\n if (keptLines.length && used + font.lineHeight > maxHeight) {\n break\n }\n used += font.lineHeight\n keptLines.push(lines[i])\n keptStyles.push(styles[i])\n }\n\n const dropped = keptLines.length < lines.length\n const last = keptLines.length - 1\n for (let i = 0; i < keptLines.length; i++) {\n const font = fontFor(fonts, keptStyles[i])\n const tooWide = measureLabelSize(ctx, [keptLines[i]], [font]).width > maxWidth\n if (tooWide || (dropped && i === last)) {\n keptLines[i] = sliceTextToFitWidth(ctx, keptLines[i], maxWidth, [font])\n }\n }\n return { lines: keptLines, styles: keptStyles }\n}\n\nexport function labelToDraw(rect: DrawRect, options: TreemapLabelsOptions, labelSize: LabelSize) {\n const { overflow, padding } = options\n const { width, height } = labelSize\n if (overflow === 'hidden') {\n return !(width + padding * 2 > rect.w || height + padding * 2 > rect.h)\n } else if (overflow === 'fit') {\n const ratio = Math.min(rect.w / (width + padding * 2), rect.h / (height + padding * 2))\n if (ratio < 1) {\n return ratio\n }\n }\n return true\n}\n","import type { Font } from './measure.js'\n\nimport { isArray } from 'chart.js/helpers'\n\nimport { fontFor, measureLabelSize } from './measure.js'\n\nexport /**\n * Breaks one piece of text to `width`, greedily on spaces. A single word wider\n * than the width is broken by character, because leaving it to overflow would\n * defeat the point of asking for wrapping.\n */\nfunction wrapToWidth(ctx: CanvasRenderingContext2D, text: string, font: Font, width: number) {\n if (width <= 0) {\n return [text]\n }\n const fits = (value: string) => measureLabelSize(ctx, [value], [font]).width <= width\n const lines: string[] = []\n let line = ''\n\n const pushWord = (word: string) => {\n if (fits(word)) {\n line = word\n return\n }\n let chunk = ''\n for (const char of word) {\n if (chunk && !fits(chunk + char)) {\n lines.push(chunk)\n chunk = ''\n }\n chunk += char\n }\n line = chunk\n }\n\n for (const word of text.split(' ')) {\n const candidate = line ? `${line} ${word}` : word\n if (fits(candidate)) {\n line = candidate\n continue\n }\n if (line) {\n lines.push(line)\n line = ''\n }\n pushWord(word)\n }\n if (line) {\n lines.push(line)\n }\n return lines.length ? lines : ['']\n}\n\nexport /**\n * Formatter output as drawable lines.\n *\n * An array is one paragraph per entry and a string breaks on newlines, which\n * canvas would otherwise draw as a stray glyph. Colours and fonts are indexed\n * by paragraph, so a wrapped paragraph keeps one style throughout.\n */\nfunction toLines(\n ctx: CanvasRenderingContext2D,\n content: string | string[],\n fonts: Font[],\n width: number,\n wrap: boolean\n) {\n const paragraphs = (isArray(content) ? content : [content]).map((entry) => `${entry}`)\n const lines: string[] = []\n const styles: number[] = []\n\n paragraphs.forEach((paragraph, index) => {\n const font = fontFor(fonts, index)\n for (const piece of paragraph.split('\\n')) {\n for (const line of wrap ? wrapToWidth(ctx, piece, font, width) : [piece]) {\n lines.push(line)\n styles.push(index)\n }\n }\n })\n return { lines, styles }\n}\n","import type { Element } from 'chart.js'\nimport type { DrawRect } from '../geometry.js'\nimport type {\n TreemapCaptionsOptions,\n TreemapConfig,\n TreemapDataPoint,\n TreemapDisplayMode,\n TreemapLabelsOptions,\n TreemapLayoutOptions,\n TreemapOptions,\n TreemapScriptableContext,\n} from '../types.js'\nimport type { TextBlock } from './draw.js'\nimport type { Font } from './measure.js'\n\nimport { defined, isArray, isNumber, toFont, valueOrDefault } from 'chart.js/helpers'\n\nimport { calculateBlockTop, clipToPadding, drawTextBlock } from './draw.js'\nimport { applyEllipsis, labelToDraw, sliceTextToFitWidth } from './fit.js'\nimport { measureLabelSize, measureLines, toFonts } from './measure.js'\nimport { toLines } from './wrap.js'\n\ntype RectSize = {\n h: number\n w: number\n}\n\ntype RectHeight = {\n h: number\n}\n\ntype TextElement = Element<TreemapConfig, TreemapOptions> & {\n $context?: TreemapScriptableContext\n}\n\nexport function shouldDrawCaption(\n displayMode: TreemapDisplayMode,\n rect: RectSize,\n options?: Partial<TreemapCaptionsOptions>\n) {\n if (!options || options.display === false) {\n return false\n }\n if (displayMode === 'headerBoxes') {\n return true\n }\n const { w, h } = rect\n const font = toFont(options.font || {})\n const min = font.lineHeight\n const padding = Math.max(Math.min(valueOrDefault(options.padding, 3) * 2, Math.min(w, h)), 0)\n return w - padding > min && h - padding > min\n}\n\nexport function getCaptionHeight(\n displayMode: TreemapDisplayMode,\n rect: RectHeight,\n font: { lineHeight: number },\n padding: number\n) {\n if (displayMode !== 'headerBoxes') {\n return font.lineHeight + padding * 2\n }\n const captionHeight = font.lineHeight + padding * 2\n return rect.h < 2 * captionHeight ? rect.h / 3 : captionHeight\n}\n\nexport function drawText(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement,\n layout: TreemapLayoutOptions\n) {\n const { captions, labels } = options\n const { displayMode } = layout\n const isLeaf = item && (!defined(item.l) || item.isLeaf)\n\n // Resolve the text before touching the canvas. Most elements in a large\n // treemap draw no text at all, and clipping is not free: this is the\n // difference between five canvas calls per element and none.\n let block: TextBlock | undefined\n if (isLeaf) {\n if (labels.display) {\n block = labelBlock(ctx, rect, options, item, element)\n }\n } else if (shouldDrawCaption(displayMode, rect, captions)) {\n block = captionBlock(ctx, rect, options, item, element, layout)\n }\n if (!block) {\n return\n }\n\n ctx.save()\n clipToPadding(ctx, rect, block.padding, block.clipY)\n drawTextBlock(ctx, rect, block)\n ctx.restore()\n}\n\nfunction callbackContext(element: TextElement, item: TreemapDataPoint): TreemapScriptableContext {\n const context =\n element.$context ||\n ({ active: !!element.active, raw: item, type: 'data' } as TreemapScriptableContext)\n context.active = !!element.active\n context.raw = item\n return context\n}\n\nfunction resolveOption<T>(\n option: T | ((context: TreemapScriptableContext) => T) | undefined,\n context: TreemapScriptableContext\n) {\n return typeof option === 'function'\n ? (option as (context: TreemapScriptableContext) => T)(context)\n : option\n}\n\nfunction resolveCaptionText(\n captions: TreemapCaptionsOptions,\n element: TextElement,\n item: TreemapDataPoint\n) {\n return resolveOption(captions.formatter, callbackContext(element, item)) || item.g || ''\n}\n\n/** The caption's text, truncated with an ellipsis when it does not fit. */\nfunction captionText(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n captions: TreemapCaptionsOptions,\n element: TextElement,\n item: TreemapDataPoint,\n fonts: Font[]\n) {\n const text = resolveCaptionText(captions, element, item)\n if (!text) {\n return undefined\n }\n const padding = captions.padding\n if (measureLabelSize(ctx, [text], fonts).width + 2 * padding <= rect.w) {\n return text\n }\n // `ellipsis` is the default and is what v4 always did; the other modes leave\n // the clip to tell the whole story.\n const overflow = captions.overflow || 'ellipsis'\n if (overflow === 'hidden') {\n return undefined\n }\n if (overflow === 'cut') {\n return text\n }\n return sliceTextToFitWidth(ctx, text, rect.w - 2 * padding, fonts)\n}\n\nfunction captionBlock(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement,\n layout: TreemapLayoutOptions\n): TextBlock | undefined {\n const { displayMode, rtl, spacing } = layout\n const { captions } = options\n const { color, hoverColor, font, hoverFont, padding, align } = captions\n const optFont = (rect.active ? hoverFont : font) || font\n const oFont = toFont(optFont)\n if (oFont.lineHeight > rect.h) {\n return\n }\n const text = captionText(ctx, rect, captions, element, item, [oFont])\n if (text === undefined) {\n return\n }\n const fonts = [oFont]\n // A caption is a single line, centred in the header strip in headerBoxes mode\n // and sitting under the top padding otherwise.\n const top =\n displayMode === 'headerBoxes'\n ? rect.y + (rect.h - oFont.lineHeight) / 2\n : rect.y + padding + spacing\n return {\n align: align || (rtl ? 'right' : 'left'),\n clipY: displayMode === 'headerBoxes' ? 0 : padding,\n colors: [(rect.active ? hoverColor : color) || color],\n fonts,\n lines: [text],\n padding,\n styles: [0],\n textAlign: captions.textAlign,\n top,\n width: measureLabelSize(ctx, [text], fonts).width,\n }\n}\n\nfunction labelBlock(\n ctx: CanvasRenderingContext2D,\n rect: DrawRect,\n options: TreemapOptions,\n item: TreemapDataPoint,\n element: TextElement\n): TextBlock | undefined {\n const labels = options.labels\n const content = resolveOption(labels.formatter, callbackContext(element, item))\n if (!content) {\n return\n }\n const { align, color, hoverColor, overflow, padding, wrap } = labels\n const maxWidth = rect.w - padding * 2\n const maxHeight = rect.h - padding * 2\n\n let fonts = getFontFromOptions(rect, labels)\n let { lines, styles } = toLines(ctx, content, fonts, maxWidth, !!wrap)\n let labelSize = measureLines(ctx, lines, styles, fonts)\n\n const lblToDraw = labelToDraw(rect, labels, labelSize)\n if (!lblToDraw) {\n return\n }\n if (isNumber(lblToDraw)) {\n fonts = toFonts(fonts, lblToDraw)\n if (wrap) {\n // Shorter lines pack into fewer rows, so wrap once more at the smaller\n // size rather than iterating towards a fixed point.\n const rewrapped = toLines(ctx, content, fonts, maxWidth, true)\n lines = rewrapped.lines\n styles = rewrapped.styles\n labelSize = measureLines(ctx, lines, styles, fonts)\n } else {\n labelSize = { height: labelSize.height * lblToDraw, width: labelSize.width * lblToDraw }\n }\n }\n\n if (overflow === 'ellipsis') {\n const trimmed = applyEllipsis(ctx, lines, styles, fonts, maxWidth, maxHeight)\n lines = trimmed.lines\n styles = trimmed.styles\n labelSize = measureLines(ctx, lines, styles, fonts)\n }\n\n const optColor = (rect.active ? hoverColor : color) || color\n return {\n align,\n clipY: padding,\n colors: isArray(optColor) ? optColor : [optColor],\n fonts,\n lines,\n padding,\n styles,\n textAlign: labels.textAlign,\n top: calculateBlockTop(rect, labels, labelSize),\n width: labelSize.width,\n }\n}\n\nfunction getFontFromOptions(rect: DrawRect, labels: TreemapLabelsOptions) {\n const { font, hoverFont } = labels\n const optFont = (rect.active ? hoverFont : font) || font\n return Array.isArray(optFont) ? optFont.map((f) => toFont(f)) : [toFont(optFont)]\n}\n","import type { DrawRect } from './geometry.js'\nimport type {\n TreemapDataPoint,\n TreemapDisplayMode,\n TreemapOthers,\n TreemapValueScale,\n} from './types.js'\n\nimport { isObject, toFont, valueOrDefault } from 'chart.js/helpers'\n\nimport { parseBorderWidth } from './options.js'\nimport { packInto, sortNodes, toNodes, WEIGHT_KEY } from './squarify.js'\nimport { getCaptionHeight, shouldDrawCaption } from './text/index.js'\nimport { getGroupKey, group, normalizeTreeToArray } from './utils.js'\n\nexport type LayoutOptions = {\n borderWidth: any\n captions: any\n displayMode: TreemapDisplayMode\n groups: any[]\n leafKey: string\n others: false | TreemapOthers\n spacing: number\n unsorted: boolean\n valueScale: TreemapValueScale\n}\n\n/** A node while the layout is being built; `_children` is dropped before use. */\nexport type LayoutNode = TreemapDataPoint & { _children?: LayoutNode[] }\n\n/**\n * Pass one: the hierarchy.\n *\n * Groups the items level by level and orders each set of siblings. Nothing here\n * depends on the chart area, so the number of nodes and their order are known\n * before the layout has a rectangle to fill.\n */\nfunction buildHierarchy(\n values: any[],\n gidx: number,\n keys: string[],\n layout: LayoutOptions,\n weighted: boolean,\n parentGroupValue?: string\n): LayoutNode[] {\n const { groups, leafKey, unsorted } = layout\n const glen = groups.length\n const g = getGroupKey(groups[gidx])\n const gdata = group(\n values,\n g,\n keys,\n leafKey,\n undefined,\n parentGroupValue,\n groups.filter((_item: any, index: number) => index <= gidx),\n groups,\n gidx\n )\n const nodes = toNodes(gdata, keys, g, gidx) as LayoutNode[]\n\n for (const node of nodes) {\n const record = node._data as any\n const nextGroupIndex = record.groupIndex + 1\n const children =\n gidx < glen - 1 && nextGroupIndex < glen\n ? buildHierarchy(record.children, nextGroupIndex, keys, layout, weighted, node.g)\n : []\n // Non-enumerable: the geometry pass needs it on every layout, but it\n // must not show up in ctx.raw.\n Object.defineProperty(node, '_children', {\n configurable: true,\n value: children,\n writable: true,\n })\n node.isLeaf = !children.length\n }\n\n // Weights depend on the children, so they are set before the siblings are\n // ordered: a scaled group can rank differently from a raw one.\n if (weighted) {\n applyValueScale(nodes, scaleFor(layout))\n }\n const withOthers = layout.others ? applyOthers(nodes, layout.others, weighted) : nodes\n if (!unsorted) {\n sortNodes(withOthers, weighted)\n }\n return withOthers\n}\n\n/**\n * The layout weight of every node, when `valueScale` is not linear.\n *\n * A leaf's weight is its scaled value; a group's is the sum of its children's,\n * so a group still covers exactly the area its contents do. `v` is untouched:\n * tooltips, labels and `sumKeys` stay in the units the data came in.\n */\nfunction applyValueScale(nodes: LayoutNode[], scale: (value: number, item: any) => number) {\n for (const node of nodes) {\n const children = node._children\n let weight: number\n if (children?.length) {\n applyValueScale(children, scale)\n weight = children.reduce((total, child) => total + (child as any)[WEIGHT_KEY], 0)\n } else {\n const scaled = scale(node.v, node._data)\n weight = Number.isFinite(scaled) && scaled > 0 ? scaled : 0\n }\n Object.defineProperty(node, WEIGHT_KEY, { configurable: true, value: weight, writable: true })\n }\n}\n\n/**\n * Replaces the leaves too small to see with one tile that stands for all of\n * them.\n *\n * The question behind #213 is \"where did my small items go\", and a compressed\n * scale answers it by distorting the areas. This answers it by admitting the\n * items are too small and naming them instead. Groups are never bucketed: a\n * group is already a summary.\n */\nfunction applyOthers(nodes: LayoutNode[], others: TreemapOthers, weighted: boolean) {\n const { label = 'Other', minCount = 2, threshold } = others\n // A node with children is a group, and a group is already a summary.\n if (!(threshold > 0) || nodes.some((node) => node._children?.length)) {\n return nodes\n }\n\n const weightOf = (node: LayoutNode) => (weighted ? (node as any)[WEIGHT_KEY] : node.v)\n const total = nodes.reduce((sum, node) => sum + weightOf(node), 0)\n if (!(total > 0)) {\n return nodes\n }\n\n const small = nodes.filter((node) => weightOf(node) / total < threshold)\n if (small.length < Math.max(2, minCount)) {\n return nodes\n }\n\n const kept = nodes.filter((node) => !small.includes(node))\n const bucket: LayoutNode = {\n _data: { label, others: small.map((node) => node._data) },\n h: 0,\n isLeaf: true,\n isOthers: true,\n s: 0,\n v: small.reduce((sum, node) => sum + node.v, 0),\n vs: sumValues(small),\n w: 0,\n x: 0,\n y: 0,\n }\n const grouped = nodes.find((node) => node.g !== undefined)\n if (grouped) {\n bucket.g = label\n bucket.l = grouped.l\n }\n if (weighted) {\n Object.defineProperty(bucket, WEIGHT_KEY, {\n configurable: true,\n value: small.reduce((sum, node) => sum + weightOf(node), 0),\n writable: true,\n })\n }\n kept.push(bucket)\n return kept\n}\n\n/** The `sumKeys` totals of the absorbed items, so the bucket carries them too. */\nfunction sumValues(nodes: LayoutNode[]) {\n const totals: Record<string, number> = {}\n for (const node of nodes) {\n for (const [key, value] of Object.entries(node.vs || {})) {\n totals[key] = (totals[key] || 0) + (value as number)\n }\n }\n return Object.keys(totals).length ? totals : undefined\n}\n\nconst VALUE_SCALES: Record<string, (value: number) => number> = {\n log: (value) => Math.log1p(Math.max(value, 0)),\n sqrt: (value) => Math.sqrt(Math.max(value, 0)),\n}\n\n/** Draw order: a set of siblings, then the descendants of each in turn. */\nexport function flattenNodes(nodes: LayoutNode[]): LayoutNode[] {\n const flat = nodes.slice()\n for (const node of nodes) {\n if (node._children?.length) {\n flat.push(...flattenNodes(node._children))\n }\n }\n return flat\n}\n\n/**\n * Pass two: the geometry.\n *\n * Packs each set of siblings into its parent's rectangle, writing the\n * coordinates onto the nodes the first pass produced.\n */\nfunction layoutLevel(\n nodes: LayoutNode[],\n rect: any,\n layout: LayoutOptions,\n weighted: boolean,\n parentSum?: number\n) {\n if (parentSum !== undefined) {\n for (const node of nodes) {\n node.gs = parentSum\n }\n }\n packInto(nodes, rect, weighted)\n\n for (const node of nodes) {\n if (node._children?.length) {\n layoutLevel(node._children, getSubRect(node, rect, layout), layout, weighted, node.s)\n }\n }\n}\n\n/** Writes the geometry for a whole tree of nodes, then applies headerBoxes. */\nexport function layoutNodes(nodes: LayoutNode[], rect: any, layout: LayoutOptions) {\n layoutLevel(nodes, rect, layout, isWeighted(layout))\n applyHeaderBoxes(flattenNodes(nodes), layout)\n}\n\n/** Linear is the default and needs no weights, so it keeps v4's arithmetic. */\nfunction isWeighted(layout: LayoutOptions) {\n const scale = layout.valueScale\n return scale !== 'linear' && scale !== undefined\n}\n\nfunction scaleFor(layout: LayoutOptions) {\n const scale = layout.valueScale\n if (typeof scale === 'function') {\n return scale\n }\n return VALUE_SCALES[scale as string] || ((value: number) => value)\n}\n\n/** The rectangle left for a group's children once its border and caption are taken. */\nfunction getSubRect(sq: any, rect: any, layout: LayoutOptions) {\n const { borderWidth, captions, displayMode } = layout\n const sp = displayMode === 'headerBoxes' ? 0 : layout.spacing\n const bw =\n displayMode === 'headerBoxes'\n ? { b: 0, l: 0, r: 0, t: 0 }\n : parseBorderWidth(borderWidth, sq.w / 2, sq.h / 2)\n const subRect = {\n ...rect,\n h: sq.h - 2 * sp - bw.t - bw.b,\n w: sq.w - 2 * sp - bw.l - bw.r,\n x: sq.x + sp + bw.l,\n y: sq.y + sp + bw.t,\n }\n if (shouldDrawCaption(displayMode, subRect, captions)) {\n const captionHeight = getCaptionHeight(\n displayMode,\n subRect,\n toFont(captions.font),\n valueOrDefault(captions.padding, 3)\n )\n subRect.y += captionHeight\n subRect.h -= captionHeight\n }\n return subRect\n}\n\n/**\n * The hierarchy pass on its own: the nested nodes, in draw order, with no\n * geometry. Takes no rectangle, which is the whole point - the controller needs\n * the node count before the chart area is known.\n */\nexport function buildNodes(tree: any, keys: string[], layout: LayoutOptions): LayoutNode[] {\n const { groups, leafKey, unsorted } = layout\n const input = isObject(tree) ? normalizeTreeToArray(keys, leafKey, tree) : tree\n\n const weighted = isWeighted(layout)\n let nodes: LayoutNode[]\n if (groups.length) {\n nodes = buildHierarchy(input, 0, keys, layout, weighted)\n } else {\n nodes = toNodes(input || [], keys) as LayoutNode[]\n if (weighted) {\n applyValueScale(nodes, scaleFor(layout))\n }\n if (layout.others) {\n nodes = applyOthers(nodes, layout.others, weighted)\n }\n if (!unsorted) {\n sortNodes(nodes, weighted)\n }\n }\n return nodes\n}\n\n/**\n * In headerBoxes mode a group is drawn as a header strip rather than a box\n * around its children, and a group whose caption does not fit is not drawn at\n * all. It is marked hidden rather than removed: the number of parsed nodes must\n * not depend on the size of the chart area.\n */\nfunction applyHeaderBoxes(nodes: LayoutNode[], layout: LayoutOptions) {\n const { captions, displayMode } = layout\n if (displayMode !== 'headerBoxes') {\n return\n }\n const font = toFont(captions.font)\n const padding = valueOrDefault(captions.padding, 3)\n for (const node of nodes) {\n if (node.isLeaf) {\n continue\n }\n if (shouldDrawCaption(displayMode, node, captions)) {\n node.h = getCaptionHeight(displayMode, node, font, padding)\n node.hidden = false\n } else {\n node.hidden = true\n }\n }\n}\n\n/** Turns the user's input into the flat list of rectangles the chart draws. */\nexport function buildData(\n tree: any,\n keys: string[],\n mainRect: DrawRect,\n layout: LayoutOptions\n): TreemapDataPoint[] {\n const nodes = buildNodes(tree, keys, layout)\n layoutNodes(nodes, mainRect, layout)\n return flattenNodes(nodes)\n}\n","import type { LayoutNode, LayoutOptions } from './layout.js'\n\nimport { Chart, DatasetController, registry } from 'chart.js'\nimport { clipArea, unclipArea, valueOrDefault } from 'chart.js/helpers'\n\nimport { version } from '../package.json'\nimport { rectNotEqual, scaleRect } from './helpers/index.js'\nimport { buildNodes, flattenNodes, layoutNodes } from './layout.js'\nimport { layoutDefaults } from './options.js'\nimport { requireVersion } from './utils.js'\n\n/** Region fractions are shares of the chart area, so outside 0..1 means nothing. */\nfunction clampFraction(value: number | undefined, fallback: number) {\n return value === undefined ? fallback : Math.min(Math.max(value, 0), 1)\n}\n\nfunction registerTooltipPositioner() {\n const tooltipPlugin = registry.plugins.get('tooltip') as any\n if (!tooltipPlugin || tooltipPlugin.positioners.treemap) {\n return\n }\n tooltipPlugin.positioners.treemap = (active: any[]) => {\n if (!active.length) {\n return false\n }\n\n const item = active.at(-1)\n return item.element.tooltipPosition()\n }\n}\n\nexport default class TreemapController extends DatasetController {\n declare static readonly id: string\n declare static readonly defaults: Record<string, unknown>\n declare static readonly descriptors: Record<string, unknown>\n declare static readonly overrides: Record<string, unknown>\n declare static readonly beforeRegister: () => void\n declare static readonly afterRegister: () => void\n declare static readonly afterUnregister: () => void\n\n // Chart.js assigns this on the class when the controller is registered; its\n // type definitions do not describe it.\n declare dataElementType: new () => any\n\n options: any\n _rect: any\n _rectChanged: boolean\n _nodes: LayoutNode[]\n _regionWarned: boolean\n _layoutDirty: boolean\n _fingerprint: string | undefined\n _layoutKey: string | undefined\n _resetFrom: number | undefined\n\n constructor(chart: any, datasetIndex: number) {\n super(chart, datasetIndex)\n\n this._rect = undefined\n this._rectChanged = true\n this._regionWarned = false\n this._nodes = []\n this._layoutDirty = true\n this._fingerprint = undefined\n this._resetFrom = undefined\n }\n\n override initialize() {\n // The tooltip can be registered after the treemap controller. At chart creation time all\n // components are available, so retry here to make registration order irrelevant.\n registerTooltipPositioner()\n this.enableOptionSharing = true\n super.initialize()\n }\n\n override getMinMax(scale: any) {\n return {\n max: scale.axis === 'x' ? scale.right - scale.left : scale.bottom - scale.top,\n min: 0,\n }\n }\n\n override configure() {\n super.configure()\n const { xScale, yScale } = this.getMeta() as any\n if (!xScale || !yScale) {\n // configure is called once before `linkScales`, and at that call we don't have any scales linked yet\n return\n }\n\n const w = xScale.right - xScale.left\n const h = yScale.bottom - yScale.top\n const rect = {\n ...this._regionBounds(w, h),\n rtl: !!this.options.rtl,\n unsorted: !!this.options.unsorted,\n }\n\n if (rectNotEqual(this._rect, rect)) {\n this._rect = rect\n this._rectChanged = true\n }\n\n if (this._rectChanged) {\n xScale.max = w\n xScale.configure()\n yScale.max = h\n yScale.configure()\n }\n }\n\n /**\n * The part of the chart area this dataset lays out into.\n *\n * Every dataset shares the chart's single pair of linear scales, whose max is\n * the full chart area in pixels, so a region is just a rectangle in that\n * space and no scale has to change.\n */\n _regionBounds(w: number, h: number) {\n const region = this.options.region\n if (!region) {\n return { h, w, x: 0, y: 0 }\n }\n const left = clampFraction(region.left, 0)\n const top = clampFraction(region.top, 0)\n const width = clampFraction(region.width, 1)\n const height = clampFraction(region.height, 1)\n\n if (!this._regionWarned && (left + width > 1 || top + height > 1)) {\n this._regionWarned = true\n console.warn(\n 'chartjs-chart-treemap: a dataset region reaches outside the chart area and is clipped to it.'\n )\n }\n return {\n h: h * Math.min(height, 1 - top),\n w: w * Math.min(width, 1 - left),\n x: w * left,\n y: h * top,\n }\n }\n\n /**\n * Options that shape the layout rather than a single rectangle, resolved once\n * per dataset. Reading them from `this.options` rather than from the raw\n * dataset is what makes `options.datasets.treemap` work for all of them.\n */\n _layoutOptions(): LayoutOptions {\n const dataset = this.getDataset() as any\n const options = this.options\n return {\n // Still raw: resolving these with the dataset context is feature 2's\n // change, and doing it here would move pixels in this refactor.\n borderWidth: dataset.borderWidth,\n captions: dataset.captions || {},\n displayMode: options.displayMode,\n groups: options.groups || [],\n leafKey: options.leafKey,\n others: options.others || false,\n // Deliberately NOT options.spacing. The child rectangle calculation has\n // always defaulted spacing to 0 while the drawn rectangle defaults it to\n // 0.5, so reading the resolved value here would inset every nested group\n // by an extra 0.5 and move 11 fixtures. Unifying the two is a visual\n // change that deserves its own pull request.\n spacing: valueOrDefault(dataset.spacing, 0),\n unsorted: !!options.unsorted,\n valueScale: options.valueScale || 'linear',\n }\n }\n\n /**\n * Chart.js calls this before `configure()`, so the chart area is not\n * available here - see the hierarchy pass in `./layout`, which does not need\n * one. Elements are created from the parsed nodes rather than from\n * `dataset.data`, because a treemap with groups has more rectangles than the\n * user supplied rows.\n */\n override buildOrUpdateElements(resetNewElements?: boolean) {\n // Chart.js rebuilds `this.options` in `configure()`, which it calls from\n // `_updateDatasets` - after this method. Parsing reads the grouping options\n // from `this.options`, and the layout read in `update()` primes a resolver's\n // per-property cache, so without a rebuild here parsing would see the\n // previous update's values. Only the options are rebuilt: the scales and the\n // region are configured by `configure()` once the chart area is known.\n super.configure()\n this.parse(0, 0)\n\n const meta = this.getMeta() as any\n const count = (meta._parsed as unknown[]).length\n const elements = meta.data as unknown[]\n const previous = elements.length\n if (previous > count) {\n elements.splice(count, previous - count)\n }\n while (elements.length < count) {\n elements.push(new this.dataElementType())\n }\n // New elements start from a reset, as in Chart.js's `_insertElements`, but\n // that needs their geometry, which only exists after `update()` has laid\n // the nodes out.\n this._resetFrom = resetNewElements && count > previous ? previous : undefined\n }\n\n override parse(_start: number, _count: number) {\n const dataset = this.getDataset() as any\n if (dataset.tree !== undefined) {\n throw new Error(\n 'chartjs-chart-treemap v5: the \"tree\" option was renamed to \"data\". ' +\n 'See https://chartjs-chart-treemap.pages.dev/usage/'\n )\n }\n\n const options = this.options\n const keys = [options.key || ''].concat(options.sumKeys || [])\n const layoutOptions = this._layoutOptions()\n const nodes = buildNodes(dataset.data || [], keys, layoutOptions)\n const flat = flattenNodes(nodes)\n\n // A `chart.update('none')` per wheel event must not re-run the layout when\n // nothing about the data changed, so keep the previous nodes - and with\n // them their geometry - when the hierarchy is identical.\n const fingerprint = flat.map((node) => `${node.v}\\u0000${node.g}\\u0000${node.l}`).join('\\u0001')\n\n // Options such as spacing, borderWidth or the captions move the rectangles\n // without changing the hierarchy.\n const layoutKey = JSON.stringify(layoutOptions, (_key, value) =>\n typeof value === 'function' ? String(value) : value\n )\n const layoutChanged = this._layoutKey !== layoutKey\n this._layoutKey = layoutKey\n\n if (this._fingerprint === fingerprint) {\n if (layoutChanged) {\n this._layoutDirty = true\n }\n return\n }\n\n this._fingerprint = fingerprint\n this._nodes = nodes\n ;(this.getMeta() as any)._parsed = flat\n this._layoutDirty = true\n }\n\n // `getContext` exists on DatasetController at runtime but not in its type\n // definitions, so this cannot be declared as an override.\n getContext(index: number, active?: boolean, mode?: string) {\n const base = (DatasetController.prototype as any).getContext\n const context = base.call(this, index, active, mode)\n const parsed = typeof index === 'number' ? this.getParsed(index) : undefined\n if (parsed) {\n context.raw = parsed\n context.parsed = parsed\n }\n return context\n }\n\n override getLabelAndValue(index: number) {\n const node = this.getParsed(index) as any\n if (!node) {\n return { label: '', value: '' }\n }\n const dataset = this.getDataset() as any\n const label = node.g ?? node._data?.label ?? dataset.label\n const text = label === undefined ? '' : `${label}`\n const others = node.isOthers ? node._data?.others?.length : undefined\n return {\n label: others ? `${text} (${others} items)` : text,\n value: `${node.v}`,\n }\n }\n\n override update(mode: any) {\n const { data } = this.getMeta()\n\n if (mode === 'reset') {\n // reset is called before 2nd configure and is only called if animations are enabled. So wen need an extra configure call here.\n this.configure()\n }\n\n if (this._layoutDirty || this._rectChanged) {\n layoutNodes(this._nodes, this._rect, this._layoutOptions())\n this._layoutDirty = false\n this._rectChanged = false\n }\n\n const resetFrom = this._resetFrom\n this._resetFrom = undefined\n if (resetFrom !== undefined && mode !== 'reset') {\n this.updateElements(data, resetFrom, data.length - resetFrom, 'reset')\n }\n\n this.updateElements(data, 0, data.length, mode)\n }\n\n override updateElements(rects: any[], start: number, count: number, mode: any) {\n const reset = mode === 'reset'\n const firstOpts = this.resolveDataElementOptions(start, mode)\n this._rect.options = firstOpts\n const sharedOptions = this.getSharedOptions(firstOpts)\n // `sharedOptions` is undefined whenever the options cannot be shared, and\n // Chart.js then expects every element to receive its own. Passing an empty\n // object instead made `includeOptions()` false under animation, so elements\n // kept the options they were created with.\n const includeOptions = this.includeOptions(mode, sharedOptions as any)\n const { xScale, yScale } = this.getMeta() as any\n const spacing = this.options.spacing\n\n for (let i = start; i < start + count; i++) {\n const options = sharedOptions || this.resolveDataElementOptions(i, mode)\n const node = this.getParsed(i) as any\n const properties: any = scaleRect(node, xScale, yScale, spacing)\n properties.hidden = properties.hidden || !!node.hidden\n if (reset) {\n properties.width = 0\n properties.height = 0\n }\n\n if (includeOptions) {\n properties.options = options\n }\n this.updateElement(rects[i], i, properties, mode)\n }\n\n this.updateSharedOptions(sharedOptions as any, mode, firstOpts)\n }\n\n override draw() {\n const { ctx, chartArea } = this.chart\n const metadata = ((this.getMeta() as any).data || []) as any[]\n const { displayMode, rtl, spacing } = this.options\n const layout = { displayMode, rtl, spacing }\n\n clipArea(ctx, chartArea)\n for (let i = 0, ilen = metadata.length; i < ilen; ++i) {\n const rect = metadata[i]\n if (!rect.hidden) {\n rect.draw(ctx, this.getParsed(i) as any, layout)\n }\n }\n unclipArea(ctx)\n }\n}\n\n;(TreemapController as any).id = 'treemap'\n\n;(TreemapController as any).version = version\n\n;(TreemapController as any).defaults = {\n animations: {\n numbers: {\n properties: ['x', 'y', 'width', 'height'],\n type: 'number',\n },\n },\n dataElementType: 'treemap',\n displayMode: layoutDefaults.displayMode,\n groups: [],\n key: '',\n leafKey: '_leaf',\n others: false,\n region: undefined,\n rtl: layoutDefaults.rtl,\n spacing: layoutDefaults.spacing,\n sumKeys: [],\n unsorted: false,\n valueScale: 'linear',\n}\n\n;(TreemapController as any).descriptors = {\n _indexable: false,\n _scriptable: true,\n captions: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n labels: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n}\n\n;(TreemapController as any).overrides = {\n hover: {},\n interaction: {\n includeInvisible: true,\n intersect: true,\n mode: 'point',\n },\n\n plugins: {\n tooltip: {\n callbacks: {\n label(item: any) {\n const node = item.parsed\n const label = node.g || node._data?.label || item.dataset.label\n return (label ? `${label}: ` : '') + node.v\n },\n title(items: any[]) {\n if (items.length) {\n const item = items[0]\n return item.dataset.key || ''\n }\n return ''\n },\n },\n intersect: true,\n position: 'treemap',\n },\n },\n scales: {\n x: {\n alignToPixels: true,\n bounds: 'data',\n display: false,\n type: 'linear',\n },\n y: {\n alignToPixels: true,\n bounds: 'data',\n display: false,\n reverse: true,\n type: 'linear',\n },\n },\n}\n\n;(TreemapController as any).beforeRegister = () => {\n requireVersion('chart.js', '4.0', Chart.version)\n}\n\n;(TreemapController as any).afterRegister = () => {\n registerTooltipPositioner()\n}\n\n;(TreemapController as any).afterUnregister = () => {\n const tooltipPlugin = registry.plugins.get('tooltip') as any\n if (tooltipPlugin) {\n delete tooltipPlugin.positioners.treemap\n }\n}\n","import type { BorderRadius, Element } from 'chart.js'\nimport type { TreemapBorderRadius, TreemapConfig, TreemapOptions } from './types.js'\n\nimport { parseBorderRadius, parseBorderWidth } from './options.js'\n\nexport type DrawRect = {\n active?: boolean\n h: number\n radius: TreemapBorderRadius\n w: number\n x: number\n y: number\n}\n\ntype TreemapElementBase = Element<TreemapConfig, TreemapOptions>\n\nfunction getBounds(rect: TreemapElementBase, useFinalPosition?: boolean) {\n const { x, y, width, height } = rect.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return { bottom: y + height, left: x, right: x + width, top: y }\n}\n\nexport function boundingRects(rect: TreemapElementBase) {\n const bounds = getBounds(rect)\n const width = bounds.right - bounds.left\n const height = bounds.bottom - bounds.top\n const border = parseBorderWidth(rect.options.borderWidth, width / 2, height / 2)\n const radius: Required<BorderRadius> = parseBorderRadius(\n rect.options.borderRadius,\n width / 2,\n height / 2\n )\n const outer = {\n active: rect.active,\n h: height,\n radius,\n w: width,\n x: bounds.left,\n y: bounds.top,\n }\n\n return {\n inner: {\n active: rect.active,\n h: outer.h - border.t - border.b,\n radius: {\n bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),\n bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r)),\n topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),\n topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),\n },\n w: outer.w - border.l - border.r,\n x: outer.x + border.l,\n y: outer.y + border.t,\n },\n outer,\n }\n}\n\nexport function inRange(\n rect: TreemapElementBase,\n x: number | null,\n y: number | null,\n useFinalPosition?: boolean\n) {\n const skipX = x === null\n const skipY = y === null\n const bounds = !rect || (skipX && skipY) ? false : getBounds(rect, useFinalPosition)\n\n return (\n bounds &&\n (skipX || (x >= bounds.left && x <= bounds.right)) &&\n (skipY || (y >= bounds.top && y <= bounds.bottom))\n )\n}\n\nexport function hasRadius(radius: TreemapBorderRadius) {\n return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight\n}\n\nexport function addNormalRectPath(ctx: CanvasRenderingContext2D, rect: DrawRect) {\n ctx.rect(rect.x, rect.y, rect.w, rect.h)\n}\n","import type {\n TreemapConfig,\n TreemapDataPoint,\n TreemapLayoutOptions,\n TreemapOptions,\n TreemapScriptableContext,\n} from './types.js'\n\nimport { Element } from 'chart.js'\nimport { addRoundedRectPath } from 'chart.js/helpers'\n\nimport { addNormalRectPath, boundingRects, hasRadius, inRange } from './geometry.js'\nimport { layoutDefaults } from './options.js'\nimport { drawText } from './text/index.js'\n\nexport default class TreemapElement extends Element<TreemapConfig, TreemapOptions> {\n static readonly id = 'treemap'\n\n static override readonly defaults = {\n borderRadius: 0,\n borderWidth: 0,\n captions: {\n align: undefined,\n color: 'black',\n display: true,\n font: {},\n formatter: (ctx: TreemapScriptableContext) => {\n const label = ctx.raw._data?.label\n return ctx.raw.g || (typeof label === 'string' ? label : '')\n },\n overflow: 'ellipsis',\n padding: 3,\n textAlign: undefined,\n },\n labels: {\n align: 'center',\n color: 'black',\n display: false,\n font: {},\n formatter(ctx: TreemapScriptableContext) {\n const label = ctx.raw._data?.label\n if (ctx.raw.g) {\n return [ctx.raw.g, `${ctx.raw.v}`]\n }\n return typeof label === 'string' ? [label, `${ctx.raw.v}`] : `${ctx.raw.v}`\n },\n overflow: 'cut',\n padding: 3,\n position: 'middle',\n textAlign: undefined,\n wrap: false,\n },\n }\n\n static readonly descriptors = {\n _indexable: false,\n _scriptable: true,\n captions: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n labels: {\n _fallback: true,\n _scriptable: (name: string) => name !== 'formatter',\n },\n }\n\n static override readonly defaultRoutes = {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor',\n }\n\n $context?: TreemapScriptableContext\n width: number | undefined\n height: number | undefined\n\n constructor(cfg?: Partial<TreemapConfig> & { options?: TreemapOptions }) {\n super()\n\n this.width = undefined\n this.height = undefined\n\n if (cfg) {\n Object.assign(this, cfg)\n }\n }\n\n draw(\n ctx: CanvasRenderingContext2D,\n data?: TreemapDataPoint,\n layout: TreemapLayoutOptions = layoutDefaults\n ) {\n if (!data) {\n return\n }\n const options = this.options\n const { inner, outer } = boundingRects(this)\n const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath\n\n ctx.save()\n\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath()\n addRectPath(ctx, outer)\n ctx.clip()\n addRectPath(ctx, inner)\n ctx.fillStyle = options.borderColor\n ctx.fill('evenodd')\n }\n\n ctx.beginPath()\n addRectPath(ctx, inner)\n ctx.fillStyle = options.backgroundColor\n ctx.fill()\n\n drawText(ctx, inner, options, data, this, layout)\n ctx.restore()\n }\n\n inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, mouseY, useFinalPosition)\n }\n\n inXRange(mouseX: number, useFinalPosition?: boolean) {\n return inRange(this, mouseX, null, useFinalPosition)\n }\n\n inYRange(mouseY: number, useFinalPosition?: boolean) {\n return inRange(this, null, mouseY, useFinalPosition)\n }\n\n getCenterPoint(useFinalPosition?: boolean) {\n const { x, y, width, height } = this.getProps(['x', 'y', 'width', 'height'], useFinalPosition)\n return {\n x: x + width / 2,\n y: y + height / 2,\n }\n }\n\n override tooltipPosition() {\n return this.getCenterPoint()\n }\n}\n","import { Chart } from 'chart.js'\n\nimport TreemapController from './controller.js'\nimport TreemapElement from './element.js'\n\nChart.register(TreemapController as any, TreemapElement as any)\n\nexport type {\n LabelAlign,\n LabelOverflow,\n LabelPosition,\n TreemapConfig,\n TreemapControllerDatasetOptions,\n TreemapDataPoint,\n TreemapElement as TreemapElementType,\n TreemapOptions,\n} from './types.js'\n\nexport * from './utils.js'\nexport { TreemapController, TreemapElement }\n"],"names":["scaleRect","sq","xScale","yScale","sp","sp2","x","getPixelForValue","y","w","h","height","hidden","width","layoutDefaults","displayMode","rtl","spacing","limit","value","min","max","Math","parseBorderWidth","maxW","maxH","o","toTRBL","b","bottom","l","left","r","right","t","top","getDims","itm","w2","s2","key","a","_normalized","d1","d2","ar","sqrt","assignRow","rect","dims","sum","s","iw","_ix","getX","_iy","Rect","area","this","ih","dir","side","map","arr","nsum","row","get","maxd2","totd1","constructor","unsorted","getNewStat","sa","v","n","ratio","nmax","nmin","push","stat","_arr","Object","assign","setStat","StatArray","length","reset","_hist","Infinity","pushIf","fn","args","nstat","isOlderPart","act","req","startsWith","getGroupKey","lvl","String","hasGroupValue","scanTreeObject","keys","leafKey","obj","tree","result","objIndex","record","reduce","reduced","item","i","forEach","k","childKey","child","isObject","splice","normalizeTreeToArray","data","maxVal","element","ikeys","groupKey","getPath","groups","defaultValue","path","grp","join","resolveGroup","allGroups","groupIndex","idx","group","ensureGroup","tmp","groupValue","addKeys","tmpRef","values","mainGrp","mainValue","slice","create","ret","resolvedAllGroups","resolvedGroupIndex","itemGroup","g","label","children","ak","index","_idx","sort","requireVersion","pkg","ver","strict","parts","split","Number","parseInt","Error","WEIGHT_KEY","compareAspectRatio","oldStat","newStat","os2","ns2","l2","or","toNodes","items","node","_data","vs","undefined","gs","sortNodes","nodes","weighted","widthCache","Map","fontFor","fonts","measureLabelSize","ctx","lines","fontsKey","prev","string","mapKey","_measureText","size","save","count","font","text","measureText","lineHeight","restore","clear","set","measureLines","styles","line","drawTextBlock","block","align","colors","padding","textAlign","lineAlign","calculateBlockLeft","calculateLineX","textBaseline","offset","style","fillStyle","fillText","calculateBlockTop","options","labelSize","position","sliceTextToFitWidth","ellipsisWidth","currentWidth","lowerBoundLen","upperBoundLen","currentLen","floor","slicedText","wrapToWidth","fits","pushWord","word","chunk","char","candidate","toLines","content","wrap","paragraphs","isArray","entry","paragraph","piece","shouldDrawCaption","display","toFont","valueOrDefault","getCaptionHeight","captionHeight","drawText","layout","captions","labels","defined","isLeaf","resolveOption","formatter","callbackContext","color","hoverColor","overflow","maxWidth","maxHeight","hoverFont","optFont","active","Array","f","getFontFromOptions","lblToDraw","labelToDraw","isNumber","fitRatio","_lineHeight","toFonts","rewrapped","trimmed","keptLines","keptStyles","used","dropped","last","applyEllipsis","optColor","clipY","labelBlock","oFont","resolveCaptionText","captionText","captionBlock","beginPath","clip","clipToPadding","context","$context","raw","type","option","buildHierarchy","gidx","parentGroupValue","glen","gdata","filter","_item","nextGroupIndex","defineProperty","configurable","writable","applyValueScale","scaleFor","withOthers","others","applyOthers","scale","_children","weight","total","scaled","isFinite","minCount","threshold","some","weightOf","small","kept","includes","bucket","isOthers","sumValues","grouped","find","totals","entries","VALUE_SCALES","log","log1p","flattenNodes","flat","layoutLevel","parentSum","rectangle","packInto","getSubRect","layoutNodes","isWeighted","applyHeaderBoxes","valueScale","borderWidth","bw","subRect","buildNodes","input","clampFraction","fallback","registerTooltipPositioner","tooltipPlugin","registry","plugins","positioners","treemap","at","tooltipPosition","TreemapController","DatasetController","initialize","enableOptionSharing","super","getMinMax","axis","configure","getMeta","_regionBounds","r1","r2","_rect","_rectChanged","region","_regionWarned","console","warn","_layoutOptions","dataset","getDataset","buildOrUpdateElements","resetNewElements","parse","meta","_parsed","elements","previous","dataElementType","_resetFrom","_start","_count","concat","sumKeys","layoutOptions","fingerprint","layoutKey","JSON","stringify","_key","layoutChanged","_layoutKey","_fingerprint","_nodes","_layoutDirty","getContext","mode","prototype","call","parsed","getParsed","getLabelAndValue","update","resetFrom","updateElements","rects","start","firstOpts","resolveDataElementOptions","sharedOptions","getSharedOptions","includeOptions","properties","updateElement","updateSharedOptions","draw","chartArea","chart","metadata","clipArea","ilen","unclipArea","datasetIndex","getBounds","useFinalPosition","getProps","boundingRects","bounds","border","radius","toTRBLCorners","maxR","bottomLeft","bottomRight","topLeft","topRight","parseBorderRadius","borderRadius","outer","inner","inRange","skipX","skipY","addNormalRectPath","id","version","defaults","animations","numbers","descriptors","_indexable","_scriptable","_fallback","name","overrides","hover","interaction","includeInvisible","intersect","tooltip","callbacks","title","scales","alignToPixels","reverse","beforeRegister","Chart","afterRegister","afterUnregister","TreemapElement","Element","addRectPath","addRoundedRectPath","borderColor","fill","backgroundColor","mouseX","mouseY","inXRange","inYRange","getCenterPoint","cfg","defaultRoutes","register","stack","res","next","pop"],"mappings":";;;;;;yWAAO,SAASA,EAAUC,EAASC,EAAaC,EAAaC,GAC3D,MAAMC,EAAW,EAALD,EACNE,EAAIJ,EAAOK,iBAAiBN,EAAGK,GAC/BE,EAAIL,EAAOI,iBAAiBN,EAAGO,GAC/BC,EAAIP,EAAOK,iBAAiBN,EAAGK,EAAIL,EAAGQ,GAAKH,EAC3CI,EAAIP,EAAOI,iBAAiBN,E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
|
|
2
|
+
import type { DatasetController } from 'chart.js' with { 'resolution-mode': 'import' };
|
|
3
|
+
export default class TreemapController extends DatasetController {
|
|
4
|
+
static readonly id: string;
|
|
5
|
+
static readonly defaults: Record<string, unknown>;
|
|
6
|
+
static readonly descriptors: Record<string, unknown>;
|
|
7
|
+
static readonly overrides: Record<string, unknown>;
|
|
8
|
+
static readonly beforeRegister: () => void;
|
|
9
|
+
static readonly afterRegister: () => void;
|
|
10
|
+
static readonly afterUnregister: () => void;
|
|
11
|
+
dataElementType: new () => any;
|
|
12
|
+
options: any;
|
|
13
|
+
_rect: any;
|
|
14
|
+
_rectChanged: boolean;
|
|
15
|
+
_nodes: LayoutNode[];
|
|
16
|
+
_regionWarned: boolean;
|
|
17
|
+
_layoutDirty: boolean;
|
|
18
|
+
_fingerprint: string | undefined;
|
|
19
|
+
_layoutKey: string | undefined;
|
|
20
|
+
_resetFrom: number | undefined;
|
|
21
|
+
constructor(chart: any, datasetIndex: number);
|
|
22
|
+
initialize(): void;
|
|
23
|
+
getMinMax(scale: any): {
|
|
24
|
+
max: number;
|
|
25
|
+
min: number;
|
|
26
|
+
};
|
|
27
|
+
configure(): void;
|
|
28
|
+
/**
|
|
29
|
+
* The part of the chart area this dataset lays out into.
|
|
30
|
+
*
|
|
31
|
+
* Every dataset shares the chart's single pair of linear scales, whose max is
|
|
32
|
+
* the full chart area in pixels, so a region is just a rectangle in that
|
|
33
|
+
* space and no scale has to change.
|
|
34
|
+
*/
|
|
35
|
+
_regionBounds(w: number, h: number): {
|
|
36
|
+
h: number;
|
|
37
|
+
w: number;
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Options that shape the layout rather than a single rectangle, resolved once
|
|
43
|
+
* per dataset. Reading them from `this.options` rather than from the raw
|
|
44
|
+
* dataset is what makes `options.datasets.treemap` work for all of them.
|
|
45
|
+
*/
|
|
46
|
+
_layoutOptions(): LayoutOptions;
|
|
47
|
+
/**
|
|
48
|
+
* Chart.js calls this before `configure()`, so the chart area is not
|
|
49
|
+
* available here - see the hierarchy pass in `./layout`, which does not need
|
|
50
|
+
* one. Elements are created from the parsed nodes rather than from
|
|
51
|
+
* `dataset.data`, because a treemap with groups has more rectangles than the
|
|
52
|
+
* user supplied rows.
|
|
53
|
+
*/
|
|
54
|
+
buildOrUpdateElements(resetNewElements?: boolean): void;
|
|
55
|
+
parse(_start: number, _count: number): void;
|
|
56
|
+
getContext(index: number, active?: boolean, mode?: string): any;
|
|
57
|
+
getLabelAndValue(index: number): {
|
|
58
|
+
label: string;
|
|
59
|
+
value: string;
|
|
60
|
+
};
|
|
61
|
+
update(mode: any): void;
|
|
62
|
+
updateElements(rects: any[], start: number, count: number, mode: any): void;
|
|
63
|
+
draw(): void;
|
|
64
|
+
}
|