{"id":19672287,"url":"https://github.com/oi-contrib/vislite","last_synced_at":"2025-04-13T03:08:10.380Z","repository":{"id":158276956,"uuid":"633967417","full_name":"oi-contrib/VISLite","owner":"oi-contrib","description":"🎃 灵活、快速、简单的数据可视化交互式跨端前端库 💯","archived":false,"fork":false,"pushed_at":"2025-01-10T14:26:10.000Z","size":3119,"stargazers_count":29,"open_issues_count":4,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T03:08:05.163Z","etag":null,"topics":["canvas","image2d","image3d","miniprogram","svg","typescript","uniapp","vislite","vue","webgl"],"latest_commit_sha":null,"homepage":"https://oi-contrib.github.io/VISLite","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oi-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://zxl20070701.github.io/notebook/home.html"]}},"created_at":"2023-04-28T17:39:36.000Z","updated_at":"2025-02-17T07:41:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"b643ad5e-eb60-4646-ae6a-e18fd2320b34","html_url":"https://github.com/oi-contrib/VISLite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oi-contrib%2FVISLite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oi-contrib%2FVISLite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oi-contrib%2FVISLite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oi-contrib%2FVISLite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oi-contrib","download_url":"https://codeload.github.com/oi-contrib/VISLite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657918,"owners_count":21140846,"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":["canvas","image2d","image3d","miniprogram","svg","typescript","uniapp","vislite","vue","webgl"],"created_at":"2024-11-11T17:11:40.522Z","updated_at":"2025-04-13T03:08:10.347Z","avatar_url":"https://github.com/oi-contrib.png","language":"TypeScript","funding_links":["https://zxl20070701.github.io/notebook/home.html"],"categories":[],"sub_categories":[],"readme":"-   💘 开源不易，去 \u003ci\u003e[Github给个Star](https://github.com/oi-contrib/VISLite) \u003c/i\u003e吧！\n\n\u003cimg src='https://oi-contrib.github.io/VISLite/images/logo.png' height='300px'/\u003e\n\n\u003cp\u003e\n    \u003ca href=\"https://zxl20070701.github.io/toolbox/#/npm-download?packages=vislite\u0026interval=7\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/dm/vislite.svg\" alt=\"downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/vislite\"\u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/vislite.svg\" alt=\"npm\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.jsdelivr.com/package/npm/vislite\"\u003e\n        \u003cimg src=\"https://data.jsdelivr.com/v1/package/npm/vislite/badge\" alt=\"cdn\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/oi-contrib/VISLite/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/issues/oi-contrib/VISLite\" alt=\"issue\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/oi-contrib/VISLite\" target='_blank'\u003e\n        \u003cimg alt=\"GitHub repo stars\" src=\"https://img.shields.io/github/stars/oi-contrib/VISLite\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/oi-contrib/VISLite\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/forks/oi-contrib/VISLite\" alt=\"forks\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://gitee.com/oi-contrib/VISLite\" target='_blank'\u003e\n        \u003cimg alt=\"Gitee repo stars\" src=\"https://gitee.com/oi-contrib/VISLite/badge/star.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://gitee.com/oi-contrib/VISLite\"\u003e\n        \u003cimg src=\"https://gitee.com/oi-contrib/VISLite/badge/fork.svg\" alt=\"forks\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cimg src=\"https://nodei.co/npm/vislite.png?downloads=true\u0026amp;downloadRank=true\u0026amp;stars=true\" alt=\"NPM\"\u003e\n\n# VISLite\n\n`VISLite`是一个使用`TypeScript`开发的可视化库。官网地址：[https://oi-contrib.github.io/VISLite](https://oi-contrib.github.io/VISLite)\n\n主要提供了跨端的画布和计算，开发人员只需要按照文档的描述就可以非常简单的完成包括Web、uni-app、微信小程序、支付宝小程序等平台的可视化开发，除了初始化时可能存在一些差异外，主要的业务代码部分在不同端完全一致。\n\n## 简介\n\n这是一个轻量级的数据可视化资源库，目标是：帮助你更快速、简单、高效的开发出任意的可视化业务产品。\n\n\u003e 本项目已在[开源中国](https://www.oschina.net/p/vislite)中开源，欢迎关注和留言。\n\n## 如何使用？\n\n首先，需要进行安装：\n\n```js\nnpm install --save vislite\n```\n\n然后，准备好画布：\n\n```html\n\u003cdiv id=\"root\" style=\"width:500px;height:300px;\"\u003e\u003c/div\u003e\n```\n\n现在，就可以获取画笔绘制自己需要的内容了。比如获取canvas画笔，绘制一个红色的圆：\n\n```js\nimport { Canvas } from 'vislite';\n\nvar painter = new Canvas(document.getElementById('root'));\n\npainter.config({\n    fillStyle: \"red\"\n}).fillCircle(200, 150, 100);\n```\n\n更复杂的图表，我们也提供了丰富的辅助API。比如使用树布局，可以非常快速的绘制一个树图：\n\n\u003cimg src=\"https://oi-contrib.github.io/VISLite/images/docs/tree.png\" width=\"500\"/\u003e\n\n具体代码如下：\n\n```js\nimport { Canvas, TreeLayout } from 'vislite';\n\nvar painter = new Canvas(document.getElementById('root'));\nvar treeLayout = new TreeLayout();\n\ntreeLayout.setOption({\n    type: \"rect\",\n    direction: \"TB\",\n    x: 250,\n    y: 20,\n    width: 500,\n    height: 260\n});\n\nvar data = {\n    \"name\": \"前端\",\n    \"children\": [{\n        \"name\": \"基础\",\n        \"children\": [{\n            \"name\": \"HTML\"\n        }, {\n            \"name\": \"CSS\"\n        }, {\n            \"name\": \"JavaScript\"\n        }, {\n            \"name\": \"DOM\"\n        }]\n    }, {\n        \"name\": \"框架\"\n    }, {\n        \"name\": \"小技术\"\n    }]\n};\n\nvar tree = treeLayout.use(data);\n\n// 绘制连线\npainter.config({\n    strokeStyle: 'red'\n});\nfor (var key in tree.node) {\n    var pid = tree.node[key].pid;\n\n    // 如果父结点存在，和父结点连起来\n    if (pid) {\n        var dist = (tree.node[key].top - tree.node[pid].top) * 0.5;\n\n        painter\n            .beginPath()\n            .moveTo(tree.node[key].left, tree.node[key].top)\n            .bezierCurveTo(\n                tree.node[key].left, tree.node[key].top - dist,\n                tree.node[pid].left, tree.node[pid].top + dist,\n                tree.node[pid].left, tree.node[pid].top\n            ).stroke();\n    }\n}\n\n// 绘制节点和文字\npainter.config({\n    strokeStyle: 'red',\n    fontSize: 12\n});\nfor (var key in tree.node) {\n    painter.config({\n        fillStyle: \"white\"\n    }).fullCircle(tree.node[key].left, tree.node[key].top, 10);\n\n    painter.config({\n        fillStyle: \"black\"\n    }).fillText(key, tree.node[key].left + 15, tree.node[key].top);\n}\n```\n\n关于树布局更具体的使用细节，你可以访问：[ 《教程 / 树布局》 ](https://oi-contrib.github.io/VISLite/#/course/tree-layout)一节。\n\n## 部分功能\n\n### 常用的算法\n\n我们通过提供可视化常用的算法来帮助你绘制复杂图表。比如下面的树图，通过简单的配置就可以把任意格式的数据变成任意绘制的带坐标的数据：\n\n\u003cimg src=\"https://oi-contrib.github.io/VISLite/images/docs/what_1.png\" width=\"400\"/\u003e\n\n\u003e 上述例子的运行地址：[从左到右树状图](https://oi-contrib.github.io/VISLite/#/example/canvas/tree-layout-lr)。\n\n除了[树布局](https://oi-contrib.github.io/VISLite/#/api/treeLayout)外，我们还提供了：[刻度尺算法](https://oi-contrib.github.io/VISLite/#/api/ruler)来帮助你计算刻度应该如何确定、[等角斜方位投影](https://oi-contrib.github.io/VISLite/#/api/eoap)和[墨卡托投影](https://oi-contrib.github.io/VISLite/#/api/mercator)来绘制地图、[插值函数](https://oi-contrib.github.io/VISLite/#/api/cardinal)来完成折线变光滑的曲线、[变换矩阵](https://oi-contrib.github.io/VISLite/#/api/matrix4)提供各种坐标变换等。\n\n### 画笔加强\n\n我们对画笔进行了加强，使得其更简单好用。比如canvas，抽象出区域的概念，使得无论你绘制的图形多么的不规则，都可以很轻松的实现交互功能：\n\n\u003cimg src=\"https://oi-contrib.github.io/VISLite/images/docs/what_2.png\" width=\"400\"/\u003e\n\n\u003e 上述例子的运行地址：[中国地图](https://oi-contrib.github.io/VISLite/#/example/canvas/china)。\n\n画笔除了像上面那样为了方便交互而补充区域的设计外，还对原来的API进行了一次抽象，使得API更友好简单`（比如WebGL，即使不会3D的人也可以轻松使用，而SVG的使用，你无需去记忆那些晦涩难懂的属性）`，同时，我们还抹平了不同版本浏览器等之间的差异。\n\n### 支持跨端开发\n\n除了Web端外，我们还针对uni-app、微信小程序、支付宝小程序等端进行了支持，并且不同端API保持一致，大大提高了代码的复用性：\n\n\u003cimg src=\"https://oi-contrib.github.io/VISLite/images/docs/what_3.png\" width=\"600\"/\u003e\n\n\u003e 上述例子的运行地址：[金额波浪球](https://oi-contrib.github.io/VISLite/#/example/svg/money-schedule)。\n\n基于实际需要，我们目前对 `Canvas` 提供了跨端支持，除 `Web端` 外，还支持 `原生微信小程序` 、 `原生支付宝小程序` 和 `uni-app端` （编译成H5、微信小程序、支付宝小程序等） ，如果后续有必要，我们会对Canvas支持的端或SVG、WebGL等画笔进行更多端扩展。\n\n## 特点\n\n-   灵活的引入方式：包括npm安装后按照`ES Module`或`CommonJS`规范引入或直接使用script标签的`CDN`方式。\n-   按需引入或全局引入：支持源码TS引入、按需JS引入或者全量引入等多种方式。\n-   简单与复杂共存：一方面我们提供了可视化需要的基础功能，你可以按照自己的需要组合使用；另一方面，为了加速开发，我们针对常见的可视化业务场景进行了封装，可以帮助你快速完成，你可以根据实际情况进行选择。\n-   向下兼容：我们向你保证，同一个大版本下始终向下兼容`（alpha和beta版本为测试版本，不包括）`，因此，无论何时，在同一个大版本号下，最新版本总是最好的选择。\n\n\u003e 版本说明：alpha为开发阶段、beta为发布前测试、rc为候选版本、next为未来版本、无后缀的为正式版本。\n\n## 需求墙\n\n我们的目标是不断完善丰富可视化功能，非常希望获得你宝贵的建议和批评，无论任何想法，都可以给我们[留言](https://github.com/oi-contrib/VISLite/issues)告诉我们。\n\n你所提的任何建议我们都会在最长一周内进行反馈说明。\n\n## 更新日志\n\n详见[正式版更新日志](./CHANGELOG)，我们会在每次发布完正式版本后更新其内容。\n\n## 下一步\n\n我们会在这里列出接下来的工作重心：\n\n-   为加速开发，提供常用坐标系和布局\n-   文档优化（提高可读性、丰富用例、补充教程）\n\n给我们[留言](https://github.com/oi-contrib/VISLite/issues)告诉我们你希望快速扩展的功能，我们会优先你的建议考虑哦～\n\n## 参与贡献\n\n你可以选择下列一项或多项进行参与：\n\n-   代码维护：由于新功能或一些BUG的出现，对代码进行维护和升级。\n-   文档编辑：主要是接口文档和教程需要编辑，这很重要。\n-   用例开发和测试：在项目的test文件夹下有一些测试，而在docs文档中存在一些例子需要补充。\n-   参与讨论：主要是讨论未来如何发展，改造的方向等。\n\n如果有意向加入我们，你可以通过提 [issue](https://github.com/oi-contrib/VISLite/issues) 和我们取到联系，请简单说明一下情况，我们会尽快回复。\n\n你可以查看[VISLite 贡献指南](./.github/CONTRIBUTING.md)文件了解更多细节，查看[AUTHORS.txt](./AUTHORS.txt)了解所有的贡献者。\n\n## 例子项目\n\n### 水分子式 H2O\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/h2o\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/h2o.png\"\u003e\n\u003c/a\u003e\n\n### 手式解锁\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/manual-unlocking\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/manual-unlocking.jpeg\"\u003e\n\u003c/a\u003e\n\n### 3D环图\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/ring3d\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/ring3d.jpeg\"\u003e\n\u003c/a\u003e\n\n### 径向树状图\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/tree-radial\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/tree-radial.jpeg\"\u003e\n\u003c/a\u003e\n\n### 桑基图\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/sankey\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/sankey.jpeg\"\u003e\n\u003c/a\u003e\n\n### 可缩放折线图\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/zoom-line\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/zoom-line.jpeg\"\u003e\n\u003c/a\u003e\n\n### 从上到下树状图\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/tree-orient-top-bottom\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/tree-orient-top-bottom.jpeg\"\u003e\n\u003c/a\u003e\n\n### 可视化大屏\n\n\u003ca href=\"https://oi-contrib.github.io/h5box/dataGUI/index.html#/bigview\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://oi-contrib.github.io/h5box/snipping/bigview.jpeg\"\u003e\n\u003c/a\u003e\n\n\u003e 更多内容，你可以直接访问： [https://oi-contrib.github.io/h5box/dataGUI/index.html](https://oi-contrib.github.io/h5box/dataGUI/index.html)\n\n## 版权\n\nMIT License\n\nCopyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步，再走一步\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foi-contrib%2Fvislite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foi-contrib%2Fvislite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foi-contrib%2Fvislite/lists"}