DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Client Side Exporting in Highchart

This article tackles the idea and code of client-side exporting in HighChart.

Sibeesh Venu user avatar by
Sibeesh Venu
·
Jun. 04, 16 · Tutorial
Like (6)
Save
Tweet
Share
9.28K Views

Join the DZone community and get the full member experience.

Join For Free

in this post we will discuss how we can enable client-side exporting in highchart . normally, the data of your chart is sent to the external server here . but if your product is already in the production environment, your clients will agree with the idea of sending their data to any third party server. am i right? to overcome this, highchart has given an option called offline-exporting . we will discuss that here.

for starters, there is a demo here .

background

for the past few months, i have been working with a project where i use highchart to manipulate data and show them as charts. now the problem is while exporting the data, all of it was going to the highchart server. i wanted to get rid of this. so, i used the option client-side exporting by adding one extra javascript file: https://code.highcharts.com/modules/offline-exporting.js.

using the code

first, we will populate the chart. for that, you have to add the needed references as follows:

<script src="https://code.jquery.com/jquery-2.2.4.min.js""></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

now, add the chart configuration as follows:

$(function () {
 $('#mychart').highcharts({
 credits: {
 enabled: false
 },
 exporting: {
 chartoptions: {
 plotoptions: {
 series: {
 datalabels: {
 enabled: true
 }
 }
 }
 },
 scale: 3
 },
 title: {
 text: 'my blog vistor count for a week'
 },
 subtitle: {
 text: 'monday to sunday'
 },
 chart: {
 type: 'area'
 },
 xaxis: {
 categories: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat',
 'sun']
 },
 series: [{
 name:'visitor count',
 data: [1005, 558, 1467, 707, 1289, 867, 543]
 }]
 });
});

now, if you run your application, you can see a chart as follows:

high chart

now it's time to check the exporting. if you click on export icon on the right top corner, you will see options such as which format you need to export the data. just click on anything you wish. you can see that the data is being seny to the server in the top left. to overcome this, you need to add a reference of the file called offline-exporting.js.

<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>

that’s it. you are done.

please note that this feature is not supported in browser ie 8, so if you load this chart in any unsupported browser, the module will fall back to the export server. this can be handled with the option fallbacktoexportserver: false . you need to set this option in your exporting settings as follows:

exporting: {
 chartoptions: {
 plotoptions: {
 series: {
 datalabels: {
 enabled: true
 }
 }
 }
 },
 scale: 3,
 fallbacktoexportserver: false
 }

in internet explorer, it requires a canvg library to export the chart to png format. but you don’t need to worry about this file. the system will automatically download it file on demand.

for more information, here is a reference for client side exporting.

Highcharts

Published at DZone with permission of Sibeesh Venu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Debugging Threads and Asynchronous Code
  • Why Does DevOps Recommend Shift-Left Testing Principles?
  • Choosing the Best Cloud Provider for Hosting DevOps Tools
  • Spring Boot Docker Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: