Thursday, 9 January 2014

P-chart DRUPAL 7.In 6 easy steps

Step 1: Install Pchart Module
Step2: Install libraries
Step3: Download Pchart libraries and copy in sites all libraries
Step 4:See status Report to observe Pchart library as active
Step 5:
 $x=  chart_mine($a,$b,$c,$d);
//where $a to $d are abscissa values
  
Step 6: return $x.'
'; Function chart_mine Definition: $first_values = $a; function chart_mine($a,$b,$c,$d){ $second_values = $b; $third_values=$c; $fouth_values=$d; $name = "pChart"; if ($path = libraries_get_path($name)) { include("{$path}/class/pData.class.php"); include("{$path}/class/pDraw.class.php"); include("{$path}/class/pImage.class.php"); } // Create and populate the pData object. $myData = new pData(); $myData->addPoints($first_values, "Total ISBN"); $myData->addPoints($second_values, "Unique Isbn"); $myData->addPoints($third_values, "Having Catalog"); $myData->addPoints($fouth_values, "No Catalog"); $myData->addPoints(array('TotalISBN', 'Total Unique Isbn', 'Having Catalog', 'No catalog',), "Day"); // Add a description to one series. $myData->setSerieDescription("Days", "Day"); // Define the abscissa axis labels serie. $myData->setAbscissa("Day"); $myPicture = new pImage(1000, 250, $myData); $myPicture->setFontProperties(array("FontName" => "{$path}/fonts/Forgotte.ttf", "FontSize" => 16, "R"=>$FontColorRo,"G"=>$FontColorRo,"B"=>$FontColorRo)); $myPicture->setGraphArea(50, 30, 680, 200); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 102, "StartG" => 178, "StartB" => 255, "EndR" => 0, "EndG" => 0, "EndB" => 50, "Alpha" => 80)); $myPicture->drawScale(array("CycleBackground" => FALSE, "DrawSubTicks" => TRUE, "GridR" => 185, "GridG" => 240, "GridB" => 120, "GridAlpha" => 10)); $settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN); // Draw a bar chart. $myPicture->drawBarChart($settings); $myPicture->drawLegend(540, 12, array("Style" => LEGEND_BORDER, "Mode" => LEGEND_HORIZONTAL)); $output = file_create_filename('example.png', 'sites/default/files/pictures'); $myPicture->Render($output); $x= '
'; return $x; } play with the classes to change color,font,backgrounds,etc.

Wednesday, 8 January 2014

Creating Drupal 7 Service

  array(
      'title'=>t('bbd_servicehello'),
      'description'=>t('Creating a service'),
      ),
      );
      
 }
 /**
 * Implements hook_services_resources().
 */


function bbd_servicehello_services_resources() {
  $bbd_servicehello = array(
      '#api_version' => 3002,
  );
  $bbd_servicehello = array(
      'bbd_greetings' => array(
          'actions' => array(
              'bbd_say_hello' => array(
                  'help' => '',
                  'callback' => 'say_hello',
                  'args' => array(
                      array(
                          'name' => 'greetings_to',
                          'type' => 'string',
                          'description' => 'greetings',
                          'source' => array('data' => 'greetings_to'),
                          'optional' => FALSE,
                      ),
                  ),
                  'access callback' => 'bbd_servicehello_access_menu',
                  'file' => array('type' => 'module', 'module' => 'bbd_serviceshello', 'name' => 'bbd_serviceshello'),
              ),
               
          ),
      ),
  );
  return $bbd_servicehello;
}


function _bbd_servicehello_services_access_callback() {
  return true;
}


function say_hello($greetings_to){
  return array($greetings_to);
}

]