Menu

range of axis and customizing the image look

Pradeep
2016-02-10
2016-02-12
  • Pradeep

    Pradeep - 2016-02-10

    Code at the php file

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    
    require_once 'phplot.php';
    
    $image_map = "";
    
    $title=$_POST['Shoe_name'];
    $heal_fit=$_POST['Heal_Fit'];
    $forefoot_fit=$_POST['Forefoot_Fit'];
    $midfoot=$_POST['Midfoot'];
    $toe_Box_depth=$_POST['Toe_Box_Depth'];
    $arch_height=$_POST['Arch_Height'];
    $forefoot_flex=$_POST['Forefoot_Flex'];
    $forefoot_feel=$_POST['Forefoot_Feel'];
    
    if(isset($_POST["submit"]))
    {
        if(empty($heal_fit) || empty($forefoot_fit) || empty($midfoot) || empty($toe_Box_depth) || empty($arch_height) || empty($forefoot_flex) || empty($forefoot_feel)) 
         {
        echo "You did not fill out the required fields.";   
          }
    else {
    $data = array(
        array('Forefoot Feel', $forefoot_feel),
        array('Forefoot Flex', $forefoot_flex),
        array('Arch Height', $arch_height),
        array('Toe Box Depth', $toe_Box_depth),
        array('Midfoot', $midfoot),
        array('Forefoot Fit', $forefoot_fit),
        array('Heal Fit', $heal_fit), 
    
    );
    # Callback for 'data_points': Generate 1 <area> line in the image map:
    function store_map($im, $passthru, $shape, $row, $col, $x1, $y1, $x2, $y2)
    {
        global $image_map;
    
        # Title, also tool-tip text:
        $title = "Group $row, Bar $col";
        # Required alt-text:
        $alt = "Region for group $row, bar $col";
        # Link URL, for demonstration only:
        $href = "javascript:alert('($row, $col)')";
        # Convert coordinates to integers:
        $coords = sprintf("%d,%d,%d,%d", $x1, $y1, $x2, $y2);
        # Append the record for this data point shape to the image map string:
        $image_map .= "  <area shape=\"rect\" coords=\"$coords\""
                   .  " title=\"$title\" alt=\"$alt\" href=\"$href\">\n";
    }
    
    # Create and configure the PHPlot object.
    $plot = new PHPlot(640, 480);
    # Disable error images, since this script produces HTML:
    $plot->SetFailureImage(False);
    # Disable automatic output of the image by DrawGraph():
    $plot->SetPrintImage(False);
    # Set up the rest of the plot:
    $plot->SetTitle($title);
    
    $plot->SetImageBorderType('plain');
    $plot->SetDataValues($data);
    // $plot->SetDataType('text-data');
    $plot->SetYTickPos('plotleft');
    $plot->SetAxisFontSize('5');
    $plot->SetXTickPos('plotup');
    //  No X axis labels. The data values labels are sufficient.
    $plot->SetXTickLabelPos('plotup');
    $plot->SetDataType('text-data-yx');
    // $plot->SetLegendPosition(0, 0, 'image', 0, 0, 5, 5);
    $plot->TuneYAutoRange(0, 'R', 0);
    $plot->TuneYAutoTicks(NULL, 'binary');
    $plot->SetPlotType('bars');
    $plot->SetXTickPos('none');
    $plot->SetAxisFontSize('5');
    //  Set the bar fill color:
    $plot->SetDataColors('green');
    //  Use less 3D shading on the bars:
    $plot->SetShading(10);
    # Set the data_points callback which will generate the image map.
    $plot->SetCallback('data_points', 'store_map');
    // $plot->SetPlotAreaWorld(NULL, 0, NULL, 100);
    $plot->SetPlotAreaWorld(0);
    //$plot->SetPlotAreaWorld(NULL, -10, NULL, 10);
    # Produce the graph; this also creates the image map via callback:
    $plot->TuneYAutoRange(0);
    $plot->TuneXAutoRange(0);
    $plot->DrawGraph();
    $newimg=$plot->EncodeImage();
    # Now output the HTML page, with image map and embedded image:
    ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>PHPlot Example: Bar Chart with Image Map</title>
    </head>
    <body>
    <h1>PHPlot Example: Bar Chart with Image Map</h1>
    <map name="map1">
    <?php echo $image_map; ?>
    </map>
    <p>image map of <?php echo $title; ?></p>
    <img src="<?php echo $newimg;?>" alt="Plot Image" usemap="#map1">
    </body>
    </html>
    
    <?php
    }
    }
    else{
    
        echo "please submit the form";
    }
    
     

    Last edit: lbayuk 2016-02-10
  • lbayuk

    lbayuk - 2016-02-10

    Admin note: I changed your second post to put markers around the code so it would display better. I also edited your first post to change the images into just URLs. For some reason, Sourceforge put these posts into a Moderation queue even though the forum is set to not be moderated. I thought it might be because of the images loaded from numeric IP addresses, so I removed the image markup and left just the URLs. This way people can choose whether to load them or not.

    As for your actual code and question, I will take a look shortly.

     
  • lbayuk

    lbayuk - 2016-02-10

    I am not sure what you mean by "remove the decimal value on the axis". Do you mean in the tick label values along the X axis at the top? (Remember that even with a horizontal bar chart, the horizontal axis is X, and the vertical axis is Y.) I see 0 0.5 1 1.5 etc. If you want them to be whole numbers, then you can use either this, which forces the tick step to 1:

    $plot->SetXTickIncrement(1)
    

    or this, which forces the ticks to be whole integers:

    $plot->TuneXAutoTicks(NULL, NULL, True);
    

    (Which of these is better would depend on the range of data you expect to see.)

    If I am not understanding what you are asking, please clarify.

     
    • Pradeep

      Pradeep - 2016-02-11
      Post awaiting moderation.
  • Pradeep

    Pradeep - 2016-02-12

    Thank you for the Reply
    I want to download the image created , please tell me how I can doe that by code.
    As the image is encoded , its name in the img src is very big
    Also how can I customizwe the look like

    Till now I have recahed to
    Please suggest

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.