Word cloud

author(s): Jon Arild Nygård

by Dongor7

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/wordcloud.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<div id="container"></div>

CSS

#container {
  height: 84px;
}

JavaScript

const DEFAULT_DATA_LABELS_OPTIONS = {
    enabled: false,
    format: null,
    style: {
        color: 'black',
        textOutline: false,
        width: 200,
        fontSize: 10,
        lineHeight: 12,
    },
}

const DEFAULT_CHART_OPTIONS = {
    title: {
        text: null,
    },
    chart: {
        zoomType: 'xy',
        panKey: 'ctrl',
        panning: true,
        animation: true,
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        shadow: false,
        style: {
            fontSize: '12px',
        },
    },
    legend: {
        enabled: false,
    },
    plotOptions: {
        series: {
            dataLabels: DEFAULT_DATA_LABELS_OPTIONS,
            point: {
                events: {
                    click: undefined,
                },
            },
        },
    },
    credits: {
        enabled: false,
    },
    exporting: {
        enabled: false,
    },
}

const data = [{
  name: "Difficulty",
  weight: 0.8999999762
}];

Highcharts.chart('container', {
		...DEFAULT_CHART_OPTIONS,
    series: [{
      series: [
        {
          type: 'wordcloud',
          data: data,
          colors: ['#8BC53F'],
        },
      ],
    }],
});