Skip to content

Instantly share code, notes, and snippets.

@amelieykw
Created March 19, 2018 17:00
Show Gist options
  • Save amelieykw/bef1cf85653cc79fdd7f66381c7e47f9 to your computer and use it in GitHub Desktop.
Save amelieykw/bef1cf85653cc79fdd7f66381c7e47f9 to your computer and use it in GitHub Desktop.
[HighChart - word cloud] #Highchart #wordCloud
#container {
min-width: 310px;
max-width: 1000px;
max-height: 200px;
margin: 0 auto
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/wordcloud.js"></script>
<div id="container"></div>
/* var text = 'Proration Interline Acquisition SalesAudit Accounting Tax Disruption(COP/TRR) NGIAutoReval Etsync RET22 HOT22 Exchange Revalidation TermsandConditions SalesReports CouponUsageandControl TRMD Issuance EnhancedSalesFeed';
var lines = text.split(/[,\. ]+/g),
data = Highcharts.reduce(lines, function (arr, word) {
var obj = Highcharts.find(arr, function (obj) {
return obj.name === word;
});
if (obj) {
obj.weight += 1;
} else {
obj = {
name: word,
weight: 1
};
arr.push(obj);
}
return arr;
}, []);
*/
var data = [{name:'Proration', weight:9}, {name:'Interline', weight:11}, {name:'Acquisition',weight: 1}, {name:'Sales Audit', weight:10}, {name:'Accounting', weight:2}, {name:'Tax', weight:13}, {name:'Disruption(COP/TRR)', weight:5}, {name:'NGI Auto Reval', weight:9}, {name:'Etsync', weight:15}, {name:'RET22.0', weight:19}, {name:'HOT22.0', weight:16}, {name:'Exchange', weight:12}, {name:'Revalidation', weight:4}, {name:'Terms and Conditions', weight:14}, {name:'Sales Reports', weight:6}, {name:'Coupon Usage and Control', weight:3}, {name:'TRMD', weight:18}, {name:'Issuance', weight:7}, {name:' Enhanced Sales Feed', weight:17}];
Highcharts.chart('container', {
chart: {
backgroundColor: '#222222'
},
series: [{
type: 'wordcloud',
data: data,
name: ''
}],
title: {
text: ''
}
});

Figure - sort before drawing

Figure - final result example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment