Jpgraph : Set Value Y-AXIS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahmawaktu
    New Member
    • Jul 2007
    • 2

    Jpgraph : Set Value Y-AXIS

    Dear list, i am new to this forum and to JPGraph too. I just install jpgraph to create a graphic to my website. But i got error.

    Here is the complete code :

    First is MySQL Database : ( 2 tables) :

    1. Table : Hesk_Categories

    [CODE=sql]
    CREATE TABLE `hesk_categorie s` (
    `id` int(5) unsigned NOT NULL auto_increment,
    `name` varchar(60) NOT NULL default '',
    `cat_order` smallint(5) unsigned NOT NULL default '0',
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT= 6 ;

    #
    # Dumping data for table `hesk_categorie s`
    #

    INSERT INTO `hesk_categorie s` VALUES (1, 'Komputer', 10);
    INSERT INTO `hesk_categorie s` VALUES (4, 'Customer Services Problem', 20);
    INSERT INTO `hesk_categorie s` VALUES (5, 'Treasury Problem', 30);

    [/CODE]

    2. Table Hesk_Tickets

    [CODE=sql]CREATE TABLE `hesk_tickets` (
    `id` mediumint(8) unsigned NOT NULL auto_increment,
    `trackid` varchar(10) NOT NULL default '',
    `name` varchar(50) NOT NULL default '',
    `email` varchar(50) NOT NULL default '',
    `category` smallint(5) unsigned NOT NULL default '1',
    `priority` enum('1','2','3 ') NOT NULL default '3',
    `subject` varchar(70) NOT NULL default '',
    `message` text NOT NULL,
    `dt` varchar(25) NOT NULL default '0000-00-00 00:00:00',
    `lastchange` varchar(25) NOT NULL default '0000-00-00 00:00:00',
    `ip` varchar(20) NOT NULL default '',
    `status` enum('0','1','2 ','3') default '1',
    `lastreplier` enum('0','1') NOT NULL default '0',
    `archive` enum('0','1') NOT NULL default '0',
    `attachments` text,
    `custom1` varchar(255) NOT NULL default '',
    `custom2` varchar(255) NOT NULL default '',
    `custom3` varchar(255) NOT NULL default '',
    `custom4` varchar(255) NOT NULL default '',
    `custom5` varchar(255) NOT NULL default '',
    PRIMARY KEY (`id`),
    KEY `trackid` (`trackid`),
    KEY `archive` (`archive`)
    ) TYPE=MyISAM AUTO_INCREMENT= 36 ;

    #
    # Dumping data for table `hesk_tickets`
    #

    INSERT INTO `hesk_tickets` VALUES (34, 'WMW', 'tes', 'tes@tes.com', 1, '3', 'fdf', 'gfdsg', '19 July 2007, 4:14 PM', '20 July 2007, 1:55 PM', '172.32.30.121' , '2', '1', '0', '', '', '', '', '', '');
    INSERT INTO `hesk_tickets` VALUES (35, '6PE', 'Waode Rahmawaktu', 'waode.rahmawak tu@gmail.com', 1, '1', 'Monitor Mati', 'Dear helpdesk, <br />\r\n<br />\r\nPagi ini saya sudah mencoba menyalakan komputer saya beberapa kali. Komputernya hidup, tapi layar monitornya tidak bisa menampilkan tampilan dari program komputer. Padahal monitor tersebut sudah dinyalakan (kabel juga sudah dicolokin ke tempat colokan listrik). Kok ga bisa nyala ya? Apa monitornya yang rusak? Saya belum bisa mencoba diganti dengan monitor lain karena ga ada monitor yang tidak terpakai, semuanya terpakai. Tolong donk bagian TSI nya ke sini , dibenerin gitu monitor gue. <br />\r\n<br />\r\nThanks', '20 July 2007, 9:40 AM', '20 July 2007, 11:28 AM', '172.32.30.121' , '3', '1', '0', '', '', '', '', '', '');
    [/CODE]

    And the PHP CODE is here :

    [PHP]
    <?php
    include ("jpgraph/src/jpgraph.php");
    include ("jpgraph/src/jpgraph_bar.php ");

    $db = mysql_connect(" localhost", "root","roo t") or die(mysql_error ());

    mysql_select_db ("helpdeskSULTR A",$db) or die(mysql_error ());

    $sql = mysql_query("SE LECT * FROM hesk_categories ") or die(mysql_error ());


    while($row=mysq l_fetch_array($ sql))
    {

    $leg[]=$row[1];
    $idkat=$row[0];

    $sql_tiket=mysq l_query("SELECT COUNT(*) FROM hesk_tickets WHERE category=$idkat ");

    $data[] = $sql_tiket;

    }

    $graph = new Graph(250,150," auto");
    $graph->SetScale("text int");
    $graph->img->SetMargin(50,3 0,50,50);

    $graph->SetShadow();

    $graph->xaxis->SetTickLabels( $leg);

    $bplot = new BarPlot($data);
    $bplot->SetFillColor(" lightgreen"); // Fill color
    $bplot->value->Show();
    $bplot->value->SetFont(FF_ARI AL,FS_BOLD);
    $bplot->value->SetAngle(45) ;
    $bplot->value->SetColor("blac k","navy");

    $graph->Add($bplot);
    $graph->Stroke(); ?>

    [/PHP]

    The error message is :

    Cannot use auto scaling since its imposible to determine a valid min/max value of y-axis(only null values)


    My Need is : I want to display in a graphic about how many tickets in a category. Thanks for help!!
    Last edited by rahmawaktu; Jul 23 '07, 07:12 AM. Reason: correct the english grammar
  • rahmawaktu
    New Member
    • Jul 2007
    • 2

    #2
    Sorry, i found the solution . that just a wrong sql syntax. Thanks :)

    Comment

    • kovik
      Recognized Expert Top Contributor
      • Jun 2007
      • 1044

      #3
      You will need to check the JPGraph documentation for that error message. That error is produced by the application, not PHP.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, rahmawaktu. Welcome to TSDN!

        Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

        Comment

        Working...