I am to create and export a word cloud to a pdf, How can I go about it using Highcharts?

I am currently trying to use highcharts to create a word cloud so I can display it in a pdf that I have generated. I cannot seem to get it to work.

I am trying to have an offline export because while generating this pdf, I don’t have a website~ to generate the chart and then export it from there.

This is a react typescript project, I am using react-pdf to make the pdf.

current render-word-cloud.jsx

import React, { useEffect, useRef } from 'react';
import Highcharts from 'highcharts';
import HighchartsWordCloud from 'highcharts/modules/wordcloud';


const RenderWordCloud = ({ data, title, onChartRendered }) => {
  const chartRef = useRef(null);

  useEffect(() => {
    HighchartsWordCloud(Highcharts); // Initialize the Word Cloud module

    Highcharts.chart(chartRef.current, {
      series: [{
        type: 'wordcloud',
        data: JSON.parse(data)
      }],
      title: {
        text: title
      },
      chart: {
        events: {
          load: function () {
            const imageData = this.getSVG(); // Get the SVG of the chart
            onChartRendered(imageData); // Callback function to handle the chart image data
          }
        },
        renderTo: chartRef.current // Add this line to specify the render target
      },
      exporting: {
        enabled: false // Disable exporting options to prevent unwanted interactions
      }
    });
  }, [data, title, onChartRendered]);

  return <div ref={chartRef}></div>;
};

export default RenderWordCloud;

my types:

import React from 'react';

export interface IRenderWordCloudProps {
  data: string;
  title: string;
  onChartRendered?: (imageData: string) => void;
}

declare const RenderWordCloud: React.FC<IRenderWordCloudProps>;
export default RenderWordCloud;

Finally word cloud render in my renderer.tsx

const renderWordCloudComponent = (
    chartType: string,
    index: number,
    title: string
  ) => {
    let value;
    let logTitle;

    switch (chartType) {
      case 'top100AdjectiveWordCloud':
        value = portalData.detailedAnalysis.details.adjectiveData;
        logTitle = 'Top 100 Adjective Word Cloud';
        break;
      case 'top100NounWordCloud':
        value = portalData.detailedAnalysis.details.nounData;
        logTitle = 'Top 100 Noun Word Cloud';
        break;
      default:
        console.error('Unsupported word cloud type.');
        return <React.Fragment />;
    }

    console.log(`${logTitle} / ${title || 'No Title'} + ${index}:`, value);

    const handleChartRendered = (imageData: string) => {
      console.log('Chart rendered as image:', imageData);
      // Use imageData for your PDF generation logic
      // For example, you might add it to your PDF as an image
    };

    return (
      <RenderWordCloud
        data={JSON.stringify(value)}
        title={logTitle}
        onChartRendered={handleChartRendered}
      />
    );
  };

I’m not sure if I’m on the right path here but that code gives me this error.

{"errorType": "TypeError", "errorMessage": "Cannot read properties of undefined (reading 'hasOwnProperty')", "trace": ["TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')", " at i (/node_modules/highcharts/modules/wordcloud.js:8:343)", " at HighchartsWordcloud (/node_modules/highcharts/modules/wordcloud.js:8:510)", " at e (/src/cell-components/render-word-cloud.jsx:10:5)", " at Ue (/node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js:108:200)", " at eventHandler (/node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js:156:231)", " at Mb (/node_modules/scheduler/cjs/scheduler.development.js:818:12)", " at hc (/node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js:29:325)", " at Vf (/node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js:155:214)", " at callback (/node_modules/node_modules/react-reconciler/cjs/react-reconciler.production.min.js:155:121)", " at Hr (/node_modules/scheduler/cjs/scheduler.development.js:762:34)"]}

New contributor

user26601295 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật