/base/000_base/bower_components/highcharts/modules/exporting.src.js |
@@ -1,5 +1,5 @@ |
/** |
* @license Highcharts JS v5.0.10 (2017-03-31) |
* @license Highcharts JS v5.0.12 (2017-05-24) |
* Exporting module |
* |
* (c) 2010-2017 Torstein Honsi |
@@ -38,13 +38,16 @@ |
merge = H.merge, |
pick = H.pick, |
each = H.each, |
objectEach = H.objectEach, |
extend = H.extend, |
isTouchDevice = H.isTouchDevice, |
win = H.win, |
SVGRenderer = H.SVGRenderer; |
userAgent = win.navigator.userAgent, |
SVGRenderer = H.SVGRenderer, |
symbols = H.Renderer.prototype.symbols, |
isMSBrowser = /Edge\/|Trident\/|MSIE /.test(userAgent), |
isFirefoxBrowser = /firefox/i.test(userAgent); |
|
var symbols = H.Renderer.prototype.symbols; |
|
// Add language |
extend(defaultOptions.lang, { |
printChart: 'Print chart', |
@@ -122,64 +125,39 @@ |
symbol: 'menu', |
_titleKey: 'contextButtonTitle', |
menuItems: [{ |
textKey: 'printChart', |
onclick: function() { |
this.print(); |
} |
}, { |
separator: true |
}, { |
textKey: 'downloadPNG', |
onclick: function() { |
this.exportChart(); |
} |
}, { |
textKey: 'downloadJPEG', |
onclick: function() { |
this.exportChart({ |
type: 'image/jpeg' |
}); |
} |
}, { |
textKey: 'downloadPDF', |
onclick: function() { |
this.exportChart({ |
type: 'application/pdf' |
}); |
} |
}, { |
textKey: 'downloadSVG', |
onclick: function() { |
this.exportChart({ |
type: 'image/svg+xml' |
}); |
} |
textKey: 'printChart', |
onclick: function() { |
this.print(); |
} |
// Enable this block to add "View SVG" to the dropdown menu |
/* |
,{ |
|
text: 'View SVG Image', |
onclick: function () { |
var div = doc.createElement('div'); |
div.innerHTML = this.getSVGForExport(); |
|
this.renderTo.parentNode.appendChild(div); |
} |
}, { |
|
text: 'View SVG Source', |
onclick: function () { |
var pre = doc.createElement('pre'); |
pre.innerHTML = this.getSVGForExport() |
.replace(/</g, '\n<') |
.replace(/>/g, '>'); |
|
this.renderTo.parentNode.appendChild(pre); |
} |
}, { |
separator: true |
}, { |
textKey: 'downloadPNG', |
onclick: function() { |
this.exportChart(); |
} |
// */ |
] |
}, { |
textKey: 'downloadJPEG', |
onclick: function() { |
this.exportChart({ |
type: 'image/jpeg' |
}); |
} |
}, { |
textKey: 'downloadPDF', |
onclick: function() { |
this.exportChart({ |
type: 'application/pdf' |
}); |
} |
}, { |
textKey: 'downloadSVG', |
onclick: function() { |
this.exportChart({ |
type: 'image/svg+xml' |
}); |
} |
}] |
} |
} |
}; |
@@ -186,11 +164,8 @@ |
|
// Add the H.post utility |
H.post = function(url, data, formAttributes) { |
var name, |
form; |
|
// create the form |
form = createElement('form', merge({ |
var form = createElement('form', merge({ |
method: 'post', |
action: url, |
enctype: 'multipart/form-data' |
@@ -199,13 +174,13 @@ |
}, doc.body); |
|
// add the data |
for (name in data) { |
objectEach(data, function(val, name) { |
createElement('input', { |
type: 'hidden', |
name: name, |
value: data[name] |
value: val |
}, null, form); |
} |
}); |
|
// submit |
form.submit(); |
@@ -214,7 +189,7 @@ |
discardElement(form); |
}; |
|
extend(Chart.prototype, { |
extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ { |
|
/** |
* A collection of fixes on the produced SVG to account for expando properties, |
@@ -290,13 +265,17 @@ |
/** |
* Return an SVG representation of the chart. |
* |
* @param additionalOptions {Object} Additional chart options for the |
* generated SVG representation. For collections like `xAxis`, `yAxis` or |
* `series`, the additional options is either merged in to the orininal |
* item of the same `id`, or to the first item if a commin id is not |
* found. |
* @param chartOptions {Options} |
* Additional chart options for the generated SVG representation. |
* For collections like `xAxis`, `yAxis` or `series`, the additional |
* options is either merged in to the orininal item of the same |
* `id`, or to the first item if a common id is not found. |
* @return {String} |
* The SVG representation of the rendered chart. |
* @sample highcharts/members/chart-getsvg/ |
* View the SVG from a button |
*/ |
getSVG: function(additionalOptions) { |
getSVG: function(chartOptions) { |
var chart = this, |
chartCopy, |
sandbox, |
@@ -306,7 +285,7 @@ |
sourceHeight, |
cssWidth, |
cssHeight, |
options = merge(chart.options, additionalOptions); // copy the options and add extra options |
options = merge(chart.options, chartOptions); // copy the options and add extra options |
|
|
// IE compatibility hack for generating SVG content that it doesn't really understand |
@@ -374,11 +353,11 @@ |
chartCopy = new H.Chart(options, chart.callback); |
|
// Axis options and series options (#2022, #3900, #5982) |
if (additionalOptions) { |
if (chartOptions) { |
each(['xAxis', 'yAxis', 'series'], function(coll) { |
var collOptions = {}; |
if (additionalOptions[coll]) { |
collOptions[coll] = additionalOptions[coll]; |
if (chartOptions[coll]) { |
collOptions[coll] = chartOptions[coll]; |
chartCopy.update(collOptions); |
} |
}); |
@@ -431,30 +410,63 @@ |
}, |
|
/** |
* Submit the SVG representation of the chart to the server |
* @param {Object} options Exporting options. Possible members are url, type, width and formAttributes. |
* @param {Object} chartOptions Additional chart options for the SVG representation of the chart |
* Exporting module required. Submit an SVG version of the chart to a server |
* along with some parameters for conversion. |
* @param {Object} exportingOptions |
* Exporting options in addition to those defined in {@link |
* https://api.highcharts.com/highcharts/exporting|exporting}. |
* @param {String} exportingOptions.filename |
* The file name for the export without extension. |
* @param {String} exportingOptions.url |
* The URL for the server module to do the conversion. |
* @param {Number} exportingOptions.width |
* The width of the PNG or JPG image generated on the server. |
* @param {String} exportingOptions.type |
* The MIME type of the converted image. |
* @param {Number} exportingOptions.sourceWidth |
* The pixel width of the source (in-page) chart. |
* @param {Number} exportingOptions.sourceHeight |
* The pixel height of the source (in-page) chart. |
* @param {Options} chartOptions |
* Additional chart options for the exported chart. For example a |
* different background color can be added here, or `dataLabels` |
* for export only. |
* |
* @sample highcharts/members/chart-exportchart/ |
* Export with no options |
* @sample highcharts/members/chart-exportchart-filename/ |
* PDF type and custom filename |
* @sample highcharts/members/chart-exportchart-custom-background/ |
* Different chart background in export |
* @sample stock/members/chart-exportchart/ |
* Export with Highstock |
*/ |
exportChart: function(options, chartOptions) { |
exportChart: function(exportingOptions, chartOptions) { |
|
var svg = this.getSVGForExport(options, chartOptions); |
var svg = this.getSVGForExport(exportingOptions, chartOptions); |
|
// merge the options |
options = merge(this.options.exporting, options); |
exportingOptions = merge(this.options.exporting, exportingOptions); |
|
// do the post |
H.post(options.url, { |
filename: options.filename || 'chart', |
type: options.type, |
width: options.width || 0, // IE8 fails to post undefined correctly, so use 0 |
scale: options.scale, |
H.post(exportingOptions.url, { |
filename: exportingOptions.filename || 'chart', |
type: exportingOptions.type, |
width: exportingOptions.width || 0, // IE8 fails to post undefined correctly, so use 0 |
scale: exportingOptions.scale, |
svg: svg |
}, options.formAttributes); |
}, exportingOptions.formAttributes); |
|
}, |
|
/** |
* Print the chart |
* Exporting module required. Clears away other elements in the page and |
* prints the chart as it is displayed. By default, when the exporting |
* module is enabled, a context button with a drop down menu in the upper |
* right corner accesses this function. |
* |
* @sample highcharts/members/chart-print/ |
* Print from a HTML button |
*/ |
print: function() { |
|
@@ -855,28 +867,28 @@ |
|
// Add the buttons on chart load |
Chart.prototype.renderExporting = function() { |
var n, |
exportingOptions = this.options.exporting, |
var chart = this, |
exportingOptions = chart.options.exporting, |
buttons = exportingOptions.buttons, |
isDirty = this.isDirtyExporting || !this.exportSVGElements; |
isDirty = chart.isDirtyExporting || !chart.exportSVGElements; |
|
this.buttonOffset = 0; |
if (this.isDirtyExporting) { |
this.destroyExport(); |
chart.buttonOffset = 0; |
if (chart.isDirtyExporting) { |
chart.destroyExport(); |
} |
|
if (isDirty && exportingOptions.enabled !== false) { |
this.exportEvents = []; |
chart.exportEvents = []; |
|
for (n in buttons) { |
this.addButton(buttons[n]); |
} |
objectEach(buttons, function(button) { |
chart.addButton(button); |
}); |
|
this.isDirtyExporting = false; |
chart.isDirtyExporting = false; |
} |
|
// Destroy the export elements at chart destroy |
addEvent(this, 'destroy', this.destroyExport); |
addEvent(chart, 'destroy', chart.destroyExport); |
}; |
|
Chart.prototype.callbacks.push(function(chart) { |
@@ -908,8 +920,11 @@ |
// testing of export |
/* |
if (!chart.renderer.forExport) { |
var button = doc.createElement('button'); |
button.innerHTML = 'View exported SVG'; |
var button; |
|
// View SVG Image |
button = doc.createElement('button'); |
button.innerHTML = 'View SVG Image'; |
chart.renderTo.parentNode.appendChild(button); |
button.onclick = function () { |
var div = doc.createElement('div'); |
@@ -916,6 +931,18 @@ |
div.innerHTML = chart.getSVGForExport(); |
chart.renderTo.parentNode.appendChild(div); |
}; |
|
// View SVG Source |
button = doc.createElement('button'); |
button.innerHTML = 'View SVG Source'; |
chart.renderTo.parentNode.appendChild(button); |
button.onclick = function () { |
var pre = doc.createElement('pre'); |
pre.innerHTML = chart.getSVGForExport() |
.replace(/</g, '\n<') |
.replace(/>/g, '>'); |
chart.renderTo.parentNode.appendChild(pre); |
}; |
} |
// */ |
}); |