Charts: Use other icons for processing chart types

This commit is contained in:
Aysam Guerler
2014-06-19 03:57:57 -04:00
parent 37eabda30b
commit 0c19d260fe
7 changed files with 62 additions and 60 deletions
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@@ -137,63 +137,6 @@ define(["libs/underscore"], function(_) {
window.location.href = 'data:none/none;base64,' + btoa(createXML(options).string);
};
// XML creator
function createXML (options) {
if (options.$el.find('svg').length == 0) {
if (options.error) {
options.error('No SVG found. This chart type does not support SVG export.');
return;
}
}
// get parameters
var $el = options.$el;
// get svg dimensions
var nsvgs = $el.find('svg').length;
var height = parseInt($el.find('svg').first().css('height'));
var width = parseInt($el.find('svg').first().css('width'));
// serialize svg
var serializer = new XMLSerializer();
// get svg element
var $composite = $('<svg/>');
// configure svg
$composite.attr({
version : '1.1',
xmlns : 'http://www.w3.org/2000/svg',
width : width*nsvgs,
height : height
});
// write all svgs
var xmlString = '';
var offsetX = 0;
$el.find('svg').each(function() {
var $svg = $(this).clone();
// inline css
_inline($svg);
// create group and append to composite svg
var $g = $('<g transform="translate(' + offsetX + ', 0)">');
$g.append($svg.find('g').first());
$composite.append($g);
// shift offset for multipanel charts
offsetX += width;
});
// create xml string
return {
string : serializer.serializeToString($composite[0]),
height : height,
width : width
}
};
// css inliner
function _inline ($target) {
for (var sheet_id in document.styleSheets) {
@@ -265,6 +208,65 @@ define(["libs/underscore"], function(_) {
}
};
//
// XML export
//
function createXML (options) {
if (options.$el.find('svg').length == 0) {
if (options.error) {
options.error('No SVG found. This chart type does not support SVG/PDF export.');
return;
}
}
// get parameters
var $el = options.$el;
// get svg dimensions
var nsvgs = $el.find('svg').length;
var height = parseInt($el.find('svg').first().css('height'));
var width = parseInt($el.find('svg').first().css('width'));
// serialize svg
var serializer = new XMLSerializer();
// get svg element
var $composite = $('<svg/>');
// configure svg
$composite.attr({
version : '1.1',
xmlns : 'http://www.w3.org/2000/svg',
width : width*nsvgs,
height : height
});
// write all svgs
var xmlString = '';
var offsetX = 0;
$el.find('svg').each(function() {
var $svg = $(this).clone();
// inline css
_inline($svg);
// create group and append to composite svg
var $g = $('<g transform="translate(' + offsetX + ', 0)">');
$g.append($svg.find('g').first());
$composite.append($g);
// shift offset for multipanel charts
offsetX += width;
});
// create xml string
return {
string : serializer.serializeToString($composite[0]),
height : height,
width : width
}
};
// return
return {
createPNG: createPNG,
@@ -28,7 +28,7 @@ return Backbone.View.extend(
var picture_button_menu = new Ui.ButtonMenu({
icon : 'fa-camera',
title : 'Screenshot',
tooltip : 'Download as PNG or SVG file'
tooltip : 'Download as PNG, SVG or PDF file'
});
// add png option
@@ -77,7 +77,7 @@ return Backbone.View.extend(
title : 'Send chart data for PDF creation',
body : 'Galaxy does not provide integrated PDF export scripts. You may click \'Continue\' to create the PDF by using a 3rd party service (https://export.highcharts.com).',
buttons : {
'Close' : function() {self.app.modal.hide()},
'Cancel' : function() {self.app.modal.hide()},
'Continue' : function() {
self._wait (self.chart, function() {
self.app.modal.hide();