Giter Club home page Giter Club logo

Comments (3)

cvasseng avatar cvasseng commented on July 24, 2024

You should be able to use the (undocumented) themeOptions property to separate theme settings from chart options:

var exportSettings = {
    options: {..chart options...},
    themeOptions: {...theme options..}
};

exporter.export(exportSettings, function (err, res) {...}

So you could load your chart options into options, your theme into themeOption, and then set type to e.g. png or svg. If you need it in two formats per. export (or with two different themes), the best way is probably to mutate the exportSettings and do multiple calls to export(..).

from node-export-server.

tylersticka avatar tylersticka commented on July 24, 2024

Thanks for your response!

I tried using themeOptions but now I'm seeing errors:

Wed Feb 15 2017 09:29:27 GMT-0800 (PST) [error] phantom worker 7 unexpected data - SyntaxError: Expected token ']'

  undefined:1 in appendChild
  :15
  :16
{"filename":"chart.svg"}

The chart.svg is output but without any themeOptions applied.

I was worried this could be caused by some unrelated mistake in my code, so I stripped everything down to the barest essentials, but the issue still remains. Here's my complete simplified JS file:

const exporter = require('highcharts-export-server');

const options ={
  "chart": {
    "type": "pie"
  },
  "title": {
    "text": "Example Title"
  },
  "subtitle": {
    "text": "Example Subtitle"
  },
  "series": [{
    "showInLegend": true,
    "dataLabels": {
      "enabled": true,
      "format": "{y}"
    },
    "data": [
      {
        "y": 529,
        "name": "Data Sample 1"
      },
      {
        "y": 81,
        "name": "Data Sample 2"
      }
    ]
  }]
};

const themeOptions = {
  "lang": {
    "thousandsSep": ","
  },
  "chart": {
    "style": {
      "fontFamily": "\"proxima-nova\", sans-serif"
    }
  },
  "colors": [
    "#008fc4",
    "#46a088",
    "#e21836",
    "#f5d664",
    "#ff6b35",
    "#5b507a"
  ],
  "title": {
    "style": {
      "color": "#353536",
      "fontFamily": "\"proxima-nova-soft\", sans-serif",
      "fontWeight": "600"
    }
  },
  "subtitle": {
    "style": {
      "color": "#747476",
      "fontWeight": "600"
    }
  },
  "legend": {
    "itemStyle": {
      "fontWeight": "400",
      "color": "#353536"
    }
  }
};

const settings = {
  options: options,
  themeOptions: themeOptions,
  type: 'svg',
  outfile: 'chart.svg'
};

exporter.initPool();

exporter.export(settings, (err, res) => {
  exporter.killPool();
  process.exit(1);
});

from node-export-server.

cvasseng avatar cvasseng commented on July 24, 2024

Sorry for the delay!

bbbbfa1 adds a fix for this, I'll push it to NPM once I've taken care of a couple more issues.

Please feel free to reopen if you still experience issues with this.

from node-export-server.

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.