Created
June 14, 2019 23:24
-
-
Save msrivastav13/66d58042063ae26d6f74d90a582089b2 to your computer and use it in GitHub Desktop.
wordcloud lwc demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<lightning-card title="Word Cloud Demo"> | |
<canvas class="my_canvas" lwc:dom="manual"></canvas> | |
</lightning-card> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
import {loadScript} from 'lightning/platformResourceLoader'; | |
import wordcloud from '@salesforce/resourceUrl/wordcloud2'; | |
export default class Wordcloud extends LightningElement { | |
list = [['foo', 12], ['bar', 6], ['foo', 20], ['bar', 18]]; | |
renderedCallback() { | |
if (this.cloudInit) { | |
return; | |
} | |
this.cloudInit = true; | |
loadScript(this, wordcloud) | |
.then(() => { | |
this.initializeWordCloud(); | |
}) | |
.catch(error => { | |
// eslint-disable-next-line no-console | |
console.log(error); | |
}); | |
} | |
initializeWordCloud(){ | |
window.WordCloud(this.template.querySelector('canvas.my_canvas'), { | |
list: this.list | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | |
<apiVersion>46.0</apiVersion> | |
<isExposed>true</isExposed> | |
<description>A LWC Bundle</description> | |
<masterLabel>wordcloud</masterLabel> | |
<targets> | |
<target>lightning__HomePage</target> | |
</targets> | |
</LightningComponentBundle> |
@msrivastav I am trying to built word cloud , on which i am storing values from different fields from different objects and storing them in a list and than displaying on word cloud , But it is not happening. Please help
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The library referenced in static resource
https://github.com/adityanaag3/wordcloud2.js/blob/locker-fix/src/wordcloud2.js