Giter Club home page Giter Club logo

Comments (8)

tbvjwodn2 avatar tbvjwodn2 commented on May 3, 2024 2

same here, my next.js complains about this

ReferenceError: window is not defined
    at Object.<anonymous> (Z:\xx\StockDashboard\next\node_modules\hammerjs\hammer.js:2643:4)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Z:\xx\StockDashboard\next\node_modules\chartjs-plugin-zoom\dist\chartjs-plugin-zoom.js:8:110
    at Object.<anonymous> (Z:\xx\StockDashboard\next\node_modules\chartjs-plugin-zoom\dist\chartjs-plugin-zoom.js:11:3)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)

from react-chartjs-2.

Oceanestars avatar Oceanestars commented on May 3, 2024 2

@tbvjwodn2 What fixed it for me in NextJS at least(So maybe even if you don't use NextJS some stuff on that page can be useful) is I had to import the parent component that contained the chart dynamically

import dynamic from 'next/dynamic'

const SidePanel = dynamic(() => import('./components/sidePanel'), { ssr: false });

That side panel component has my line chart chart from reach chart.

from react-chartjs-2.

gor181 avatar gor181 commented on May 3, 2024

Hey @mira-thakkar,

Thanks for reaching out.

When doing server rendering there is no window available thus you are unable to render them server side.

The error you are getting is directly from the chart.js library, unfortunately as per my knowledge there isn't much we can do..

from react-chartjs-2.

gor181 avatar gor181 commented on May 3, 2024

If you manage to find a workaround please do post it to this issue so other people will be able to reference it.

Closing till then.
Thank you for reporting.

from react-chartjs-2.

nevace avatar nevace commented on May 3, 2024

This is horrible but it works.. reactjs/react-chartjs#57

from react-chartjs-2.

danieljames-dj avatar danieljames-dj commented on May 3, 2024

This error is happening for my next.js application, did anybody got a solution for this?

from react-chartjs-2.

tbvjwodn2 avatar tbvjwodn2 commented on May 3, 2024

@tbvjwodn2 What fixed it for me in NextJS at least(So maybe even if you don't use NextJS some stuff on that page can be useful) is I had to import the parent component that contained the chart dynamically

import dynamic from 'next/dynamic'

const SidePanel = dynamic(() => import('./components/sidePanel'), { ssr: false });

That side panel component has my line chart chart from reach chart.

Thank you for the help! :)

from react-chartjs-2.

yashwason avatar yashwason commented on May 3, 2024

@tbvjwodn2 What fixed it for me in NextJS at least(So maybe even if you don't use NextJS some stuff on that page can be useful) is I had to import the parent component that contained the chart dynamically

import dynamic from 'next/dynamic'

const SidePanel = dynamic(() => import('./components/sidePanel'), { ssr: false });

That side panel component has my line chart chart from reach chart.

This works perfectly!

from react-chartjs-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.