project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
252 stars 58 forks source link

Trying to install in SvelteKit #83

Closed Antc1993 closed 1 year ago

Antc1993 commented 1 year ago

Describe the bug

Hello, I am trying to install NightVision in SvelteKit but it always gives me the same error 500 Worker is not defined

ReferenceError: Worker is not defined at WebWork.start (/node_modules/night-vision/dist/index-d313a23d.js:4779:23) at new WebWork (/node_modules/night-vision/dist/index-d313a23d.js:4772:10) at Object.instance$e [as instance] (/node_modules/night-vision/dist/index-d313a23d.js:4840:23) at new NightVision2 (/node_modules/night-vision/dist/index-d313a23d.js:11078:25) at index.svelte:9:16 at Object.$$render (/sandbox/node_modules/svelte/internal/index.js:1380:22) at Object.default (root.svelte:38:46) at /sandbox/.svelte-kit/dev/components/layout.svelte:5:41 at Object.$$render (/sandbox/node_modules/svelte/internal/index.js:1380:22) at root.svelte:36:44 Any ideas ? thank you.

Reproduction

https://codesandbox.io/s/bold-moser-82qsx2?file=/src/routes/index.svelte

Steps to reproduce

No response

Javascript Framework

svelte

Logs

No response

Validations

Antc1993 commented 1 year ago

Hello, I was able to solve it this way

```
 import {onMount} from  'svelte';

onMount(async () =>{
    const NightVision =  await import('night-vision');
    function data() {
        return Array(30).fill(1).map((x, i) => [
            new Date(`${i+1} Nov 2022 GMT+0000`).getTime(),
            i * Math.random()
        ])
    }
    let chart = new NightVision.NightVision('chart-container')
    chart.data = {
        panes: [{
            overlays: [{
                name: 'APE Stock',
                type: 'Spline',
                data: data(),
                settings: {
                    precision: 2
                }
            }]
        }]
    }

});

Thanks