This topic is locked
[SOLVED]

 Chart with rangeMaker depending on the filter

7/12/2019 7:18:12 AM
PHPRunner General questions
T
taumic author

Hello,

I've created a sales chart. It allows me to filter by customer number.

In the chart, you can color any areas ( chart.rangeMarker(0) - in JavaScript Chart Modify), which also works very well.

How can I now display or suppress each one of these areas depending on the filters set?

Is that possible at all?

Many thanks for every help!
Michael

fhumanes 7/16/2019

Hello:
I'm sorry not to give you an adjusted solution, because I have not understood your problem well.
To do everything that requires graphics in PHPrunner I suggest reading this article.

https://asprunner.com/forums/topic/26563-anychart-a-hidden-gem-in-phprunner/
Regards,

T
taumic author 7/17/2019



Hello:
I'm sorry not to give you an adjusted solution, because I have not understood your problem well.
To do everything that requires graphics in PHPrunner I suggest reading this article.

https://asprunner.com/forums/topic/26563-anychart-a-hidden-gem-in-phprunner/
Regards,


Hello and many thanks for the answer!

My question didn't refer to the graphical part of the chart, but rather to the data filter.

The chart is based on invoice transactions that contain the customer number as a key field.

On the basis of the data I have made a filter by customer number possible. So I select the customer and get a graph of his sales.

Now, depending on the customer number (of the data filter), I want to color the background for a certain sales area (e.g. from 50 - 100 $ in yellow, from 101 - 500 $ in red). The coloring also works very well in "JavaScript ChartModify" using "chart.rangeMarker(x)". But I don't know how to use the previously set filter value (the customer number) in "JavaScript ChartModify". How do I get the set filter value ?
Note: The search parameters can probably be determined via the search API via "$srchObj->getFieldValue()". Is there for example such a possibility perhaps also for the filter?

I hope, I could show my problem now more clearly.
Many thanks in advance
Michael

fhumanes 7/19/2019

Hello:
For what you are looking for, I would start by getting the content of the where clause of the query.
You can do this in the "before SQL query" event, passing the value of the variable "$ strWhereClause" to a global variable.
The content of this variable (name of the filter fields) will tell you what filters are applied.
Maybe with this you have your solution.
Regards,

T
taumic author 7/19/2019



Hello:
For what you are looking for, I would start by getting the content of the where clause of the query.
You can do this in the "before SQL query" event, passing the value of the variable "$ strWhereClause" to a global variable.
The content of this variable (name of the filter fields) will tell you what filters are applied.
Maybe with this you have your solution.
Regards,


Hello and thank you for your input,
the idea with "$ strWhereClause" was great!

Now I only have the problem that I don't know how to use the PHP-session in "Javascrip Chart Modify".

So

========

var filt = "<?php echo $_SESSION['filter_number_rg']; ?>" ;

alert("Filter: " + filters) ; // Troubleshooting only

========

I'm afraid it's not working.
Sorry, but Javascript is not my strength...

How do I read the PHP-session from "ChartPageBeforeQueryChart" as JavaScript in "Javascrip Chart Modify"?
Gracias y que tengas un buen fin de semana
Michael

fhumanes 7/20/2019

I have another article in my blog that describes how to pass values from the PHP environment to the javascript one. As if the previous example was not clear to you.
https://fhumanes.com/blog/pasar-valores-adicionales-a-los-graficos-anychart-incluido-en-phprunner/
Regards,

T
taumic author 7/22/2019

Thank you so much for your help,
I now have the following working status:



// ChartPage Before SQL query:

// ===========================

$_SESSION["filter_sess"] = $strWhereClause ;
// Before Display:

// ===============

$pageObject->setProxyValue("filter_p_sess", $_SESSION["filter_sess"]);
// JavaScript Chart Modify:

// ========================

// PHP Session to JafaScrip-Var

filt = proxy.filter_p_sess ;
// Mark areas

if (filt == "( ( tw_rg_kopf.RGK_KNR=10001 ) )" )

{

var vMarker = chart.rangeMarker(0); // 1. Area

vMarker.from("0");

vMarker.to("11999");

vMarker.axis(chart.yAxis());

vMarker.fill("#f77e7e"); // red
var vMarker_1 = chart.rangeMarker(1); // 2. Area

vMarker_1.from("12000");

vMarker_1.to("24999");

vMarker_1.axis(chart.yAxis());

vMarker_1.fill("#7fe89e"); // green

}