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

Message ListMessage List     Post MessagePost Message

  isPartialUpdateRequest issue
Posted by Dan on Oct-10-2012 03:22
I am using the python version of ChartDirector and have successfully implemented real time cursor tracking using the example code in the documentation.  I am now trying to move this code over to django and have most of it working.  The initial request (full update) works fine; however,  the partialUpdate is failing.

The snippet of code being executed on the server is:

def display_chart(request):
  viewer = WebChartViewer(request, 'chart1')
  if viewer.isPartialUpdateRequest():
      .. set up the partial update call..
      return HttpResponse( viewer.partialUpdateChart() )
  #...draw the chart here call
  # remainder of code to return the full response

The problem is on the ajax call the expression viewer.isPartialUpdateRequest() is return false which is causing the chart to generate a full response and causes the "Partial Update returns invalid data" message.

Using firefox, I looked at the parameters being sent to the server on the ajax call and it seems ok to me (see below):

cdCacheDefeat = 1349809457200
cdLoopBack = 1
cdPartialUpdate = chart1
chart1_JsChartViewerState = 0*401*302*21203*9564*05*06*17*18*29**#00000010*011*012*013*214*0.515*0.0116*117*0.0118*119*523*124**cutoff_mm*2425*0

What am I missing?

Thanks!

  Re: isPartialUpdateRequest issue
Posted by Peter Kwan on Oct-11-2012 01:03
Hi Dan,

The method to retrieve query parameters is different for every web framework. In some programming languages (such as PHP, Ruby, Java/JSP, C#/VB.NET/ASP.NET, VBScript/ASP, ColdFusion), the web framework is quite standard. However, in Python, Perl and C++, there is no dominate web framework. The only standard web framework included in Python is CGI (see http://docs.python.org/library/cgi.html). WebChartViewer is designed assuming the "query" object (the first argument to WebChartViewer) is the standard Python cgi.FieldStorage object.

In your case, your code probably is not using the standard Python cgi.FieldStorage object, but is using the Django HTTPRequest object. WebChartViewer does not know how to use a Django HTTPRequest object, and this is why the code does not work.

For your case, you may consider one of the following methods:

(a) Do not use Django for scripts that use WebChartViewer. Instead, just use CGI.

(b) Try to create the cgi.FieldStorage object yourself by copying the query parameters from the Django HTTPRequest object.

Regards
Peter Kwan

  Re: isPartialUpdateRequest issue
Posted by Dan on Oct-11-2012 20:43
I was able to get this working using your 2nd suggestion -- creating the FieldStorage object
and populating it with the query parameters.

For those interested, this is what I did in the view handling the request (note: I am sure
there are better ways to accomplish this, but in the interest of time this does the trick):

import os, cgi, urllib
...standared view handers...

def myHandler(request):
  s = urllib.urlencode( request.REQUEST )
  os.environ['QUERY_STRING'] = s
  f = cgi.FieldStorage()
  viewer = WebChartViewer(f, "chart1")
  ...logic to determine if partialUpdate or full response
  ..etc...

  Re: isPartialUpdateRequest issue
Posted by nmahale on Jan-19-2017 12:12
Hi Dan

   I am also working on same.
To get data on web page using Django with scrollbar,zoomin,zoomout facilitis.
If you have any example related to this please help.

Thanks
Neha

  Re: isPartialUpdateRequest issue
Posted by Peter Kwan on Jan-20-2017 15:47
Hi nmahale,

My response is at:

http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1204518493#N1484898366

Regards
Peter Kwan