{"id":19560002,"url":"https://github.com/plotdb/layout","last_synced_at":"2026-05-13T08:05:55.885Z","repository":{"id":57137268,"uuid":"328408269","full_name":"plotdb/layout","owner":"plotdb","description":"layout chart components by HTML/CSS.","archived":false,"fork":false,"pushed_at":"2022-01-22T06:38:09.000Z","size":2091,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T10:17:11.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plotdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-10T14:56:21.000Z","updated_at":"2022-01-03T11:13:52.000Z","dependencies_parsed_at":"2022-09-01T03:01:08.857Z","dependency_job_id":null,"html_url":"https://github.com/plotdb/layout","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Flayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Flayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Flayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Flayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plotdb","download_url":"https://codeload.github.com/plotdb/layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240816897,"owners_count":19862384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T05:05:30.658Z","updated_at":"2025-11-20T08:04:40.605Z","avatar_url":"https://github.com/plotdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @plotdb/layout\n\nCompute chart layout by HTML/CSS.\n\n\n# Usage\n\nWe will need 3 elements:\n\n - root node: containing layout and render node. should set with `pdl-layout` class.\n - layout node: provide layout information with `div.pdl-cell` for `g.pdl-cell` with the same `data-name` attr.\n - render node: containing `g.pdl-cell` element corresponding to `pdl-cell` in layout node.\n\nA sample DOM structure in Pug:\n \n    #my-chart.pdl-layout\n      div(data-type=\"layout\")\n        .pdl-cell(data-name=\"yaxis\")\n        .pdl-cell(data-name=\"view\")\n        .pdl-cell\n        .pdl-cell(data-name=\"xaxis\")\n      div(data-type=\"render\")\n        svg\n          g.pdl-cell(data-name=\"yaxis\")\n          g.pdl-cell(data-name=\"view\"): rect(ld-each=\"data\")\n          g\n          g.pdl-cell(data-name=\"xaxis\")\n\n\nthen, init with JS:\n\n    mylayout = new layout({root: '#my-chart'})\n    mylayout.on \\render, -\u003e\n      d3.select('g.pdl-cell[data-name=view]').call -\u003e\n        /* get corresponding node and related size (box{x,y,width,height}) information */\n        @layout{node, box}\n      @get-box('name') # get bounding box with given name\n      @get-node('name') # get DOM node with given name\n      @get-group('name') # get `g` (group) with given name\n    mylayout.init -\u003e ... /* initializing ... */\n\n\nwhen the layout object is no longer needed, one should destroy it:\n\n    mylayout.destroy!\n\n\n## Configuration\n\n - `autoSvg`: true if automatically create corresponding `svg` and `g` element. default true\n   - even with `autoSvg` enabled, user can still prepare partial svg / g elements. `@plotdb/layout` will fill the missing parts automatically.\n - `watchResize`: true if automatically calls `update` when container resized. default true.\n   - by disabling this you will have to manually call `update` when you want to update layout.\n - `round`: set true to automatically round dimensions. default true.\n\n\n## API\n\n - `init(cb)`: initialize layout. optional `cb` callback function.\n   - `cb()`: a function called before `update` but after groups are prepared.\n     - run with the context of the inited layout object.\n     - if it returns a promise, `@plotdb/layout` waits until it resolves before calling `update`\n - `root()`: get root node\n - `getNode(name)`: get layout node by `name`\n - `getNodes`: get all layout nodes in an object, hashed by names\n - `getGroup(name)`: get render `g` by `name`\n - `getGroups`: get all render `g` in an object, hashed by names\n - `getBox(name,cached)`: -\u003e get bounding client rect or node by `name`.\n   - `cached`: return cached version if true. default false ( computed in realtime )\n - `update(opt)`: update layout. ( update position of all groups )\n   - fire rendering event if `opt` is `true`. default false.\n - `destroy()`: destroy function\n - `on(n,cb)`: handle `n` event with `cb` callback function.\n - `fire(n, ...v)`: fire `n` event with parameters in v.\n\n## SVG styling\n\nwhen rendering text manually with SVG, one should be aware of following settings:\n\n - `line-height` should be `1em` in HTML layout.\n - `dominant-baseline` should be `hanging` in SVG text.\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Flayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplotdb%2Flayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Flayout/lists"}