Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4: getting error #564

Open
DanielRuf opened this issue Aug 6, 2024 · 6 comments
Open

v4: getting error #564

DanielRuf opened this issue Aug 6, 2024 · 6 comments
Assignees

Comments

@DanielRuf
Copy link

DanielRuf commented Aug 6, 2024

I'm getting the following error:

Cannot create property 'chart' on string '<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="highcharts-root

The config looks like this:

  highcharts: {
    version: 'latest',
    cdnURL: 'https://code.highcharts.com/',
    coreScripts: [ 'highcharts', 'highcharts-more', 'highcharts-3d' ],
    moduleScripts: [
      'stock',
      'map',
      'gantt',
      'exporting',
      'parallel-coordinates',
      'accessibility',
      'boost-canvas',
      'boost',
      'data',
      'data-tools',
      'draggable-points',
      'static-scale',
      'broken-axis',
      'heatmap',
      'tilemap',
      'tiledwebmap',
      'timeline',
      'treemap',
      'treegraph',
      'item-series',
      'drilldown',
      'histogram-bellcurve',
      'bullet',
      'funnel',
      'funnel3d',
      'geoheatmap',
      'pyramid3d',
      'networkgraph',
      'overlapping-datalabels',
      'pareto',
      'pattern-fill',
      'pictorial',
      'price-indicator',
      'sankey',
      'arc-diagram',
      'dependency-wheel',
      'series-label',
      'series-on-point',
      'solid-gauge',
      'sonification',
      'streamgraph',
      'sunburst',
      'variable-pie',
      'variwide',
      'vector',
      'venn',
      'windbarb',
      'wordcloud',
      'xrange',
      'no-data-to-display',
      'drag-panes',
      'debugger',
      'dumbbell',
      'lollipop',
      'cylinder',
      'organization',
      'dotplot',
      'marker-clusters',
      'hollowcandlestick',
      'heikinashi',
      'flowmap',
      'export-data',
      'navigator',
      'textpath'
    ],
    indicatorScripts: [ 'indicators-all' ],
    customScripts: [
      'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js',
      'https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.45/moment-timezone-with-data.min.js'
    ],
    forceFetch: false,
    cachePath: '.cache'
  },
  export: {
    infile: false,
    instr: false,
    options: '<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="highcharts-root" style="font-family: Verdana, sans-serif; font-size: 1rem;" xmlns="http://www.w3.org/2000/svg" width="600" height="219.062" viewBox="0 0 600 219.062" role="img" aria-label="Tool Factory"><desc>Created with Highcharts 11.4.6</desc>...,
    outfile: '....',
    type: 'png',
    constr: 'chart',
    defaultHeight: 400,
    defaultWidth: 600,
    defaultScale: 1,
    height: false,
    width: 600,
    scale: false,
    globalOptions: null,
    themeOptions: false,
    batch: false,
    rasterizationTimeout: 1500
  },
  customLogic: {
    allowCodeExecution: false,
    allowFileResources: false,
    customCode: false,
    callback: false,
    resources: false,
    loadConfig: false,
    createConfig: false
  },
  server: {
    enable: false,
    host: '0.0.0.0',
    port: 7801,
    benchmarking: false,
    proxy: { host: false, port: 8080, timeout: 5000 },
    rateLimiting: {
      enable: false,
      maxRequests: 10,
      window: 1,
      delay: 0,
      trustProxy: false,
      skipKey: false,
      skipToken: false
    },
    ssl: { enable: false, force: false, port: 443, certPath: false }
  },
  pool: {
    minWorkers: 4,
    maxWorkers: 8,
    workLimit: 40,
    acquireTimeout: 5000,
    createTimeout: 5000,
    destroyTimeout: 5000,
    idleTimeout: 30000,
    createRetryInterval: 200,
    reaperInterval: 1000,
    benchmarking: false
  },
  logging: {
    level: 4,
    file: 'highcharts-export-server.log',
    dest: 'log/',
    toConsole: true,
    toFile: true
  },
  ui: { enable: false, route: '/' },
  other: {
    nodeEnv: 'production',
    listenToProcessExits: true,
    noLogo: false,
    hardResetPage: false,
    browserShellMode: true
  },
  debug: {
    enable: false,
    headless: true,
    devtools: false,
    listenToConsole: false,
    dumpio: false,
    slowMo: 0,
    debuggingPort: 9222
  },
  customCode: { allowCodeExecution: 1, callback: null }
}
@DanielRuf
Copy link
Author

Ah I see now.

Renamed the customCode section of the options config to the customLogic in order to avoid confusion with the existing customCode property within.

@DanielRuf
Copy link
Author

After further checks it seems the documentation is outdated.

Instead of info.data it should be info.result.

After fixing that, it says Error: ENOENT: no such file or directory, open '...\public\resources.json'.
This seems to come from https://github.com/highcharts/node-export-server/blob/master/lib/chart.js#L302-L331.

@PaulDalek
Copy link
Contributor

Hi @DanielRuf,

Thanks for reporting this as well. While I am indeed getting an error when trying to export the chart, it is related to another minor bug (which I will fix), and I cannot reproduce the error related to the resources.json file. Could you provide me with a simple example where this issue is reproduced?

@DanielRuf
Copy link
Author

DanielRuf commented Aug 6, 2024

@PaulDalek when I have this config, I get the error:

customLogic: {
    allowCodeExecution: true,
    allowFileResources: false,
    customCode: false,
    callback: false,
    resources: false,
    loadConfig: false,
    createConfig: false
  },

When I use this, I do not get the resources.json error:

customLogic: {
    allowCodeExecution: true,
    allowFileResources: false,
    customCode: false,
    callback: false,
    resources: false,
    loadConfig: false,
    createConfig: false,
    resources: ''
  },

@PaulDalek PaulDalek self-assigned this Aug 6, 2024
@PaulDalek
Copy link
Contributor

@DanielRuf Ok, I found it. I needed to change the allowCodeExecution to true. The behavior is expected, as it looks for the default resources.json file (just like in the older versions) and, if it doesn't find one, it throws an error which is handled and logs a warning with the error's stack. Other than that, the exporting process works as expected. I agree, though, that instead of displaying the stack, the warning log alone will suffice. I'll prepare a fix for that.

@DanielRuf
Copy link
Author

So far I have moved to the CLI where the issue does not exist with the same parameters. So I guess there is some inconsistence between the NodeJS module and the CLI regarding the handling of options / settings and parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants