{"id":18332911,"url":"https://github.com/anychart/anychart-nodejs","last_synced_at":"2025-04-06T03:34:01.054Z","repository":{"id":49840713,"uuid":"75901502","full_name":"AnyChart/AnyChart-NodeJS","owner":"AnyChart","description":"ARCHIVED. AnyChart NodeJS module provides an easy way to generate SVG, JPG and PNG images of the charts on the server side.","archived":false,"fork":false,"pushed_at":"2018-02-13T15:13:17.000Z","size":7793,"stargazers_count":47,"open_issues_count":12,"forks_count":8,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-21T16:21:49.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.anychart.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnyChart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-08T04:01:06.000Z","updated_at":"2024-11-14T02:20:34.000Z","dependencies_parsed_at":"2022-09-21T16:01:31.711Z","dependency_job_id":null,"html_url":"https://github.com/AnyChart/AnyChart-NodeJS","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2FAnyChart-NodeJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2FAnyChart-NodeJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2FAnyChart-NodeJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2FAnyChart-NodeJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnyChart","download_url":"https://codeload.github.com/AnyChart/AnyChart-NodeJS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430838,"owners_count":20937873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T19:40:35.789Z","updated_at":"2025-04-06T03:33:56.043Z","avatar_url":"https://github.com/AnyChart.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://cdn.anychart.com/images/logo-transparent-segoe.png?2\" width=\"234px\" alt=\"AnyChart - Robust JavaScript/HTML5 Chart library for any project\"\u003e](https://www.anychart.com)\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Package Quality][quality-image]][quality-url]\n[![Build status][travis-image]][travis-url]\n[![David-dm][dependencies-image]][dependencies-url]\n\u003c!--[![License][licence-image]][licence-url]--\u003e\n\n\n# AnyChart NodeJS module.\n\nAnyChart NodeJS module provides an easy way to generate SVG, JPG and PNG images of the charts on the server side.\nConsider it for reporting systems that send charts by email or social networks sharing applications.\n\n## Table of Contents\n\n* [Download and install](#download-and-install)\n* [Quick start](#quick-start)\n* [Export Module API](#export-module-api)\n* [Examples](#examples)\n* [Contacts](#contacts)\n* [Links](#links)\n* [License](#license)\n\n## Download and install\nIMPORTANT: Requires Node.js 6 or newer.\nYou can install AnyChart NodeJS export module using **npm**, **bower** or **yarn**:\n\n* `npm install anychart-nodejs`\n* `bower install anychart-nodejs`\n* `yarn add anychart-nodejs`\n\nAnyChart NodeJS module requires [ImageMagick](https://www.imagemagick.org/script/index.php) and [librsvg](https://github.com/GNOME/librsvg) to create images. \n\nInstall ImageMagick and librsvg on Linux:\n\n```\napt-get install imagemagick librsvg2-dev librsvg2-bin\n```\n\nInstall ImageMagick and librsvg on Mac OS X\n\n```\nbrew install imagemagick librsvg\n```\n\nInstall ImageMagick and librsvg on Windows:\n\n- [imagemagick](https://www.imagemagick.org/script/download.php)\u003cbr\u003e\n- [GTK+ bundle](http://win32builder.gnome.org/gtk+-bundle_3.6.4-20131201_win64.zip)\u003cbr\u003e\n- [RSVG lib](https://downloads.sourceforge.net/project/tumagcc/converters/rsvg-convert.exe?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Ftumagcc%2Ffiles%2Frsvg-convert.exe%2Fdownload\u0026ts=1500995628\u0026use_mirror=netix)\n\n## Quick start \nTo generate JPG image a chart from chart instance, create index.js file with the following content:\n```javascript\n// require file system and jsdom\nvar fs = require('fs');\n\n// For jsdom version 10 or higher.\n// Require JSDOM Class.\nvar JSDOM = require('jsdom').JSDOM;\n// Create instance of JSDOM.\nvar jsdom = new JSDOM('\u003cbody\u003e\u003cdiv id=\"container\"\u003e\u003c/div\u003e\u003c/body\u003e', {runScripts: 'dangerously'});\n// Get window\nvar window = jsdom.window;\n\n// For jsdom version 9 or lower\n// var jsdom = require('jsdom').jsdom;\n// var document = jsdom('\u003cbody\u003e\u003cdiv id=\"container\"\u003e\u003c/div\u003e\u003c/body\u003e');\n// var window = document.defaultView;\n\n// require anychart and anychart export modules\nvar anychart = require('anychart')(window);\nvar anychartExport = require('anychart-nodejs')(anychart);\n\n// create and a chart to the jsdom window.\n// chart creating should be called only right after anychart-nodejs module requiring\nvar chart = anychart.pie([10, 20, 7, 18, 30]);\nchart.bounds(0, 0, 800, 600);\nchart.container('container');\nchart.draw();\n\n// generate JPG image and save it to a file\nanychartExport.exportTo(chart, 'jpg').then(function(image) {\n  fs.writeFile('anychart.jpg', image, function(fsWriteError) {\n    if (fsWriteError) {\n      console.log(fsWriteError);\n    } else {\n      console.log('Complete');\n    }\n  });\n}, function(generationError) {\n  console.log(generationError);\n});\n```\n\nRun the following command in the command line:\n```\n$ node index.js\n\u003e\u003e Complete\n```\n\nTo generate PDF image a chart from Java Script string, create index.js file with the following content:\n```javascript\n// require file system and jsdom\nvar fs = require('fs');\n\n// require only anychart export module\nvar anychartExport = require('anychart-nodejs');\n\n// define javascript string that represent code of chart creating\nvar chart = \"var chart = anychart.pie([10, 20, 7, 18, 30]); chart.bounds(0, 0, 800, 600); chart.container('container'); chart.draw()\";\n\n// generate PDF image and save it to a file\nanychartExport.exportTo(chart, 'pdf').then(function(image) {\n  fs.writeFile('anychart.pdf', image, function(fsWriteError) {\n    if (fsWriteError) {\n      console.log(fsWriteError);\n    } else {\n      console.log('Complete');\n    }\n  });\n}, function(generationError) {\n  console.log(generationError);\n});\n```\n\nRun the following command in the command line:\n```\n$ node index.js\n\u003e\u003e Complete\n```\n\n\n## Export Module API\n### `exportTo(target, options, callback):Promise`\nGenerate an image asynchronously.  \n**Parameters:**  \n\nName | Type | Description\n--- | --- | ---\n`target` | SVG string, XML string, Java Script string, a chart or a stage instance | **required** Data to be exported.\n`outputType` | string | Output type, possible values are: svg, jpg, png, pdf. Default: 'jpg'\n`dataType` | string | Type of target.\n`document` | Document | Document object where was rendered chart or should be.\n`containerId` | string | Id of container.\n`resources` | Array.\\\u003cstring\\\u003e | Links to external resources.\n`callback` | Function | The result callback.\n\n**Returns:**  \nPromise if no callback passed.\n\n### `exportToSync(target, options):Object`\nGenerate an image synchronously.  \n\n**Parameters:**\n\nName | Type | Description\n--- | --- | ---\n`target` | SVG string, XML string, Java Script string, a chart or a stage instance | **required** Data to be exported.\n`outputType` | string | Output type, possible values are: svg, jpg, png, pdf.\n`dataType` | string | Type of target.\n`document` | Document | Document object where was rendered chart or should be.\n`containerId` | string | Id of container.\n`resources` | Array.\\\u003cstring\\\u003e | Links to external resources.\n\n**Returns:**  \nArrayBuffer\n\n### `loadFont(path, callback):Promise`\nLoads the specified font asynchronously.\n\n**Parameters:**\n\nName | Type | Description\n--- | --- | ---\n`path` | string | Path to the font.\n`callback` | Function | The result callback.\n\n**Returns:**  \nPromise if no callback passed.\n\n\n### `loadFontSync(path):Object`\nLoads the specified font synchronously.\n\n**Parameters:**\n\nName | Type | Description\n--- | --- | ---\n`path` | string | Path to font.\n\n**Returns:**  \nObject\n\n## Examples \nGenerating PDF image a chart with that requires external resources:\n```javascript\n// require file system and jsdom\nvar fs = require('fs');\n\n// require only anychart export module\nvar anychartExport = require('anychart-nodejs');\n\n// define javascript string that represent code of chart creating\nvar chart = \"var chart = anychart.map(); chart.bounds(0, 0, 800, 600); chart.geoData('anychart.maps.united_states_of_america'); chart.container('container'); chart.draw()\";\n\n// exporting parameters\nvar params = {\n\toutputType: 'pdf',\n\tresources: [\n\t\t'https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js',\n\t\t'https://cdn.anychart.com/releases/v8/geodata/countries/united_states_of_america/united_states_of_america.js'\n\t]\n};\n\n// generate PDF image and save it to a file\nanychartExport.exportTo(chart, params).then(function(image) {\n  fs.writeFile('anychart.pdf', image, function(fsWriteError) {\n    if (fsWriteError) {\n      console.log(fsWriteError);\n    } else {\n      console.log('Complete');\n    }\n  });\n}, function(generationError) {\n  console.log(generationError);\n});\n```\n\nRun the following command in the command line:\n```\n$ node index.js\n\u003e\u003e Complete\n```\n\nPlease, take a look at examples:\n* [Report Generation Utility](https://github.com/anychart-integrations/nodejs-report-generation-utility)\n* [Image Generation Utility](https://github.com/anychart-integrations/nodejs-image-generation-utility)\n* [Export Server Application](https://github.com/anychart-integrations/nodejs-export-server-application)\n\n## Contacts\n\n* Web: [www.anychart.com](www.anychart.com)\n* Email: [contact@anychart.com](mailto:contact@anychart.com)\n* Twitter: [anychart](https://twitter.com/anychart)\n* Facebook: [AnyCharts](https://www.facebook.com/AnyCharts)\n* LinkedIn: [anychart](https://www.linkedin.com/company/anychart)\n\n## Links\n\n* [AnyChart Website](https://www.anychart.com)\n* [Download AnyChart](https://www.anychart.com/download/)\n* [AnyChart Licensing](https://www.anychart.com/buy/)\n* [AnyChart Support](https://www.anychart.com/support/)\n* [Report Issues](https://github.com/AnyChart/AnyChart-NodeJS/issues)\n* [AnyChart Playground](https://playground.anychart.com)\n* [AnyChart Documentation](https://docs.anychart.com)\n* [AnyChart API Reference](https://api.anychart.com)\n* [AnyChart Sample Solutions](https://www.anychart.com/solutions/)\n* [AnyChart Integrations](https://www.anychart.com/integrations/)\n\n## License\n\n[© AnyChart.com - JavaScript charts](http://www.anychart.com). [![Analytics](https://ga-beacon.appspot.com/UA-228820-4/Plugins/NodeJS?pixel\u0026useReferer)](https://github.com/igrigorik/ga-beacon)\n\n[npm-image]: https://img.shields.io/npm/v/anychart-nodejs.svg\n[npm-url]: https://www.npmjs.com/package/anychart-nodejs\n[downloads-image]: https://img.shields.io/npm/dm/anychart-nodejs.svg\n[downloads-url]: https://www.npmjs.com/package/anychart-nodejs\n[quality-image]: http://npm.packagequality.com/shield/anychart-nodejs.svg\n[quality-url]: http://packagequality.com/#?package=anychart-nodejs\n[licence-image]: https://img.shields.io/npm/l/anychart-nodejs.svg\n[licence-url]: https://github.com/AnyChart/AnyChart-NodeJS/blob/master/LICENSE\n[travis-image]: https://img.shields.io/travis/AnyChart/AnyChart-NodeJS.svg?branch=master\u0026label=unit\n[travis-url]: https://travis-ci.org/AnyChart/AnyChart-NodeJS\n[dependencies-image]: https://david-dm.org/AnyChart/AnyChart-NodeJS.svg\n[dependencies-url]: https://david-dm.org/AnyChart/AnyChart-NodeJS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanychart%2Fanychart-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanychart%2Fanychart-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanychart%2Fanychart-nodejs/lists"}