After I upgraded from 7.x-3.0-alfa5 to 7.x-3.0-beta2, my existing (created in alfa5 version) scatterplot SVG is no longer working. Instead of rendering a scatterplot (as in the alfa5 version), the graph now only contains a message like "No values in grid range". The actual scatterplot I try to create, is similar to the graph in the state_graph sample (delivered with Forena), in which I only changed the graph type (indicated via frx:type) from bargraph to scatterplot. While producing a graph of type bargraph (vertical, horizontal, or 3D), piechart, or linegraph (for the sample users_by_state sample) just continue to work fine after this upgrade (without any changes applied to any of these SVG graph as initially created in alfa5).

I did some research on this, and noticed that in renderers/FrxSvgGraph.inc there are 3 lines inserted in the beta2 version (as compared to the alfa5 version), which look like this:

    if ($type == 'ScatterGraph' || $type=='MultiScatterGraph') {
      $options['scatter_2d'] = TRUE;
    }

By (temporary) commenting out these 3 lines, my scatterplot SVG is rendered perfectly (without any change as compared to what I created in the alfa5 version).

After enabling these 3 lines again (no more in comment), and by adding scatter_2d=false within the frx:options, the problem still exists (so trying to overrule this hardcoded 'scatter_2d' flag seems to not be possible anymore either).

I also tried replacing the frx:options series[]={total} and label={state} by the (new in beta2) frx:series_1="{total}" and frx:label="{state}", but also in this case the problem continues to exist.

My questions:

  1. Why were these 3 lines added in the beta2 version? FYI: I couldn't find any forena issue with scatter_2d, or scatterplot or ScatterGraph.
  2. Do these 3 lines really have to be there (is it acceptable to remove them again)?
  3. For those cases where scatter_2d=TRUE is needed, how about adding them to the frx:options (so that these 3 lines don't have to be hardcoded as in the beta2 version now)?
  4. Is there some other option within frx:options I should change, add or remove (to make my scatterplot work again)?

Comments

metzlerd’s picture

The scatter_2d value will really reduce problems with graphs as the way scatter plots worked prior to php SVG graph 2.10 was that it couldn't graph two values with the same X coordinate. Can I ask that you upgrade to the latest version of PHP SVG Graph? Does that fix your problem?

I'll try and make an add to the release notes to let people know they should upgrade to php SVG Graph version later than 2.10.

Dave

Pierre.Vriens’s picture

David, forgot to mention but my issue was created using the 2.10 version of SVG Graph already, whereas the frx:options in my SVG graph do NOT contain anything like scatter_2d=false or scatter_2d=true. So I'm using the SVG Graph default value for scatter_2d (which is NULL according to the docu on the SVG Graph site). And (as I wrote above) by commenting out those 3 lines (new in beta2), my scatterplot SVG is rendered fine.

I can think of scenarios where that scatter_2d=true will indeed reduce problems (as you also wrote above). But since that value of "true" is only 1 of 3 options (apart from "false" or "null"), it appears to me that it should be possible to "override" the (now, in beta2) hardcoded value of "true". As an alternative: if those 3 lines from the beta2 version would be removed again, one can either uses the SVG Graph default (="null") by not specifying that option, or either "true" or "false" by specifying the desired option.

By the way, I fully agree with your recommendation to upgrade to SVG Graph 2.10. By doing so, you can tune forena a bit to also create a cylindergraph (+ its variations of stacked and grouped, all new in that 2.10 version, though not yet supported by forena), which is what I did already via a fairly small patch of FrxSVGChart.inc . Let me know if you want me to create another Forena issue (with the docu about my patch as attached file added to it, actually a frx file) related to cylindergraph (+ 2 variations) support in Forena. Such docu would also include what's needed to also support radargraph (and its multiradargraph variation), via a similar patch of FrxSVGChart.inc.

metzlerd’s picture

Ok, I'm somewhat convinced. I'm very much open to a patch that would allow scatter_2d to be manually set as long as the default was on for scatter plots. I think I know how I'd write that. Try replacing the test with:

    if (!isset($options['scatter_2d']) && ($type == 'ScatterGraph' || $type=='MultiScatterGraph')) {
      $options['scatter_2d'] = TRUE;
    }
    else { 
      $options['scatter_2d'] = (bool) $options['scatter_2d']; 
    }

Then you could specify the parameter as empty in options. Also, options are now settable using custom frx: attributes rather than having to specify them on the frx:options attribute. So you should be able to specify frx:scatter_2d="0" or frx:scatter_2d="1" or frx:scatter="" in your graph using this code.

I am a bit puzzled by the fact that setting scatter_2d to true breaks your graphs in the current version, though. Are you specifying multiple X series as well? I'd like to know under what senarios this breaks as it may be leading to another bug. Would you mind pasting a code snippet of your graph so that I could try and replicate this problem?

Yes, lets also create another issue to support the new cylindergraph + 2 variations on the graph type. Happy to continue to support them.

Pierre.Vriens’s picture

David, here is my code snippet as you asked for, actually 3 syntax-variations to further investigate this issue:

		<svg id="ScatterPlot1" frx:block="sampledb/users_by_state" frx:renderer="FrxSVGGraph"
				frx:type="scatterplot" frx:xpath="*[total&gt;10000]"
				frx:link="sample.user_distribution_simple?state={state}"
				frx:options="series[]={total}&amp;label={state}&amp;scatter_2d=0">
		</svg>
		<svg id="ScatterPlot2" frx:block="sampledb/users_by_state" frx:renderer="FrxSVGGraph"
				frx:type="scatterplot" frx:xpath="*[total&gt;10000]"
				frx:link="sample.user_distribution_simple?state={state}"
				frx:scatter_2d="0"
				frx:options="series[]={total}&amp;label={state}">
		</svg>
		<svg id="ScatterPlot3" frx:block="sampledb/users_by_state" frx:renderer="FrxSVGGraph"
				frx:type="scatterplot" frx:xpath="*[total&gt;10000]"
				frx:link="sample.user_distribution_simple?state={state}"
				frx:options="series[]={total}&amp;label={state}">
		</svg>

So ScatterPlot1 has a scatter_2d=0 value (still via the frx:options), ScatterPlot2 has a scatter_2d=0 value (via (new) the frx:scatter_2d), and ScatterPlot3 has no scatter_2d value at all (so will use the SVG Graph default value, which seems to be NULL). So I'm not specifying multiple X series (instead these SVG are quite close to your original SVG sample (frx:type is about the only difference I believe).

My newest test-results for these 3 SVG variations are as follows:

  1. WITHOUT the 3 added lines of code (in the beta2 version), and WITHOUT replacing those lines with the code you mentioned in #2, all 3 SVGs as in the code-snippet above, work fine.
  2. WITHOUT the 3 added lines of code (in the beta2 version), and WITHOUT replacing those lines with the code you mentioned in #2, but with the scatter_2d value changed from 0 to 1 (in ScatterPlot1 and ScatterPlot2) the ScatterPlot1 graph does not get created anymore (it shows a "Zero length axis" instead), while ScatterPlot2 and ScatterPlot3 work (still) fine. Same results if I use values true, TRUE, false or FALSE instead of 1.
  3. WITH a replace of the 3 added lines of code (in the beta2 version) by those lines of code you mentioned in #2, and using the code-snippet above (so with scatter_2d value 0), ScatterPlot1 works (still) fine, but ScatterPlot2 and ScatterPlot3 both do not get created anymore (they show a "Zero length axis" instead)..
  4. WITH a replace of the 3 added lines of code (in the beta2 version) by those lines of code you mentioned in #2, but with the scatter_2d value changed from 0 to 1 (in ScatterPlot1 and ScatterPlot2), none of the 3 graphs get created anymore (they all show a "Zero length axis" instead). Same results (none of the 3 graphs get created) if I use values true, TRUE, false orFALSE instead of 1.

Does this help to better understand what's happening (and hopefully solve it somehow for the various scatter_2d related scenarios)?

PS: I'll soon create a new issue for the cylindergraphs (and radargraphs), and attach my patched FrxSVGChart.inc to it, as well as a sample frx of those charts (which should work after the patch is applied).

metzlerd’s picture

Status: Active » Fixed

So this is interesting. A scatter plot with no seriesx is a case I admit I had not thoroughly tested, or thought of. Normally, we'd expect there to be an seriesx instead of a label in these graphs like this:

		<svg id="ScatterPlot3" frx:block="sampledb/users_by_state" frx:renderer="FrxSVGGraph"
				frx:type="scatterplot" frx:xpath="*[total&gt;10000]"
				frx:link="sample.user_distribution_simple?state={state}"
				frx:options="series[]={total}&amp;seriesx[]={total}">
		</svg>

But you raise a valid point. In some cases the x values are not numbers but rather labels (e.g. month) that imply an evenly spaced scale. To this end I've made a slightly more complicated fix to have the default change based on whether you are specifiying seriesx or labels. It is worth noting that if you specify scatter_2d = 1 but have still specified labels instead of seriesx, then you will get a graph with no x values, but in reality with the new fix that will be in the next beta will make the setting of scatter_2d almost moot. You simply need to specify labels when you want that behavior, but if you specify seriesx, then we expect graphable x-y coordinates in the data.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.