Getting the error "Non-numeric min/max" if one of the columns is all nulls - no chart is produced.
The requirement for this chart is to show target vs actual and only show a third marketing series if there is marketing data.

I tried several workarounds to no avail including:

  • Hide the chart based on conditional rendering - I tried to apply frx:if="{my_column}" to the svg but it always showed - is this just for a1/0 field or can there be a condition here? If this works then I could create an alternative chart with only 2 series.
  • make the value 0 instead of null and hide it - however I tried unsuccessfully to conditionally make it transparent by using a token for marker colour e.g. if marketing is null then 'transparent'
  • put the series 'off the chart' by making the value high than frx:axis_max_v - however I can't get a token to set this dynamically - is it because there are many rows (albeit with the same value) and it needs only one?

It's loosely related to this https://www.drupal.org/node/2356151 however the workaround there works because it adds zeros.

Any help appreciated - thanks.

Comments

MickC’s picture

Another option to meet the requirement could be to use guidelines http://www.goat1000.com/svggraph-guidelines.php

Marking the chart dynamically where there is a marketing event would be a good visual.
I can get a single guideline working using frx:guideline="100", but the examples use array and I can't figure out how to use arrays in frx.

Further, don't know how I would be able to generate multiple guidelines dynamically. The only think I can think of is give them 0 value if there is no data for them, and assume they will appear on the axis.

Note - this is all for multiline charts.

MickC’s picture

Parameters or fields are other options - but I don't know how to automate the values:

  • Parameter - I can get the div to render or not based on a parameter using frx:if={parm:marketing}
  • Field - setting a field value also works e.g. frx:field id="marketing_test" with default of 0 or 1, then the filter becomes frx:{marketing_test}

Is there a way to either autoselect a hidden parameter based on the other parameters as inputs, or to populate a filed value based on a field?
If not in the frx file, in the js?

Thanks

MickC’s picture

It seems I have a solution:

  • I nested the graphs inside a parent div with a 1 line query
  • Now the parent div queries a data block returning a single 1:0 value for a field "marketing".
  • I can now show:hide graphs based on the value in this field:
    • frx:if="{marketing}" - show the 3 series including marketing
    • frx:if="!{marketing}" - show only the 2 series graph

AS it appears this is a solution, hope it helps someone else.
I'd still be interested in knowing how to
- render graphs with null fields
- dynamically alter graph values using tokens
- automatically setting parameter values

metzlerd’s picture

Regarding arrays: In the SVG graph renderer you can specify values as arrays by using attributes with _1 and _2 appended to the end. For example:

  frx:colour_1="red" frx:colour_2="blue"

This technique can be used to pass arrays to any value that takes arrays.

Regarding null values: Currently most null values are suppressed from the graphs, but it sounds like that doesn't really work when there are no values in the graph (all nulls). That seems like something worth fixing so I'll leave this bug open. I'm assuming that the desired behavior would be to supress the series if is empty and perhaps to suppress the whole graph if there are no series?

Regarding automatically setting parameter values:I'm not quite sure what you're asking here. If you are asking about graphing, you can set defaults for graphing in the .skinfo file. There is an old youtube video regarding this rooted in 7.x-3.x that is still relevant. If you're talking about report parameters, these can be set up as report paramters with defaults (you can hide them if you want), or if you're just talking about in a block then use the frx:parameters="" attribute to specify parameters that you want passed down to a block.

Regarding Graph values and tokens: Of course any graph parameter can be replaced using {tokens} or by specifying values in the .skinfo file, but I suspect you're referring to something else I don't understand. In the latest version of forena, you can also define calculations as well, but I'm not sure I'm understanding what you mean, so more clarity about what you're looking for.

MickC’s picture

Thanks for your response David - further clarification as follows:

Arrays: The issue is how to use an SVG feature such as Guidelines http://www.goat1000.com/svggraph-guidelines.php which uses arrays e.g. array( "guideline" => array(10, "Target", "y"). As above I could get a single guideline working using frx:guideline="100" but no idea how to get the other variables in.

Null Values: Actually the case here is when a single series is null, but there is data for the other series. In my case target, sales have data but marketing may or may not. The chart will render if a single data point in the marketing series is available, but not if the whole series is null. Certainly suppressing a single series would be good. Less important is the case for showing a whole graph if no data at all - maybe interesting if for presentation purposes it is better to show something than nothing, even is just the axes but an empty chart.

Automatic Parameters: Does that mean I could dynamically set the default using e.g. frx:parameters="marketing={marketing}" ? Worth a try...

Graph Values as Tokens: This relates to the original post points about unsuccessfully trying to use tokens to:

  • make the value 0 instead of null and hide it - however I tried unsuccessfully to conditionally make it transparent by using a token for marker colour e.g. if marketing is null then 'transparent'
  • put the series 'off the chart' by making the value high than frx:axis_max_v - however I can't get a token to set this dynamically - is it because there are many rows (albeit with the same value) and it needs only one?

I couldn't get the tokens to work so any tips here most welcome.

Many thanks

metzlerd’s picture

Arrays:I'll look more closely at this and get back to you. I'll write up a sample in my sandbox if I can get it to work.

Null Values:Ok, will see if I can get you a patch on this.

Automatic Parameters:Yep... I do that kind of stuff all the time.

Tokens:When referring to tokens that are inside a block that you haven't iterated yet (using frx:foreach) then you need to specify a token using the xpath syntax like this {row/max_value} or {*/max_value}. Tokens in this form are basically xpath expressions and return the first value matching the xpath expressions.

MickC’s picture

Thanks David - RE Token, I can't seem to get anything to appear just using {row/max_value} - how do you specify the field? e.g. If I have a field named "Volume", something like frx:inner_text="{row/max_value[Volume]}" ?

metzlerd’s picture

I just committed an example of what I mean to my sandbox at:

http://cgit.drupalcode.org/sandbox-metzlerd-frx/tree/reports/test-graph....

You can always check out the project for common examples.

Note that in this example its using the first value of the {name} column in the users by state query to be the graph_title by specifying:

         frx:graph_title="{row/name}"

Does that make it clearer?

metzlerd’s picture

Status: Active » Closed (duplicate)