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

Message ListMessage List     Post MessagePost Message

  Decode the chart viewer state
Posted by at on Mar-23-2018 15:32
Hi Peter, how can i decode the chart viewer state passed by Chartdirector during partial update so that I can get the value of a certain custom attribute in php? Unfortunately I can't use getCustomAttr() since the value of the attribute is needed before the viewer is being initialized.

Looking at the sample string below (value of the "chart_id"+_JsChartViewerState in the query string) during partial update, how can I decode it in order to get the value of  "data_to_use" attribute?

0*56�1*111�2*485�3*284�4*0.332577325879913�5*0�6*0.19381443298969073�7*1.2�8*2�9**#000000�10*3�11*2�12*2�13*2�14*0.5�15*0.01�16*1�17*1.2�18*1�19*5�23*1�24**data_options**[{"id":"","text":""},{"id":"min_max","text":"Min & Max Results"},{"id":"iqr_limits","text":"(Q1 - 1.5*IQR) & (Q3 + 1.5*IQR)"}]�encoded_legend**[{"id":"Mean","text":"Mean"},{"id":"Outliers","text":"Outliers"}]�x_max*8�x_min*0�y_max*-0.4�y_min*-0.8�data_to_use**min_max�25*0

  Re: Decode the chart viewer state
Posted by Peter Kwan on Mar-23-2018 17:47
Hi at,

We do not suggest people to rely on the internal format of the partial update. It is because it is an internal format and we do not guarantee it will not change in future versions of ChartDirector. On the other hand, we will keep the API stable and backwards compatible.

In our sample code, the first executable line in the PHP code is to get the WebChartViewer. For example, in the "Simple Zooming and Scrolling" sample code, the code structure is like:

<?php
require_once("../lib/phpchartdir.php");

.... same function definition here ....

#first executable line
$viewer = new WebChartViewer("chart1");

Is it possible to use a similar code structure, so that the WebChartViewer is available before you run any other PHP code?

If you cannot create the WebChartViewer first, the followings are some methods I suggest:

(a) Pass the parameter using cookies

or

(b) Insert your own tag to mark the data and save that as an arbitrary custom attribute. For example, for the value, you can use:

__923492jkj__data_to_use=min_max__1974198jgi__

Now in your own PHP code, you just need to search for __923492jkj__ and __923492jkj__ and what is in between is your attribute. With the method, you do not need to make any assumption on the internal format of the custom attributes, except that the attribute values are included in the query parameters. Note that the query parameters may not be the same as the original text. If the original text contains characters that are invalid in URL, it may be escaped as per URL escape rules.

Regards
Peter Kwan

  Re: Decode the chart viewer state
Posted by at on Mar-26-2018 10:23
Thanks Peter, I think I'll just have to use your last suggestion.