We have displayed the student statistics for each departments in our application. Everything is working fine for us. But the designs are getting overlap for each student stats.
FYI, See the below screenshot
Here the stats % 0.3 and 1.0 are getting overlapped.
Code:
$color=array("#5c61fb","#bf7a7c","#f46163","#f4fafb","#f4fa63",
"#f4c463","#5cfa63","#bc74f2","#66e1e3","#f4a0ce");
$graph = new PieGraph(750,400,"auto");
$graph->SetShadow();
$graph->SetBackgroundImage('logo.jpg',BGIMG_COPY);
$graph->legend->SetFillColor('lightblue#0.7');
$graph->title->Set("Résultat $_GET[annee] $_GET[bourse]");
//$p1 = new PiePlot3D($arrayx_val);
$p1 = new PiePlot3D($arrayy);
$p1->SetSize(0.5);
$p1->SetCenter(0.4);
$p1->SetSliceColors($color);
$p1->SetLegends($arrayx);
$p1->value->SetFormat('%.1f%%');
//$p1->value->SetFormat("%.5d%%"); //$p1->SetLabelType(PIE_VALUE_ABS);
$p1->SetLabelPos(1);
$p1->value->HideZero();
//$p1->value->SetFont( FF_FONT1, FS_BOLD);
//$p1->value->SetMargin(50);
$p1->SetLabelMargin(20);
//$p1->SetShadow();
$graph->footer->left->SetFont( FF_FONT2, FS_BOLD);
$graph->footer->left->Set("Exclusion : ".$array_footer[0]." Abandon : ".$array_footer[1]." Démission : ".$array_footer[2]."");
$graph->footer-> center-> SetColor("red");
$graph->Add($p1);
$graph->Stroke();
So kindly assist our request and how to avoid this overlapping design as per the screenshot.
Thanks.
Related
A number of Xero accounts API samples have PHP variables which start with {
Example:
$invoices = {invoices:[{type: Invoice.TypeEnum.ACCREC, contact:{contactID:"00000000-0000-0000-000-000000000000"}, lineItems:[{ description:"Acme Tires", quantity:2.0, unitAmount:20.0, accountCode:"000", taxType:"NONE", lineAmount:40.0}], date:"2019-03-11", dueDate:"2018-12-10", reference:"Website Design", status: Invoice.StatusEnum.DRAFT}]};
I am struggling to understand how this can work. I am trying to use the API to create multiple invoices in the same call, I can do it fine in Postman so I know my code is OK.
I have tried following:
creating-an-invoice-using-oauth2-in-xero
Using the documents
But for some reason I just can't find a way to make it work.
All our SDKs and documentation is generated from our OpenAPI specs. Generating runnable code in our docs is our long term goal. In the interim, we needed to offer "some" generated docs, but the JSON payloads are not meant to be used.
We have created a sample app that demonstrates different endpoints and displays the code used to make the call.
https://github.com/XeroAPI/xero-php-oauth2-app
Here is the code you'll need to create an invoices
$result = $apiInstance->getContacts($xeroTenantId);
$contactId = $result->getContacts()[0]->getContactId();
$contact = new XeroAPI\XeroPHP\Models\Accounting\Contact;
$contact->setContactId($contactId);
$arr_invoices = [];
$invoice_1 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_1->setReference('Ref-456')
->setDueDate(new DateTime('2019-12-10'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_1);
$invoice_2 = new XeroAPI\XeroPHP\Models\Accounting\Invoice;
$invoice_2->setReference('Ref-123')
->setDueDate(new DateTime('2019-12-02'))
->setContact($contact)
->setLineItems($lineitems)
->setStatus(XeroAPI\XeroPHP\Models\Accounting\Invoice::STATUS_AUTHORISED)
->setType(XeroAPI\XeroPHP\Models\Accounting\Invoice::TYPE_ACCPAY)
->setLineAmountTypes(\XeroAPI\XeroPHP\Models\Accounting\LineAmountTypes::EXCLUSIVE);
array_push($arr_invoices, $invoice_2);
$invoices = new XeroAPI\XeroPHP\Models\Accounting\Invoices;
$invoices->setInvoices($arr_invoices);
$result = $apiInstance->createInvoices($xeroTenantId,$invoices);
I have a set of data that spans a number of dates. Some of the data points need to be identified with a different style so they stand out. I can approximate what I need by creating 2 plot lines using different mark styles but it doesn't look cohesive and can be confusing to some people. Here is an example using that method.
All of the data points in the sample above should be connected. The questions are
Is it possible to create a single plot line with different mark styles?
If the answer to the above is no is there a way to somehow "merge" the 2 plot lines so all of the points get connected?
The code that created the sample graph:
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_date.php';
$line1D = array(1497844800,1498449600,1505102400,1516597200);
$line1Y = array(79.00,76.00,53.00,14.00);
$line2D = array(1504584000,1507521600);
$line2Y = array(9.87,9.93);
$graph = new Graph(640,480);
$graph->clearTheme();
$graph->SetScale('datlin');
$graph->xaxis->SetLabelAngle(60);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelFormatString('m/d/Y',true);
$graph->yaxis->scale->SetGrace(5);
$line1=new LinePlot($line1Y,$line1D);
$line1->SetColor('#4A6EC6');
$line1->SetWeight(2);
$line1->mark->SetFillColor('#4A6EC6');
$line1->mark->SetType(MARK_FILLEDCIRCLE);
$graph->Add($line1);
$line2=new LinePlot($line2Y,$line2D);
$line2->SetColor('#4A6EC6');
$line2->SetWeight(2);
$line2->mark->SetType(MARK_CIRCLE);
$line2->mark->SetColor('#4A6EC6');
$graph->Add($line2);
$graph->Stroke(); // display the graph
?>
The way to have different marks on a line is to create a 3rd line that is just the line without any marks. Then change the current lines that have marks to be scatter plots instead so just the points are added with the desired marks. When the 3 things are plotted together, 2 scatter plots and the line, they come together as a single line with different marks.
The modified code that works as desired is:
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_date.php';
require_once 'jpgraph/jpgraph_scatter.php';
$line1D = array(1497844800,1498449600,1505102400,1516597200);
$line1Y = array(79.00,76.00,53.00,14.00);
$line2D = array(1504584000,1507521600);
$line2Y = array(9.87,9.93);
$line3D = array_merge($line1D,$line2D);
$line3Y = array_merge($line1Y,$line2Y);
$graph = new Graph(640,480);
$graph->clearTheme();
$graph->SetScale('datlin');
$graph->xaxis->SetLabelAngle(60);
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelFormatString('m/d/Y',true);
$graph->yaxis->scale->SetGrace(5);
$line1=new ScatterPlot($line1Y,$line1D);
$line1->SetColor('#4A6EC6');
$line1->SetWeight(2);
$line1->mark->SetFillColor('#4A6EC6');
$line1->mark->SetType(MARK_FILLEDCIRCLE);
$graph->Add($line1);
$line2=new ScatterPlot($line2Y,$line2D);
$line2->SetColor('#4A6EC6');
$line2->SetWeight(2);
$line2->mark->SetType(MARK_CIRCLE);
$line2->mark->SetColor('#4A6EC6');
$graph->Add($line2);
$line3=new LinePlot($line3Y,$line3D);
$line3->SetColor('#4A6EC6');
$line3->SetWeight(2);
$graph->Add($line3);
$graph->Stroke(); // display the graph
?>
This is my second day messing with the PHP SDK, I've encountered a road block with uploading an attachment to an Estimate with my code. I wanted a PHP form where one can upload a file and shoot it into the QBO company; my first step was to first try and set a static variable to see if it works, my code look slike this:
$Estimate = $dataService->query("SELECT * FROM Estimate WHERE DocNumber in ('{$ID}')");
// Create a new IPPAttachable
$up = "http://www.somedomain.com/test.pdf";
$sendMimeType = "application/pdf";
$randId = rand();
$entityRef = new IPPReferenceType($Estimate->Id);
$attachableRef = new IPPAttachableRef($entityRef);
$objAttachable = new IPPAttachable();
$objAttachable->FileName = $randId."TEST02.pdf";
//$objAttachable->AttachableRef = $Estimate->DocNumber;
$objAttachable->AttachableRef = $attachableRef;
$objAttachable->Note = "Test";
$objAttachable->ContentType = $sendMimeType;
$resultObj = $dataService->Upload($up,
$objAttachable->FileName,
$sendMimeType,
$objAttachable);
This code fires, adds an attachment to the proper estimate but the attachment is less than 1k and is unreadable. Almost as if it never fetched the document to attach, it simply made some kind of a "generic" success.
Can anyone assist with updating the above code? I'm sure its right in front of me, but I keep missing.
Thank you!
I'm using the Google AdWords PHP API to access statistics from our account. However, I'm getting some really strange read outs from the statistics through the api. I'm trying to access the stats for individuals Ads or Adgroups. The statistics returned, however, are way off what they are in the client center. The code I'm using:
$user->SetClientCustomerId($clientId);
$adService = $user->GetService("AdGroupAdService", ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array("Id", "Name", "Clicks", "Impressions", "Cost");
$selector->predicates[] = new Predicate("AdGroupId", "IN", array($adGroupId));
$selector->dateRange = $dateRange;
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $adService->get($selector);
if (isset($page->entries)) {
foreach ($page->entries as $ad) {
$newLineObject->adName = $ad->name;
$newLineObject->clicks = $ad->ad->AdStats->clicks;
$newLineObject->impressions = $ad->adStats->impressions;
$newLineObject->cost = $ad->ad->AdStats->cost->microAmount/ AdWordsConstants::MICROS_PER_DOLLAR;
}
}
else {
print "No matching ads were found.\n";
}
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
When I print the results I get numbers that are considerably larger than those displayed in the client center. For example, for one partiuclar Ad the API reported 2.000.000 impressions, while the client center showed 56.000.
What am I doing wrong?
Your code seems correct to me. However, you problem may be that your date range in your code is different to the one you see in your client center. Make sure that you keep the same date range when you cross check.
Having tried using the method detailed above extensively, I have altered my code completely. I now use AdHoc Reporting (described here https://developers.google.com/adwords/api/docs/guides/reporting). This method was suggested to me by an AdWords developer. While this does not literally solve my question (i.e. why does the above code return incorrect statistics), it does provide an easy and clean way to obtain the data correctly.
Hi so I've been struggling a good while to make the chart I want and I'm getting very close.
First I have performance data of a stock portfolio that should be on YAXIS #1... That's good.
Then I want a benchmark on YAXIS #2... The Line plot works, but the scale is weird :
Notice how it starts at 50 and goes 10, 15, 20, etc...
The thing is the scale should be between 3400 and 3800 since that's the range of my data.
Here is my code :
<?php // content="text/plain; charset=utf-8"
require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php');
require_once ('jpgraph.php');
require_once ('jpgraph_line.php');
require_once ('jpgraph_date.php');
require_once ('jpgraph_utils.inc.php');
// Get a dataset
$data = get_transient( 'daily_nav' );
$ydata = $data[1];
$xdata = $data[0];
$data2 = get_transient( 'CAC40_history' );
$ydata2 = array_reverse($data2[1]);
$xdata2 = array_reverse($data2[0]);
$dateUtils = new DateScaleUtils();
list($tickPositions, $minTickPositions) = DateScaleUtils::GetTicks($xdata);
// Setup a basic graph
$width=800; $height=500;
$graph = new Graph($width, $height);
$graph->SetScale('datlin');
$graph->SetYScale(0,'lin');
$graph->SetYScale(1,'lin');
$graph->SetMargin(60,20,40,60);
$graph->xaxis->SetPos('min');
$graph->xaxis->SetTickPositions($tickPositions,$minTickPositions);
// Setup the titles
$graph->title->SetFont(FF_GEORGIA,FS_NORMAL,16);
$graph->title->Set('Performance vs. CAC40');
$graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
$graph->subtitle->Set('graphique journalier depuis la création en juin 2012');
// Setup the labels to be correctly format on the X-axis
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(30);
// The second paramter set to 'true' will make the library interpret the
// format string as a date format. We use a Month + Year format m-d-Y
$graph->xaxis->SetLabelFormatString('m-Y',true);
// And then add line. We use two plots in order to get a
// more distinct border on the graph
$lp2 = new LinePlot($ydata,$xdata);
$lp2->SetColor('#71a7da');
$graph->Add($lp2);
$graph->xgrid->Show();
$graph->AddY(0,$lp2);
// second chart
$lp3 = new LinePlot($ydata2, $xdata2);
$lp3->SetColor('blue');
//$graph->Add($lp3);
//$graph->xgrid->Show();
$graph->AddY(1,$lp3);
// And send back to the client
$graph->Stroke();
?>
Would be great if anyone can help, can't figure this one out.
Thanks
I am quite a newbie but had the same issue myself a minute ago.
Missing zeros on the right? Try changing margin settings?
$graph->SetMargin(60,50,40,60);