Skip to content

Commit

Permalink
Allow functions for the exporting.filename configuration option (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
A---- committed Jul 7, 2015
1 parent 98c48d4 commit ecd3ee3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ The only dependencies you must use are HighCharts and HighCharts exporting modul

## Changelog

### v1.1.1 – 2015-07-03

* Allow functions for the `exporting.filename` configuration option (#5)

### v1.1.0 – 2015-07-03

Should have been done months ago, sorry.
IE9 and below will not be supported in a near future and possibly any kind of future. Look at #4 for discussion on this matter.
* Async rendering, fixes issues when chart includes resources (icons and the likes, #2)
* Async rendering, fixes issues when chart includes resources (icons and the likes, #1)
* Documentation fixes (#2)

### v1.0.1 – 2015-04-27
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "highcharts-export-clientside",
"main": "highcharts-export-clientside.js",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/A----/highcharts-export-clientside",
"authors": [
"A---- <A----@users.noreply.github.com>"
Expand Down
18 changes: 17 additions & 1 deletion highcharts-export-clientside.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
*/
H.exporting.MIME_TYPES = MIME_TYPES;

/**
* Little helper function that you can set to the `filename` configuration
* option to use the chart title for the filename when downloaded.
*/
H.exporting.USE_TITLE_FOR_FILENAME = function(options, chartOptions) {
var title = this.chart.title ? chart.title.textStr.replace(/ /g, '-').toLowerCase() : 'chart';
return title;
};

var supportStatus = {};
var buildSupportStatus = function() {
var hasDownloadOrBlob = browserSupportDownload || browserSupportBlob;
Expand Down Expand Up @@ -445,10 +454,17 @@
}

context.type = type;
context.filename = opt.get("filename") + MIME_TYPE_TO_EXTENSION[type];
context.browserSupportDownload = browserSupportDownload;
context.browserSupportBlob = browserSupportBlob;

var filename = opt.get("filename");
if(typeof filename === "function") {
context.filename = filename.bind(this)(options, chartOptions) + MIME_TYPE_TO_EXTENSION[type];
}
else {
context.filename = opt.get("filename") + MIME_TYPE_TO_EXTENSION[type];
}

steps.rendering[type].render(highChartsObject, context, function(data) {
if(steps.rendering[type].postRender) {
steps.rendering[type].postRender(highChartsObject, context);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "highcharts-export-clientside",
"version": "1.1.0",
"version": "1.1.1",
"title": "Highcharts Client-Side Export Module",
"author": {
"name": "A----",
Expand Down

0 comments on commit ecd3ee3

Please sign in to comment.