I am trying to produce the following graph with JQPlot
I have attempted this as best I can however the script causes an excsessive runtime and eventually firefox comes up with the stop script notice.
Any suggestions?
$(document).ready(function () {
var assigned1 = [5, 12, 2, 0, 0, 4, 8];
var assigned2 = [4, 0, 2, 0, 0, 2, 4];
var assigned3 = [1, 0, 2, 0, 0, 2, 0];
var assigned4 = [0, 0, 5, 0, 0, 3, 0];
var assigned5 = [0, 0, 1, 0, 0, 0, 0];
var assigned = [assigned1, assigned2, assigned3, assigned4, assigned5];
var numCompleted = [assigned1, assigned2, assigned3, assigned4, assigned5]; //[4,3,6,5,5,4,0,0,5,4,0,0,0,0];
//[1,1,0,0,2,2,8,7,4,4,11,10,1,1];
//var test3 = [4,6,3,8,6,3,1,9,1,5,3,6,7,4];
var dates = ['Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine', 'Assigned', 'Employee', 'Machine'];
plot3 = $.jqplot('chart3', [assigned, numCompleted], {
// Tell the plot to stack the bars.
seriesColors: ["#81a7d4", "#d0d0d0", "#fac"],
stackSeries: true,
shadow: false,
title: 'Cell Name',
animate: false,
captureRightClick: false,
grid: {
drawGridLines: false,
shadow: false
},
legend: {
show: false,
},
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions: {
barMargin: 10,
barPadding: 0,
shadowOffset: 0,
groups: 7,
highlightMouseDown: true
},
pointLabels: {
show: true,
hideZeros: true,
edgeTolerance: 10
}
},
grid: {
gridLineColor: '#fff',
borderWidth: 0,
shadow: false,
background: "white"
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dates,
showTickMarks: false
},
yaxis: {
showTicks: false
}
}
});
});
http://jsfiddle.net/K5cjj/1/
I have managed to do this by drawing multiple graphs to the same element. This has other issue but appears to work, can anyone expand on this to enable the click function to work on all bars
However this works in Firefox, chrome and IE11 only, IE 10 and below is all messed up (as usual)
http://jsfiddle.net/LADzf/1
$(document).ready(function(){
/* graph config */
var maxVal = 13;
/* graph vals */
var assigned1 = [5, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0];
var assigned2 = [3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0];
var assigned3 = [2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0];
var assigned4 = [0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var employee1 = [0, 5, 0, 0, 0, 10, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 12, 0];
var employee2 = [0, 5, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var machine = [0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 12];
var basevals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
/* graph ticks */
var ticks = ['Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine', ' ', 'Assigned', 'Employee', 'Machine'];
var blankticks = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '];
var dateticks = ['<br><br><br><br>01/01/2014', '<br><br><br><br>02/01/2014', '<br><br><br><br>03/01/2014', '<br><br><br><br>04/01/2014', '<br><br><br><br>05/01/2014', '<br><br><br><br>06/01/2014', '<br><br><br><br>07/01/2014'];
/* plot the base graph */
plotbase = $.jqplot('chart3', [basevals], {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {barMargin: 10},
pointLabels: {show: false}
},
axesDefaults: {show: false},
tickOptions: {showMark: false, angle: 90},
axes: {
showLabel: false,
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: dateticks,
tickOptions: {markSize: 0}
},
yaxis: {
padMin: 0,
min: 0,
max: maxVal,
showLabel: false,
show: false
}
}
});
plot3 = $.jqplot('chart3', [machine], {
seriesColors: ["#a62525"],
stackSeries: true,
captureRightClick: true,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {
barMargin: 10,
highlightMouseOver: true
},
pointLabels: {show: false}
},
axesDefaults: {show: false},
tickOptions: {showMark: false, angle: 90},
axes: {
showLabel: false,
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: blankticks,
tickOptions: {markSize: 0}
},
yaxis: {
padMin: 0,
min: 0,
max: maxVal,
showLabel: false,
show: false
}
}
});
plot2 = $.jqplot('chart3', [employee1, employee2], {
seriesColors: ["#67ce64", "#da9831"],
stackSeries: true,
captureRightClick: true,
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {barMargin: 10, highlightMouseOver: true},
pointLabels: {show: false}
},
axesDefaults: {show: false},
tickOptions: {showMark: false},
axes: {
showLabel: false,
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: blankticks
},
yaxis: {
padMin: 0,
min: 0,
max: maxVal,
showLabel: false,
show: false
}
},
grid: {background: 'transparent', drawGridLines: false, gridLineColor: 'transparent', borderColor: 'transparent'}
});
plot1 = $.jqplot('chart3', [assigned1, assigned2, assigned3, assigned4], {
stackSeries: true,
captureRightClick: true,
seriesColors: ["#effa38", "#37d1f8", "#5129b6"],
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
rendererOptions: {barMargin: 10, highlightMouseOver: true },
pointLabels: {show: false}
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
tickRenderer:$.jqplot.CanvasAxisTickRenderer,
ticks: ticks,
tickOptions: {
angle: -90,
}
},
yaxis: {
padMin: 0,
min: 0,
max: maxVal
}
}, grid: {background: 'transparent', drawGridLines: false, gridLineColor: 'transparent', borderColor: 'transparent'}
});
$('#chart3').bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) {
$('#info3').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
});
});
Related
I'm trying to figure out the best way to sort by multiple values and multiple keys at once.
I have the following "sort sequence";
sort by "finished or not"
sort by "out of time or not"
sort by "points in total"
sort by "points for your time"
sort by "points for each 'secret time control', can be null, then you end up at the end of that sorting"
sort by "the distance driven"
I currently have something like this of response (sorted);
[
{
"team_number": 201,
"points_for_time": 0,
"detail_points_for_time": {
"tc_start": 0,
"tc_round_in": 0,
"tc_stop": 0
},
"points_for_gtc": 1,
"detail_points_for_gtc": [
0,
1
],
"points_for_distance": 0,
"missed_controls": 100,
"out_of_time": false,
"dnf": false,
"total": 101
},
{
"team_number": 202,
"points_for_time": 2,
"detail_points_for_time": {
"tc_start": 0,
"tc_round_in": 0,
"tc_stop": 2
},
"points_for_gtc": 0,
"detail_points_for_gtc": [],
"points_for_distance": 0,
"missed_controls": 100,
"out_of_time": false,
"dnf": false,
"total": 102
},
{
"team_number": 203,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 204,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 205,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 206,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 207,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 208,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
},
{
"team_number": 209,
"points_for_time": 0,
"detail_points_for_time": 0,
"points_for_gtc": 0,
"detail_points_for_gtc": 0,
"points_for_distance": 0,
"missed_controls": 0,
"out_of_time": false,
"dnf": true,
"total": 0
}
]
So the goal here is, that I get a full sorting based on the above "sequence".
I currentmy use this;
$results = $results->sortBy('total')
->sortBy('points_for_time')
->sortBy('points_for_gtc') // this is an issue, since it puts you below someone else when you have less points
->sortBy('points_for_distance')
->sortBy('out_of_time')
->sortBy('dnf');
There is another "field" I have, detail_points_for_gtc, which holds the points (in order) for each "time control".
The possibility exists that there is nothing filled in, if so, then you should be at the end of the list. it's also possible that the value is null. Then it should be sorted at the end.
I have no idea on how I can sort on the detail_points_for_gtc, and if this sorting is "the correct sorting"?
Anyone who understands the question and may be able to help?
I think you can try this;
// you can send column and direction from request or where you need
$results = $request->direction == 'asc' ? $results->sortBy($request->column) : $results->sortByDesc($request->column);
I have create a simple XY Chart graph with percent as y axes and customers as x axes, I randomised the data between 0...100% with a set of 184 points. and have a bit of difficulty display the lower/upper region values. I have included an image for the demonstration.
Here my config file, I cant seem to find some sort of offset/padding ?
{
type: 'xy',
addClassNames: true,
autoMargins: false,
marginLeft: 67,
marginBottom: 55,
graphs: [{
balloonFunction,
bullet: 'round',
xField: 'customers',
yField: 'rate',
bulletSize: 16,
lineColorField: 'color',
}],
valueAxes: [
{
title,
borderThickness: 0,
axisThickness: 2,
maximum: 100,
labelFunction: (e,val) => { return val + "%"; },
},
{
title,
position: 'bottom',
axisAlpha: 0,
borderThickness: 0,
axisThickness: 0,
gridThickness: 0,
},
],
dataProvider: data,
};
Thanks.
There isn't a way to pad this without modifying your minimum and maximum to be further outside your 0-100 range to accommodate. Since you're using a labelFunction, you can set it up so that you don't display any labels above and below 0-100% if you want, for example:
labelFunction: (e, val) => { return (val > 100 || val < 0 ? "" : val + "%"); }
Demo below using -10 as a minimum and 110 as a maximum:
var data = [{"rate": 99, "customers": 2421},{"rate": 76,"customers": 100},{"rate": 68,"customers": 1711},{"rate": 38,"customers": 313},{"rate": 94,"customers": 393},{"rate": 57,"customers": 946},{"rate": 99,"customers": 1772},{"rate": 20,"customers": 2168},{"rate": 100,"customers": 754},{"rate": 40,"customers": 121},{"rate": 51,"customers": 2412},{"rate": 15,"customers": 2364},{"rate": 32,"customers": 2161},{"rate": 55,"customers": 1506},{"rate": 29,"customers": 986},{"rate": 0,"customers": 698},{"rate": 4,"customers": 1285},{"rate": 22,"customers": 2108},{"rate": 17,"customers": 2081},{"rate": 79,"customers": 251},{"rate": 48,"customers": 258},{"rate": 41,"customers": 1541},{"rate": 35,"customers": 1132},{"rate": 86,"customers": 1213},{"rate": 1,"customers": 1936},{"rate": 51,"customers": 1737},{"rate": 5,"customers": 2447},{"rate": 60,"customers": 305},{"rate": 37,"customers": 776},{"rate": 64,"customers": 886}];
var chart = AmCharts.makeChart("chartdiv", {
type: 'xy',
addClassNames: true,
autoMargins: false,
marginLeft: 67,
marginBottom: 55,
graphs: [{
//balloonFunction,
bullet: 'round',
xField: 'customers',
yField: 'rate',
bulletSize: 16,
lineAlpha: 0, //for testing only
lineColorField: 'color',
}],
valueAxes: [
{
title: "Rate (%)",
borderThickness: 0,
axisThickness: 2,
maximum: 110,
minimum: -10,
labelFunction: (e,val) => { return (val > 100 || val < 0 ? "" : val + "%"); },
},
{
title: "Customers",
position: 'bottom',
axisAlpha: 0,
borderThickness: 0,
axisThickness: 0,
gridThickness: 0,
},
],
dataProvider: data,
});
<script type="text/javascript" src="//www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="//www.amcharts.com/lib/3/xy.js"></script>
<div id="chartdiv" style="width: 100%; height: 300px;"></div>
If you want to remove the extra grid lines from the additional points generated by the new minimum and maximum, you'll have to use guides as your grid lines and labels instead of the ones auto-generated by the chart. For example:
valueAxes: [{
guides: [{
"value": 0,
"label": "0%",
"lineAlpha": .2,
"tickLength": 5
},
// repeat for each tick/grid line
],
"gridAlpha": 0,
"tickLength": 0,
"labelsEnabled": false,
// ...
Demo:
var data = [{"rate": 99, "customers": 2421},{"rate": 76,"customers": 100},{"rate": 68,"customers": 1711},{"rate": 38,"customers": 313},{"rate": 94,"customers": 393},{"rate": 57,"customers": 946},{"rate": 99,"customers": 1772},{"rate": 20,"customers": 2168},{"rate": 100,"customers": 754},{"rate": 40,"customers": 121},{"rate": 51,"customers": 2412},{"rate": 15,"customers": 2364},{"rate": 32,"customers": 2161},{"rate": 55,"customers": 1506},{"rate": 29,"customers": 986},{"rate": 0,"customers": 698},{"rate": 4,"customers": 1285},{"rate": 22,"customers": 2108},{"rate": 17,"customers": 2081},{"rate": 79,"customers": 251},{"rate": 48,"customers": 258},{"rate": 41,"customers": 1541},{"rate": 35,"customers": 1132},{"rate": 86,"customers": 1213},{"rate": 1,"customers": 1936},{"rate": 51,"customers": 1737},{"rate": 5,"customers": 2447},{"rate": 60,"customers": 305},{"rate": 37,"customers": 776},{"rate": 64,"customers": 886}];
var chart = AmCharts.makeChart("chartdiv", {
type: 'xy',
addClassNames: true,
autoMargins: false,
marginLeft: 67,
marginBottom: 55,
graphs: [{
//balloonFunction,
bullet: 'round',
xField: 'customers',
yField: 'rate',
bulletSize: 16,
lineAlpha: 0, //for testing only
lineColorField: 'color',
}],
valueAxes: [
{
title: "Rate (%)",
borderThickness: 0,
axisThickness: 2,
maximum: 110,
minimum: -10,
guides: [{
value: 0,
label: "0%",
lineAlpha: .2,
tickLength: 5
},{
value: 20,
label: "20%",
lineAlpha: .2,
tickLength: 5
},{
value: 40,
label: "40%",
lineAlpha: .2,
tickLength: 5
},{
value: 60,
label: "60%",
lineAlpha: .2,
tickLength: 5
},{
value: 80,
label: "80%",
lineAlpha: .2,
tickLength: 5
},{
value: 100,
label: "100%",
lineAlpha: .2,
tickLength: 5
}],
gridAlpha: 0,
tickLength: 0,
labelsEnabled: false
},
{
title: "Customers",
position: 'bottom',
axisAlpha: 0,
borderThickness: 0,
axisThickness: 0,
gridThickness: 0,
},
],
dataProvider: data,
});
<script type="text/javascript" src="//www.amcharts.com/lib/3/amcharts.js"></script>
<script type="text/javascript" src="//www.amcharts.com/lib/3/xy.js"></script>
<div id="chartdiv" style="width: 100%; height: 300px;"></div>
I am little confused here,
I am using TCPDF to print a pdf from Codeigniter.
The TCPDF directory putted in application/library
I wanna load a row from a model to a TCPDF header that I modified, because
The header will be viewing some data like serial number from model.
The model is like this :
class model_request extends CI_Model{
public function __construct(){
parent::__construct();
}
public function selectOneRequest($id_request){
$query = $this->db->get_where('tbl_requestfix', array('id_request'=>$id_request));
return $query->result_array();
}
}
and this is the mypdf class that extending header dan footer of tcpdf class
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once dirname(__FILE__) . '/tcpdf/tcpdf.php';
class TC_Pdf extends TCPDF{
//Page header
public function Header() {
// Set font
$this->SetFont('helvetica', '', 10);
// Serial number
$this->Cell(0, 15, 'I am missing here', 0, true, 'R', 0, '', 0, false, 'M', 'M');
$this->SetFont('helvetica', 'B', 16);
$this->Cell(0, 15, 'P.T. Tresnamuda Sejati', 0, true, 'C', 0, '', 0, false, 'M', 'M');
$this->SetFont('helvetica', '', 11);
$this->Cell(0, 15, 'FORM PERMINTAAN / PERBAIKAN ', 0, true, 'C', 0, '', 0, false, 'M', 'M');
$this->SetFont('helvetica', 'B', 16);
$this->Cell(0, 15, 'HARDWARE - SOFTWARE - NETWORK', 0, true, 'C', 0, '', 0, false, 'M', 'M');
}
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-10);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
//$this->Cell(0, 0, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
This is my controller to fill the body of pdf :
public function generate_pdf($idRequest){
$data=$this->model_request->selectOneRequest($idRequest);
foreach ($data as $d) {
$this->load->library("TC_PDF");
$pdf = new TC_Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Dzil');
$pdf->SetTitle('Form Perbaikan / Permintaan');
$pdf->SetSubject('TMS/DEPT/IT/06');
$pdf->SetKeywords('TCPDF, PDF, form, perbaikan, Permintaan');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (#file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 12);
// add a page
$pdf->AddPage();
$pdf->Ln(8);
$pdf->Cell(30, 8, 'Nama', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 4, 8, ': ', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 0, 8, $d['nama_user'], 1, 1, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell(30, 8, 'Departement', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 4, 8, ': ', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 0, 8, $d['departement'], 1, 1, 'L', 0, '', 0, false, 'T', 'C'); //w,h,isi, border
$pdf->Cell(30, 8, 'NIK', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 4, 8, ': ', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 0, 8, $d['id_user'], 1, 1, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell(30, 8, 'Tanggal', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 4, 8, ': ', 1, 0, 'L', 0, '', 0, false, 'T', 'C');
$pdf->Cell( 0, 8, $d['waktu_mulai'], 1, 1, 'L', 0, '', 0, false, 'T', 'C');
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_057.pdf', 'I');
//echo $d["kode_kantor"];
}
}
How should I do, coz in mypdf class that extend tcpdf class, I can not load that model ...
Any help it so appriciated...
Have you load that model in your controller?
insert this before calling the model.
public function generate_pdf($idRequest){
$this->load->model('model_request'); // <-- insert this
$data=$this->model_request->selectOneRequest($idRequest);
...
}
I have a processed an image that returns a Mat say:
[
[ 0, 0, 255, 255, 255, 0, 0, 0],
[ 0, 0, 0, 255, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
are there any segmentation functions that can help me isolate individually ?
if not so what would be the best approach ?
i.e. say if i do mysegment(Mat a,0) should return
[
[ 0, 0, 255, 255, 255, 0, 0, 0],
[ 0, 0, 0, 255, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
then mysegment(Mat a,1) will return
[
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 255, 255, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]
]
I consider continuous 255 pixels to be a block. Now I want to iterate over or process these blocks ... since more than one block can be formed in a matrix.
You can use contours
findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
the link to the library
Is there a way to calculate the skew transformation matrix along one coordinate axis, given the skew angle, as follows
This should work for the most part for skewing an object with a transformation matrix, in particular using glMultMatrix(matrix)
matrix1[] = {
1, 0, 0, 0,
tan(a), 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
matrix2[] = {
1, 0, 0, 0,
0, 1, 0, 0,
tan(a), 0, 1, 0,
0, 0, 0, 1
};
matrix3[] = {
1, tan(a), 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
matrix4[] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, tan(a), 1, 0,
0, 0, 0, 1
};
matrix5[] = {
1, 0, tan(a), 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
matrix6[] = {
1, 0, 0, 0,
0, 1, tan(a), 0,
0, 0, 1, 0,
0, 0, 0, 1
};