UNPKG

node-red-node-ui-vega

Version:
1 lines 5.44 kB
[{"id":"6e1177e7.1537c8","type":"tab","label":"[Vega] Word Cloud","disabled":false,"info":"# Word Cloud Example\n\nShow words of input text in word clound format.\nBased on [Vega Word Cloud Example](https://vega.github.io/vega/examples/word-cloud/)."},{"id":"d42fe828.133c38","type":"ui_vega","z":"6e1177e7.1537c8","group":"bfd79b35.1f1178","name":"Vega","order":1,"width":"10","height":"6","vega":"","x":650,"y":180,"wires":[]},{"id":"c42a1d9f.f228a","type":"template","z":"6e1177e7.1537c8","name":"Compose Vega Spec.","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n \"width\": 480,\n \"height\": 300,\n\n \"data\": [\n {\n \"name\": \"table\",\n \"values\": [\n \"{{payload}}\"\n ],\n \"transform\": [\n {\n \"type\": \"countpattern\",\n \"field\": \"data\",\n \"case\": \"upper\",\n \"pattern\": \"[A-Za-z][\\\\w\\\\-\\\\.']+\\\\w\",\n \"stopwords\": \"(and|its|can|for|using|that|the|then|you|within|such|with|this|which|your|are)\"\n },\n {\n \"type\": \"formula\", \"as\": \"angle\",\n \"expr\": \"[-45, 0, 45][~~(random() * 3)]\"\n },\n {\n \"type\": \"formula\", \"as\": \"weight\",\n \"expr\": \"if(datum.text=='NODE-RED', 600, 320)\"\n }\n ]\n }\n ],\n \"scales\": [\n {\n \"name\": \"color\",\n \"type\": \"ordinal\",\n \"domain\": {\n \"data\": \"table\", \n \"field\": \"text\"\n },\n \"range\": [\"#d5a928\", \"#652c90\", \"#939597\"]\n }\n ],\n \"marks\": [\n {\n \"type\": \"text\",\n \"from\": {\n \"data\": \"table\"\n },\n \"encode\": {\n \"enter\": {\n \"text\": {\n \"field\": \"text\"\n },\n \"align\": {\n \"value\": \"center\"\n },\n \"baseline\": {\n \"value\": \"alphabetic\"\n },\n \"fill\": {\n \"scale\": \"color\", \n \"field\": \"text\"\n }\n }\n },\n \"transform\": [\n {\n \"type\": \"wordcloud\",\n \"size\": [500, 300],\n \"text\": {\n \"field\": \"text\"\n },\n \"rotate\": {\n \"field\": \"datum.angle\"\n },\n \"font\": \"Helvetica Neue, Arial\",\n \"fontSize\": {\n \"field\": \"datum.count\"\n },\n \"fontWeight\": {\n \"field\": \"datum.weight\"\n },\n \"fontSizeRange\": [8, 32],\n \"padding\": 2\n }\n ]\n }\n ]\n}\n","output":"json","x":460,"y":180,"wires":[["d42fe828.133c38"]]},{"id":"c2ed83a6.0e0ed","type":"inject","z":"6e1177e7.1537c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":100,"wires":[["eece011.480e1"]]},{"id":"eece011.480e1","type":"template","z":"6e1177e7.1537c8","name":"Input Text","field":"payload","fieldType":"msg","format":"text","syntax":"plain","template":"Node-RED\nFlow-based programming for the Internet of Things\nNode-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.\nIt provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.\nNode-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range of nodes in the palette. Flows can be then deployed to the runtime in a single-click.\nJavaScript functions can be created within the editor using a rich text editor.\nA built-in library allows you to save useful functions, templates or flows for re-use.\nBuilt on Node.js\nThe light-weight runtime is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi as well as in the cloud.\nWith over 225,000 modules in Node's package repository, it is easy to extend the range of palette nodes to add new capabilities.\nSocial Development\nThe flows created in Node-RED are stored using JSON which can be easily imported and exported for sharing with others.\nAn online flow library allows you to share your best flows with the world.\nGet Started\nNode-RED is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi as well as in the cloud.","output":"str","x":340,"y":100,"wires":[["c42a1d9f.f228a"]]},{"id":"76d2184.a4f72e8","type":"comment","z":"6e1177e7.1537c8","name":"↑ Compose Vega Spec. using Mustache Template","info":"","x":550,"y":220,"wires":[]},{"id":"c3d7fed0.b9c26","type":"comment","z":"6e1177e7.1537c8","name":"↓ Display on Dashboard","info":"","x":700,"y":140,"wires":[]},{"id":"f6263265.42f88","type":"comment","z":"6e1177e7.1537c8","name":"↓ Input Text","info":"","x":350,"y":60,"wires":[]},{"id":"bfd79b35.1f1178","type":"ui_group","z":"","name":"Group 1","tab":"6b52b8b6.04be18","order":2,"disp":false,"width":"10","collapse":false},{"id":"6b52b8b6.04be18","type":"ui_tab","z":"","name":"[Vega] Word Cloud","icon":"dashboard","order":5,"disabled":false,"hidden":false}]