I have an html table defined based on dynamic data. The table contains a thead, tfoot and tbody. The tfoot is mapped to specific values within my json. However, when using JSPDF Autotable and exporting to PDF the footer is not rendered. I have seen information but no code examples of the showfoot option and have tried it after the doc.autotable, and even after the style options but to no avail. The footer is not exported. I'm sure it super simple - but I can't seem to figure it out. Note: I do not want JSDPF Autotable to 'create' a footer - it is defined, it is part of my table - I simply want it rendered on the pdf. I found an old stackoverflow from 2016 where this was mentioned - Simon B. commented it would be added - the topic was closed - but I couldn't find a code example anywhere.
Here is my jspdf autotable code where I have tried to 'show my footer' - but to no avail. Any assistance appreciated.
<script>
function generate() {
//Creation of PDF document
let doc = new jsPDF('l', 'pt');
const totalPagesExp = '{total_pages_count_string}';
var elem = document.getElementById('${pm.info.requestId}');
var data = doc.autoTableHtmlToJson(elem);
doc.autoTable(data.columns, data.rows, {
headStyles: {
cellWidth: 'wrap',
fontSize: 10,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [255,255,255]
},
bodyStyles: {
cellWidth: 'wrap',
fontSize: 8,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [255,255,255]
},
footStyles: {
cellWidth: 'wrap',
fontSize: 10,
lineWidth: 0,
lineColor: [0, 0, 0],
textColor: [0, 0, 0],
fillColor: [211,211,211]
},
//Formatting of pages
didDrawPage: function (data) {
//Summa logo on top of the page
doc.addImage('${pm.variables.get("summa")}', 'PNG', 20, 20, 145, 42.63);
//Font sizes of report information
doc.setFontSize(8);
//Report information: portfolio name, knowledge time and report time
doc.text(35, 75, '${pm.variables.get("portfolioName")}');
doc.text(35, 85, '${pm.variables.get("reportTime")}');
doc.text(35, 95, '${pm.variables.get("knowledgeTime")}');
//Page numbers
var str = "Page " + doc.internal.getNumberOfPages()
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp;
};
//Page size
var pageSize = doc.internal.pageSize;
var pageHeight = pageSize.height ? pageSize.height : pageSize.getHeight();
doc.text('Theme "plain"', 14, 16);
},
margin: {
top: 100
},
});
//Number of pages
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
},
//--------------------------------------------------------------------------------------------------START
//Change name of report if desired
doc.save('${pm.info.requestName}${pm.variables.get("reportTime")}.pdf');
//--------------------------------------------------------------------------------------------------END
}
Not sure if you already managed to export footer totals to the jspdf. I got it to working, with a small adjustment.
Replace the var elem = document.getElementById('${pm.info.requestId}'); to var elem = document.getElementById('NAME');
And replace the doc.autoTable(data.columns, data.rows, { to doc.autoTable({html: '#NAME',
Related
Wordcloud-highcharts is now available in its latest release (>=6.0) and now I am baffling with laying out the gradient (linear/radial) over texts. For example in this link, if I change the colors array in the series object to
fillColor: {
linearGradient: [0, 0, 0, 200],
stops: [
[0, 'white'],
[1, 'black']
]
},
It does nothing.
Wordcloud has limited functionality and however I am unable to do accomplish this task. Even tried appending multiple defs for different text gradients with (k is such that, it lies between 0 to n)
<defs>
<radialGradient id="myRadialGradient_k"
fx="5%" fy="5%" r="65%"
spreadMethod="pad">
<stop offset="0%" stop-color="#00ee00" stop-opacity="1"/>
<stop offset="100%" stop-color="#006600" stop-opacity="1" />
</radialGradient>
</defs>
and searching for the class and apply css to fill with this myLinearGradient_k by fill:url(#myLinearGradient_k);. But it is very clumsy and heavy. Also search by id is not possible in this case and appending to class highcharts-point is the only possibility, which limits the options.
You may find this live demo helpful: http://jsfiddle.net/kkulig/mnj07vam/
In chart.events.load I placed the code responsible for finding maximum weight, creating gradients (every point has a separate one) and applying them:
chart: {
events: {
load: function() {
var points = this.series[0].points,
renderer = this.renderer,
maxWeight = 0;
// find maximum weight
points.forEach(function(p) {
if (p.weight > maxWeight) {
maxWeight = p.weight;
}
});
points.forEach(function(p, i) {
var id = 'grad' + i;
// create gradient
var gradient = renderer.createElement('linearGradient').add(renderer.defs).attr({
id: id,
x1: "0%",
y1: "0%",
x2: "100%",
y2: "0%"
});
var stop1 = renderer.createElement('stop').add(gradient).attr({
offset: "0%",
style: "stop-color:rgb(255,255,0);stop-opacity:1"
});
var stop2 = renderer.createElement('stop').add(gradient).attr({
offset: Math.round(p.weight / maxWeight * 100) + "%",
style: "stop-color:rgb(255,0,0);stop-opacity:1"
});
// apply gradient
p.update({
color: 'url(#' + id + ')'
}, false);
});
this.redraw();
}
}
}
API reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#createElement
Hi all Am trying to Increase my Specified column size Column size , So i used like this {columnStyles: {xxx: {columnWidth: 18}}} , Column size was increased but next lines's are getting affected . That mean's next line is theme: 'grid', mean's it's not working . Can someone clarify me pls . Here is My code ,
doc.autoTable(getColumns(), getData(), //{columnStyles: {steps: {columnWidth: 65}}},
{
theme: 'grid', // 'striped', 'grid' or 'plain'
headerStyles: {
fillColor: [189, 200, 255],
textColor: [12, 1, 1]
},
// margin: { top: 50, left: 20, right: 20, bottom: 0 },
styles: {
overflow: 'linebreak',
columnWidth: 110,
lineWidth: 2,
lineColor: [85, 51, 27]
},
pageBreak: 'avoid',
beforePageContent: function(data) {
doc.setFontSize(10);
doc.text("Process Name :"+mainData.name+" || "+"Description :"+mainData.description, 20, 15);
},
//startY: doc.autoTableEndPosY() + 20,
columnStyles: {
//0: {columnWidth: 200}
}
});
//doc.save("xxx.pdf");
Try changing the pdfsize , below are the formats
pageFormats = { // Size in pt of various paper formats
'a0': [2383.94, 3370.39], 'a1': [1683.78, 2383.94],
'a2': [1190.55, 1683.78], 'a3': [841.89, 1190.55],
'a4': [595.28, 841.89], 'a5': [419.53, 595.28],
'a6': [297.64, 419.53], 'a7': [209.76, 297.64],
'a8': [147.40, 209.76], 'a9': [104.88, 147.40],
'a10': [73.70, 104.88], 'b0': [2834.65, 4008.19],
'b1': [2004.09, 2834.65], 'b2': [1417.32, 2004.09],
'b3': [1000.63, 1417.32], 'b4': [708.66, 1000.63],
'b5': [498.90, 708.66], 'b6': [354.33, 498.90],
'b7': [249.45, 354.33], 'b8': [175.75, 249.45],
'b9': [124.72, 175.75], 'b10': [87.87, 124.72],
'c0': [2599.37, 3676.54], 'c1': [1836.85, 2599.37],
'c2': [1298.27, 1836.85], 'c3': [918.43, 1298.27],
'c4': [649.13, 918.43], 'c5': [459.21, 649.13],
'c6': [323.15, 459.21], 'c7': [229.61, 323.15],
'c8': [161.57, 229.61], 'c9': [113.39, 161.57],
'c10': [79.37, 113.39], 'dl': [311.81, 623.62],
'letter': [612, 792],
'government-letter': [576, 756],
'legal': [612, 1008],
'junior-legal': [576, 360],
'ledger': [1224, 792],
'tabloid': [792, 1224],
'credit-card': [153, 243]
};
You have to say as var pdfsize = 'a1';
I am trying to use the plotting library JSXGraph from Dart using dart js but I have problems.
This is working javascript code
var board = JXG.JSXGraph.initBoard(
'box',
{
boundingbox: [-10, 10, 2, -1],
axis: true,
keepaspectratio: false,
showNavigation: false
}
);
var graph = board.create(
'functiongraph',
[function(x){ return 3*x*x + 5*x + 1;}, -10, 10],
{strokeColor: '#ffff00'}
);
You can try it here on jsFiddle.
I want to do basically the identicall thing but from dart. This is what I have come up with so far:
JsObject jsxGraph = context['JXG']['JSXGraph'];
var board = jsxGraph.callMethod('initBoard', [
'box',
new JsObject.jsify({
'boundingbox': [-10, 10, 2, -1],
'axis': true,
'keepaspectratio': false,
'showNavigation': false
})
]);
var graph = board.callMethod('create', [
'functiongraph',
[(x){return 3*x*x + 5*x + 1;}, -10, 10],
new JsObject.jsify({'strokeColor': '#ffff00'})
]);
I get the plot area and axes but I can't get the actual plot line. Instead, there is an error on the console: Uncaught TypeError: this.Y is not a function.
Could someone, please, point me to what I could be doing wrong? I suspect it is something about the callback function but I really don't know what.
There's a jsify missing in your code:
JsObject jsxGraph = context['JXG']['JSXGraph'];
var board = jsxGraph.callMethod('initBoard', [
'box',
new JsObject.jsify({
'boundingbox': [-10, 10, 2, -1],
'axis': true,
'keepaspectratio': false,
'showNavigation': false
})
]);
var graph = board.callMethod('create', [
'functiongraph',
new JsObject.jsify([(x){return 3*x*x + 5*x + 1;}, -10, 10]},
new JsObject.jsify({'strokeColor': '#ffff00'})
]);
I am new to Highcharts.
I have a line chart. Here is the categories:
["9/7/14", "9/8/14", "9/9/14", "9/10/14", "9/11/14", "9/12/14", "9/13/14", "9/14/14", "9/15/14", "9/16/14", "9/17/14", "9/18/14", "9/19/14", "9/20/14", ...]
Here is the data series:
[1, 4, 0, 2, 1, 1, 1, 5, 3, 1, 0, 0, 6, 8, ... ]
I added zoom to my chart, very similar to this jsfiddle demo: http://jsfiddle.net/348sh/3/
chart: {
renderTo: 'container',
zoomType: 'x'
},
I would like to get the total of only those Y values within the zoomed-in window, not the total of the entire data series. For this, I need to capture what values are included in the x axis in the zoomed window. So I added the following based on my research:
xAxis: {
type: 'line',
events: {
setExtremes: function(event) {
console.log(event.min);
console.log(event.max);
}
}
}
However, the values for event.min or event.max are numbers such as 3.6552511415525117, 7.10730593607306. I have no way to know which x values are included in the zoomed window. How can I find which x values are included? Any way to get the start and end x values ?
Thanks!
I did further research. I notice that I may have answered my question already in my question. It turns out that the numbers I gave in my question are very helpful, not clueless. Math.ceil(min) and Math.floor(max) are just the beginning and ending index of the data points in the data series that are show up in the zoomed window. The another thing to note is to use afterSetExtremes event. This is the moment where chart finalizes the starting and ending points in the X axis. So the complete answer is:
xAxis: {
type: 'line',
events: {
afterSetExtremes: function(event) {
var start = Math.ceil(event.min);
var end = Math.floor(event.max);
}
}
}
I am new to Highcharts and love to get corrected if I am wrong.
Cheers.
This may help you . Try this fiddle : http://jsfiddle.net/7kv9a25r/ .
chart: {
events: {
selection: function (event) {
var text,
label;
if (event.xAxis) {
text = 'min: ' + Highcharts.numberFormat(event.xAxis[0].min, 2) + ', max: ' + Highcharts.numberFormat(event.xAxis[0].max, 2);
} else {
text = 'Selection reset';
}
label = this.renderer.label(text, 100, 120)
.attr({
fill: Highcharts.getOptions().colors[0],
padding: 10,
r: 5,
zIndex: 8
})
.css({
color: '#FFFFFF'
})
.add();
setTimeout(function () {
label.fadeOut();
}, 1000);
}
},
zoomType: 'x'
},
My chart is very simple and is something like this:
function drawVisualization() {
var data = google.visualization.arrayToDataTable([
['week', 'rate'],
['1', 0.156],
['2', 0.232],
['3', 0.446],
['4', 0.832],
['5', 0.702],
['6', 0.773],
['7', 0.842],
['8', 0.413],
['9', 0.278],
['10', 0.323],
['11', 0.312],
['12', 0.309],
['13', 0.134],
['14', 0.137]
]);
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, {curveType: "function",
width: 500, height: 400,
vAxis: {maxValue: 1}}
);
}
But I have NO IDEA how to format the data column to show as a pecentage in the tooltip. Can you guys give a hand?
Use a NumberFormatter:
var formatter = new google.visualization.NumberFormat({pattern: '#%'});
formatter.format(data, 1); // format column 1
You may also want to format the y-axis:
vAxis: {
maxValue: 1,
format: '#%'
}
Add a column like this
{role: 'tooltip'}
I had the same problem and fixed it.
See for yourself!