ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Zoom in Zoom out options
Posted by contour on Sep-20-2012 14:34
Attachments:
hi,

we are using php to generate the contour maps. but we are facing the following issue. we have also attached the php file.

Query 1 parameters
//$year = "2007";
//$month = "July";
//$parameter = "Rainfall";f


## query 1
//$query="SELECT Longitude, Latitude, Rainfall as pa from wrm where year = 2007 and month ='July'";

//#Query 2 Parameters
$parameter = $_POST['Parameter'];
$year = $_POST['Year'];
$month = $_POST['Month'];

//#Query2
$query="SELECT Longitude, Latitude,".$parameter." as pa from wrm where year ='".$year."' and month ='".$month."'";

when we are using Query1 style the zoom in and zoom out options are working perfectly. however when Query2 sytle is used the zoom in and zoom out options are not working.
what can be the issues??
dsis_contour.php
dsis_contour.php

20.79 Kb

  Re: Zoom in Zoom out options
Posted by Peter Kwan on Sep-21-2012 00:20
Hi,

In your case, you are using POST data. POST data only works if your request is a POST request. It does not work for AJAX chart updates, which may not be a POST requests, and do not contain the Parameter, Year and Month.

To solve the problem, you may try something like:

if (!$viewer->isPartialUpdateRequest())
{
   #normal request
   $parameter = $_POST['Parameter'];
   $year = $_POST['Year'];
   $month = $_POST['Month'];

   #store the data in custom fields so they can be available during AJAX updates
   $viewer->setCustomAttr('ppp', $parameter);
   $viewer->setCustomAttr('yyy', $year);
   $viewer->setCustomAttr('mmm', $momth);
}
else
{
    #AJAX chart update - retrieve parameter from custom attributes
   $parameter = $viewer->getCustomAttr('ppp');
   $year = $viewer->getCustomAttr('yyy');
   $month = $viewer->getCustomAttr('mmm');
}

Hope this can help.

Regards
Peter Kwan

  Re: Zoom in Zoom out options
Posted by contour on Sep-21-2012 14:25
Hi Peter,

We paste the code in drawChart method in dsis_contour and we run it, but still we are getting the same problem.

we think that during reload the three parameters using POST method are getting NULL.

So, could you please help me in solving this.

  Re: Zoom in Zoom out options
Posted by Peter Kwan on Sep-22-2012 00:44
Hi contour,

Sorry, I have just found a typo error in the code in my message. The $momth should be $month.

As mentioned in my previous message, during reload (AJAX chart update), the POST parameters are NULL. This is normal. POST parameters should be NULL unless the request is a POST request. (A reload request is not a POST request.)

So in my suggested code, during the reload request (detected using $viewer->isPartialUpdateRequest()), the POST parameters are never used, because they are NULL. Instead, the getCustomAttr is used.

I have just examine your real code, and found that you have another line of code that checks if the POST parameters are NULL (if(empty($_POST['Parameter']))). Your code should not do this test during "reload" (AJAX chart update), because the parameters will not be obtained from POST, but from getCustomAttr. Your code should be modified to:

function drawChart(&$viewer) {
    #
    # For simplicity, in this demo, the data arrays are filled with hard coded data. In a real
    # application, you may use a database or other data source to load up the arrays.

   // this is the code for data base connectivity and retreving the data from database modifyed by me on 6th sept 2012.
    if (!$viewer->isPartialUpdateRequest())
    {
        #normal request
        if(empty($_POST['Parameter']))
        {
            $year = "2007";
            $month = "July";
            $parameter = "Rainfall";
        }
        else
        {
            $parameter = $_POST['Parameter'];
            $year = $_POST['Year'];
            $month = $_POST['Month'];
        }

        #store the data in custom fields so they can be available during AJAX updates
        $viewer->setCustomAttr('ppp', $parameter);
        $viewer->setCustomAttr('yyy', $year);
        $viewer->setCustomAttr('mmm', $month);
    }
    else
    {
        #AJAX chart update - retrieve parameter from custom attributes
        $parameter = $viewer->getCustomAttr('ppp');
        $year = $viewer->getCustomAttr('yyy');
        $month = $viewer->getCustomAttr('mmm');
    }

......

}

Hope this can help.

Regards
Peter Kwan

  Re: Zoom in Zoom out options
Posted by contour on Sep-24-2012 12:56
Hi Peter,

It is working, thanks alot.

contour wrote:

hi,

we are using php to generate the contour maps. but we are facing the following issue. we have also attached the php file.

Query 1 parameters
//$year = "2007";
//$month = "July";
//$parameter = "Rainfall";f


## query 1
//$query="SELECT Longitude, Latitude, Rainfall as pa from wrm where year = 2007 and month ='July'";

//#Query 2 Parameters
$parameter = $_POST['Parameter'];
$year = $_POST['Year'];
$month = $_POST['Month'];

//#Query2
$query="SELECT Longitude, Latitude,".$parameter." as pa from wrm where year ='".$year."' and month ='".$month."'";

when we are using Query1 style the zoom in and zoom out options are working perfectly. however when Query2 sytle is used the zoom in and zoom out options are not working.
what can be the issues??