TCPDF alignment rendering issue - tcpdf

I'm getting weird alignment issues with TCPDF.
Here's a chunk of my looping code:
$pdf->setColor('text', 255, 255, 255);
$pdf->SetFontSize(20);
$pdf->Cell( 180, 25, $post->post_title, 0, 1, 'R', false, '', 3);
$pdf->Ln(1);
$pdf->setColor('text', 0, 0, 0);
$pdf->SetFontSize(14);
$pdf->Cell( 180, 8, $product->get_sku(), 0, 1, 'R', false);
$pdf->Ln(4);
$pdf->Image( $product->post->thumbnail, 15, 50, 80, 0, 'JPG', '', '', true, 150, '', false, false, 0, false, false, false);
$pdf->SetFontSize(10);
$pdf->MultiCell(90, 0, '', 1, 'C', 1, 0, '', '', true, 0, false, true, 0, 'T');
$pdf->setCellHeightRatio(1.65);
$pdf->MultiCell(90, 0, ($post->post_excerpt ? $post->post_excerpt : 'No description found.'), 1, 'C', 1, 1, '', '', true, 0, true, true, 0);
$pdf->setCellHeightRatio(0);
And here are the results which vary from first line centering for description to the more obvious title alignment even though it is from the same loop :
What gives?
Makes me wonder if I should have just stuck with FPDF...

Related

IPv6 Resolution in gen_tcp connect when called from Elixir

When using the connect method of gen_tcp, IPv4 domains are resolved automatically, i.e.:
:gen_tcp.connect('google.com', 443, [:binary, active: false])
{:ok, #Port<0.116>}
However, if resolving an IPv6 domain, it will not resolve correctly
iex(production#b7726c04)3> :gen_tcp.connect('ipv6.google.com', 443, [:binary, active: false])
{:error, :nxdomain}
Am I missing an option with the socket options of :gen_tcp.connect that would enable IPv6 resolution or do I have manually resolve the domain myself before usage? i.e. something like:
:inet_res.resolve('ipv6.google.com', :in, :aaaa)
{:ok,
{:dns_rec, {:dns_header, 1, true, :query, false, false, true, true, false, 0},
[{:dns_query, 'ipv6.google.com', :aaaa, :in, false}],
[
{:dns_rr, 'ipv6.google.com', :cname, :in, 0, 604606, 'ipv6.l.google.com',
:undefined, [], false},
{:dns_rr, 'ipv6.l.google.com', :aaaa, :in, 0, 300,
{9220, 26624, 16387, 3072, 0, 0, 0, 101}, :undefined, [], false},
{:dns_rr, 'ipv6.l.google.com', :aaaa, :in, 0, 300,
{9220, 26624, 16387, 3072, 0, 0, 0, 102}, :undefined, [], false},
{:dns_rr, 'ipv6.l.google.com', :aaaa, :in, 0, 300,
{9220, 26624, 16387, 3072, 0, 0, 0, 113}, :undefined, [], false},
{:dns_rr, 'ipv6.l.google.com', :aaaa, :in, 0, 300,
{9220, 26624, 16387, 3072, 0, 0, 0, 100}, :undefined, [], false}
], [], []}}
Then using the IPv6 tuple directly:
:gen_tcp.connect({9220, 26624, 16387, 3072, 0, 0, 0, 101}, 443, [:binary, active: false])
{:ok, #Port<0.138>}
You can use inet6:
{ok, P} = gen_tcp:connect("ipv6.google.com", 80, [inet6]).
{ok,#Port<0.14>}

Why is Highcharts x axis not respecting my categories in stacked area chart

I have created a stacked area chart in Highcharts at https://jsfiddle.net/kg3b2xyL/ I am feeding the hours as 24 categories (I guess I could have fed timestamps with an X-axis interval instead, but I think either way should work?). Each series correspondingly has 24 entries. Highcharts is charting the data okay and shows all the categories I gave it, but then it adds additional categories for some reason at the end on the right side of the chart, so that the numbers extend to 24 even though my categories started in the middle of the day and the final category in the categories list is 18. Is this a bug in Highcharts? Do I have to switch to feeding timestamps, or is there a way for this to work as I have coded it?
Thanks!
Here is my HTML:
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
And my JavaScript:
Highcharts.chart('container', {
chart: {
type: 'area'
},
legend: {
enabled: false
},
title: {
text: 'Calls to technical support last 24 hours'
},
xAxis: {
title: {
text: 'Time of Day'
},
categories: ['19', '20', '21', '22', '23', '24', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18']
},
yAxis: {
title: {
text: 'Calls during the hour'
},
},
tooltip: {
split: true,
},
plotOptions: {
area: {
stacking: 'normal',
lineColor: '#666666',
lineWidth: 1,
marker: {
lineWidth: 1,
lineColor: '#666666'
}
}
},
series: [
{ name: 'Jane', data: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'John', data: [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Julie', data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Walter', data: [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Andy', data: [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Julio', data: [2, 0, 0, 2, 0, 0, 2, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Rachel', data: [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Steven', data: [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
{ name: 'Phil', data: [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] },
]
});
The issue can be resolved by deleting the zeros from Julio nad Reachel data - there are too many zeros.
Demo:
https://jsfiddle.net/BlackLabel/h50m9y72/

Highchart : Add data padding for left stepped area last point

When last value in left stepped area is different from previous one it is hard to see it. (we just see a line along the end of the chart)
Demo:
https://jsfiddle.net/x2qf5wuy/1/
$("#container").highcharts({
chart: {
type: 'area'
},
plotOptions: {
area: {
stacking: 'normal',
step: 'left'
}
},
series: [{
name: "Example 1",
data: [0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 2, 1, 1, 0, 0, 0, 0, 0]
}, {
name: "Example 2",
data: [0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 2, 1, 1, 0, 0, 0, 0, 10]
}]
});
There is a way in highchart to add an artificial padding to data series so that the user can see the last point ?
Wanted result :
You can add a point with the same y value as the last series point and use the setExtremes method to show only the wanted part of the area:
chart: {
type: 'area',
events: {
load: function() {
var series = this.series[1],
lastPoint = series.data[series.data.length - 1];
series.addPoint({
x: lastPoint.x + 100,
y: lastPoint.y
}, false);
this.xAxis[0].setExtremes(null, lastPoint.x + 0.5);
}
}
},
Live demo: https://jsfiddle.net/BlackLabel/54a6jdgy/
API Reference:
https://api.highcharts.com/class-reference/Highcharts.Series#addPoint
https://api.highcharts.com/class-reference/Highcharts.Axis#setExtremes

Positioning a popup keyboard

I found a plugin from github that pops out a virtual keyboard as you click a textbox/textarea. The problem is, if you have other elements, the keyboard appears at the bottom. I want it to show adjacent the textbox clicked. I tried appending ".position({
my: "left top",
at: "left top",
of: "#targetElement"
});" at the end of the keyboard initializer(last line) but it's not taking effect. Here's the script.
<script type="text/javascript">
$(function(){
var keyboard = {
'layout': [
// alphanumeric keyboard type
// text displayed on keyboard button, keyboard value, keycode, column span, new row
[
[
['`', '`', 192, 0, true], ['1', '1', 49, 0, false], ['2', '2', 50, 0, false], ['3', '3', 51, 0, false], ['4', '4', 52, 0, false], ['5', '5', 53, 0, false], ['6', '6', 54, 0, false],
['7', '7', 55, 0, false], ['8', '8', 56, 0, false], ['9', '9', 57, 0, false], ['0', '0', 48, 0, false], ['-', '-', 189, 0, false], ['=', '=', 187, 0, false],
['q', 'q', 81, 0, true], ['w', 'w', 87, 0, false], ['e', 'e', 69, 0, false], ['r', 'r', 82, 0, false], ['t', 't', 84, 0, false], ['y', 'y', 89, 0, false], ['u', 'u', 85, 0, false],
['i', 'i', 73, 0, false], ['o', 'o', 79, 0, false], ['p', 'p', 80, 0, false], ['[', '[', 219, 0, false], [']', ']', 221, 0, false], ['\', '\\', 220, 0, false],
['a', 'a', 65, 0, true], ['s', 's', 83, 0, false], ['d', 'd', 68, 0, false], ['f', 'f', 70, 0, false], ['g', 'g', 71, 0, false], ['h', 'h', 72, 0, false], ['j', 'j', 74, 0, false],
['k', 'k', 75, 0, false], ['l', 'l', 76, 0, false], [';', ';', 186, 0, false], [''', '\'', 222, 0, false], ['Enter', '13', 13, 3, false],
['Shift', '16', 16, 2, true], ['z', 'z', 90, 0, false], ['x', 'x', 88, 0, false], ['c', 'c', 67, 0, false], ['v', 'v', 86, 0, false], ['b', 'b', 66, 0, false], ['n', 'n', 78, 0, false],
['m', 'm', 77, 0, false], [',', ',', 188, 0, false], ['.', '.', 190, 0, false], ['/', '/', 191, 0, false], ['Shift', '16', 16, 2, false],
['Bksp', '8', 8, 3, true], ['Space', '32', 32, 12, false], ['Clear', '46', 46, 3, false], ['Cancel', '27', 27, 3, false]
]
]
]
}
$('#name.jQKeyboard').initKeypad({'keyboardLayout': keyboard});
});
</script>
If we're talking about: https://github.com/poiyee/jQKeyboard then I would suggest:
$('#name.jQKeyboard').initKeypad({'keyboardLayout': keyboard});
$('#jQKeyboardContainer').position({
my: "left top",
at: "left top",
of: $('#name.jQKeyboard')
});
The plugin is written in an older fashion and I would suggest or consider using $.widget() to write you're own that allows you to set the position as an option.
If you wanted a modern working widget, it would look like this: https://jsfiddle.net/Twisty/mzj9w2yb/4/

How to remove the padding on the both ends of the HighChart

I have been trying this for hours and still have no idea.
Here is the config that I am using
chart: {
type: 'xrange',
height: 800,
},
title: {
text: 'Patient Sessions Overview'
},
xAxis: {
title: 'Time of the Day',
type: 'datetime',
tickInterval: 3600*1000,
tickPixelInterval: 200,
labels: {
formatter: function () {
return Highcharts.dateFormat('%H:%M', this.value);
},
},
min: Date.UTC(2016,1,1),
max: Date.UTC(2016,1,2),
},
yAxis: {
title: 'Day of the Month',
type: 'datetime',
tickInterval: 3600*1000*24,
//tickPixelInterval: 100,
min: Date.UTC(2016,1),
max: Date.UTC(2016,2) - 3600*1000*24
//min: 0,
//max: 31
},
plotOptions:{
series: {
pointPadding: 0,
groupPadding: 0
}
},
series: [{
name: 'Sessions',
//pointStart: Date.UTC(2000,0,1),
//pointInterval: 3600*1000,
//pointPadding: 10,
// groupPadding: 0,
borderRadius: 5,
pointWidth: 20,
data: [{
x: Date.UTC(2016, 1, 1, 0),
x2: Date.UTC(2016, 1, 1, 9),
y: Date.UTC(2016,1,4)
}, {
x: Date.UTC(2016, 1, 1, 12),
x2: Date.UTC(2016, 1, 1, 15),
y: Date.UTC(2016,1,5)
}, {
x: Date.UTC(2016, 1, 1, 8),
x2: Date.UTC(2016, 1, 1, 9),
y: Date.UTC(2016,1,14)
}, {
x: Date.UTC(2016, 1, 1, 8),
x2: Date.UTC(2016, 1, 1, 9),
y: Date.UTC(2016,1,20)
}, {
x: Date.UTC(2016, 1, 1, 8),
x2: Date.UTC(2016, 1, 1, 23),
y:Date.UTC(2016,1,25)
},],
}]
Here is the jsfiddle link
I need to remove the chart to make full use of the plot area without leaving a huge white space on both ends.
It is problem with unsorted data. In fact, you can not sort your data as Highcharts would expect, because some of the points are starting before previous one are ended. However, for such case, series.pointRange = 1 resolves all issues, take a look: http://jsfiddle.net/umndydLL/1/
Use following in your chart config:
spacingBottom: 0,
spacingTop: 0,
spacingLeft: 0,
spacingRight: 0,
margin:0,
padding:0

Resources