Hitachi Vantara Pentaho Community Forums
Results 1 to 36 of 36

Thread: Open Flash Chart not working with HTML Template

  1. #1
    Join Date
    May 2009
    Posts
    10

    Default Open Flash Chart not working with HTML Template

    I have an open flash chart that is working great when I navigate to the xaction file and run it. As soon as I try to integrate it into a dashboard it doesn't work. For example my code in the HTML looks like this:

    PieGrid =
    {
    name: "Pie",
    type: "xaction",
    solution: "bi-developers",
    path: "cdf-samples/20-samples/Test",
    action: "pie.xaction",
    listeners:[],
    parameters: [],
    htmlObject: "Pie",
    executeAtStart: true,
    preExecution:function(){},
    postExecution:function(){}
    }
    I have two xaction files that I created for testing. One renders a chartcomponent pie chart, and when I call its xaction file the html page runs beautifully. When I point it to the flash xaction (which runs independently) I get a big blank window. The fact that the window is big means that it at least is picking up the height and width of the object, but simply isn't rendering it. When I right click on the big open space I am getting the greyed out "move not loaded" flash menu. I have been trying different things for two days and have had no success. I am at my wits end!

  2. #2
    Join Date
    May 2009
    Posts
    10

    Default Got it.

    After scrolling through my tomcat console, I came across an error saying that it couldn't find the open-flash-chart-full-embedded-font.swf. It was looking in a directory that didn't exist (yet). I found this file, created the directory it was looking for (...biserver-ce-3.0.0.RC2\biserver-ce\pentaho-solutions\system\pentaho-cdf\openflashchart) and dropped the file in there. Worked like a charm. So.. my question is, what is the deal with that?

  3. #3

    Default

    I had the same issue...
    http://forums.pentaho.org/showthread.php?t=69610

    and I tried your solution previously with less success. Maybe I will try again, but this seems to be a bug.

  4. #4
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    This solved the problem for me too. I created a Jira entry for this issue: http://jira.pentaho.com/browse/BISERVER-3156

    Cheers!

  5. #5
    Join Date
    Apr 2009
    Posts
    7

    Default

    I am getting the blank open flash chart issue.

    I'm using biserver-ce-3.0.0.RC2 on Windows XP.

    I copied the appropriate file mentioned below to the new openflashchart directory.

    Here is my CDF code in my template.html:

    qualityBarLineChart =
    {
    name: "qualityBarLineChart",
    type: "xaction",
    solution: "Sandbox3",
    path: "openflashchart",
    action: "qualityBarLineChart.xaction",
    listeners:[],
    parameters: [],
    htmlObject: "QualityBarLineObject",
    executeAtStart: true
    }


    Here is my xaction code for the chart:

    <action-definition>
    <component-name>OpenFlashChartComponent</component-name>

    <action-type>Open Flash Chart</action-type>

    <action-inputs>
    <chart-datatype="result-set"/>
    <heighttype="string"mapping="chart_height"/>
    <widthtype="string"mapping="chart_width"/>
    </action-inputs>

    <action-resources>
    <chart-attributestype="resource"mapping="barline"/>
    </action-resources>

    <action-outputs>
    <content_urltype="string"/>
    </action-outputs>

    <component-definition/>

    </action-definition>

  6. #6
    Join Date
    Apr 2009
    Posts
    7

    Default

    Could anyone provide some assistance? Cheers

  7. #7
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    Well, I suspect your xaction definition is not fully correct. Since I don't have the complete example I can't reproduce your environment, so I just went ahead and created a very basic example of a dashboard with a Flash Chart that you can modify it to fit your needs. Find it attached. The contained folder must be placed in the "pentaho-solutions" directory.

    ¡Cheers!
    Attached Files Attached Files

  8. #8
    Join Date
    Apr 2009
    Posts
    7

    Default

    When I load that solution I get a empty box with no data (see empty.jpg attached). Disregard the missing CDF header as I modified the mantle template.html.

    Regarding changing the xaction, I did. I now receive a JSON error. See issue.jpg attached.

  9. #9
    Join Date
    Apr 2009
    Posts
    7

    Default

    Sorry....files attached.
    Attached Files Attached Files

  10. #10
    Join Date
    Jul 2007
    Posts
    1,013

    Default

    Are you getting anything in the logs? Because the solution I attached is very simple: its failing indicates that something could be wrong with your installation. Can you try and run it in an unmodified version of the platform?

    Cheers!

  11. #11
    Join Date
    Apr 2009
    Posts
    7

    Default

    I reinstalled stable 3.0.0 and I have the same issue with your example. I can run the query against the sample database and see the 4 records it returns. However, when using it within the xaction, it doesn't display the Flash Pie Chart.

    Could you take a look at my example to see if I'm missing something?

    Also, the .swf file....I should have only the "open-flash-chart-full-embedded-font.swf" file in "<PENTAHO_HOME>/biserver-ce/pentaho-solutions/system/pentaho-cdf/openflashchart/" correct?

    Lastly, the Steel Wheels flash example (Revenue Analysis) displays the pie graph, however, when I select a slice, I get a message saying that I will be navigating to another site. Not sure if this is related.
    Attached Files Attached Files

  12. #12
    Join Date
    Apr 2009
    Posts
    7

    Default

    Here is the log when I attempt to use the OpenFlash LineChart:

    12:47:12,148 ERROR [GenericServlet] GenericServlet.ERROR_0002 - Could not get content generator: data-files

  13. #13
    Join Date
    May 2009
    Posts
    1

    Default ie vs firefox & chrome

    I think it is not working in internet explorer.
    I have no problem with other browser.
    Is there any solution for internet explorer.

  14. #14

    Default

    Has anyone found a fix for this issue? I am having the same problem. I get the following error in IE only:


    Open Flash Chart

    JSON Parse Error [Syntax Error]
    Error at character 0, line 1:

    0: GenericServlet.ERROR_0002 - Could not get content generator: data-file


    It works fine in Firefox.

  15. #15

    Default Internet Explorer is the problem

    Hello folks,

    I had the same problem with open flash chart that Kevin talked about it.

    See the post:
    http://www.nicholasgoodman.com/bt/bl...comment-274356

    The error is:
    -----------------------------------------------------------------------
    Open Flash Chart
    JSON Parse Error [Syntax Error]
    Error at character 0, line 1:
    0: GenericServlet.ERROR_0002 - Could not get content generator: data-file
    -----------------------------------------------------------------------

    I did not work with Internet Explorer just with Firefox.

    The problem is Internet Explorer.

  16. #16
    Join Date
    Jan 2008
    Posts
    177

    Default

    Hi
    for me is a big problem...and the most important project is blocked (unfortunately, my clients have almost internet explorer).

    I've open an issue...but no news recently.

    http://jira.pentaho.com/browse/CDF-72

  17. #17
    Join Date
    Oct 2009
    Posts
    3

    Default

    Hi there,
    I'm facing the same problem. I think I got the main problem. I'll try to describe so we could find a solution for that.
    I think that the problem is in the 'pentaho-solutions/system/pentaho-cdf/js/CoreComponents.js', where is defined the 'OpenFlashChartComponent' javascript class. When you call the 'callPentahoAction' method, it gets the html fragment where is defined the function which feed the flash chart with json data.
    When jQuery try to render the html fragment ('' $('#'+myself.htmlObject).html(result); ''), IE strips out the '<script>' tags, so when the flash object wants to call that function ('getData02491blahblah()'), it can't find it. The ERROR_0002 is because the swf seems to search for a default file in the 'data-file' directory.

    The solution is to find a workaround to avoid the 'strips out script tag in IE' stuff via jQuery.

    I'm trying harder to find the solution. If someone could find, please post it...
    I hope it helps you...

    regards,
    Leo

  18. #18
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    Very useful information, Leo.


    I added that comment to the bug. If anyone knows the answer, fell free to chime in.
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  19. #19
    Join Date
    Nov 2009
    Posts
    28

    Default

    Hi!
    Found this http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx describing the problem with inserting script tags in IE8.
    After a lot of trial-and-error I finally got the chart working for me in IE by adding this code to the file “CoreComponents”.
    Unfortunately it's a IE specific solution.
    ...
    getDataFuntion = result.match(/getData.*\(\)/gi);

    // Only for IE, http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
    if (navigator.appName == 'Microsoft Internet Explorer') {
    //Split Script and Object
    var newResult = result.split("}</script>");

    //Add scoped element
    var resultJS = "<input type=\"hidden\"/>" + newResult[0] + "}";

    // Add DEFER attribute
    var resultJS = resultJS.replace("<script>", "<script defer>");

    //Create new string for IE
    var resCombined = resultJS + "</" + "script>" + newResult[1];

    // For some reason OpenFlashChartComponent gets called twice. So this makes sure we don't write to div twice
    var isAlreadySet=eval(myself.htmlObject).innerHTML
    if(isAlreadySet=="") {
    eval(myself.htmlObject).innerHTML=resCombined;
    }
    }
    // Original code that works in FF
    else {
    $("#"+myself.htmlObject).html(result);
    }
    ...

    By the way, does anybody know how to best override the local setting to ensure that dot is used instead of comma when using this chart? I had to round the values in the xaction-file to get the example to work.


    Regards,
    Andreas

  20. #20
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    All this is requiring a heavy refactoring, and I hope to do that soon
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  21. #21
    Join Date
    Nov 2009
    Posts
    28

    Default

    Oups noticed that the below script didn't work i DD since the divs created with the templates are not blank.
    But the below works both for stand-alone and DD.

    ...
    var isAlreadySet=eval(myself.htmlObject).innerHTML.indexOf("embed")
    if(isAlreadySet==-1) {
    ...

    /Andreas

  22. #22
    Join Date
    Oct 2009
    Posts
    3

    Default

    Hi Andreas, good job!
    By the way, does anybody know how to best override the local setting to ensure that dot is used instead of comma when using this chart? I had to round the values in the xaction-file to get the example to work.
    What I did with the comma stuff, was to modify the 'Converter.java" file of the ofcj.
    I checked out the source from: 'http://ofcj.googlecode.com/svn/trunk'
    Then modified 'src/main/java/ofc4j/util/ConverterBase.java' to always format the number with US locale -dot- (as I'm from Argentina, the decimal separator in my locale is a comma).
    Here is the patch:

    Index: src/main/java/ofc4j/util/ConverterBase.java
    ===================================================================
    --- src/main/java/ofc4j/util/ConverterBase.java (revision 121)
    +++ src/main/java/ofc4j/util/ConverterBase.java (working copy)
    @@ -15,6 +15,7 @@
    */

    package ofc4j.util;
    +import java.util.Locale;

    import com.thoughtworks.xstream.converters.Converter;
    import com.thoughtworks.xstream.converters.MarshallingContext;
    @@ -27,7 +28,7 @@
    static java.text.NumberFormat nf;
    static
    {
    - nf = java.text.NumberFormat.getNumberInstance ();
    + nf = java.text.NumberFormat.getNumberInstance(Locale.US);
    nf.setGroupingUsed(false);
    }


    I hope it helps you,
    regards.

    Leo

  23. #23
    Join Date
    Nov 2009
    Posts
    28

    Default

    Thanks! I'll try it out.
    Wouldn't it be better if this was always set to "Local.US" to avoid problems with local settings and commas for OFC? Or might there be some other drawback here?
    /Andreas

  24. #24
    Join Date
    Jan 2008
    Posts
    177

    Default

    PERFECT!!!!!!
    Great works.

  25. #25

    Default

    Hi,
    I try use Open Flash Chart with CDF. It's don't work with IE (but work with FF)
    I have modify CoreComponent.js:
    I Add line:

    getDataFuntion = result.match(/getData.*\(\)/gi);

    // Only for IE, http://msdn.microsoft.com/en-us/libr...97(VS.85).aspx (http://msdn.microsoft.com/en-us/libr...97(VS.85).aspx)
    if (navigator.appName == 'Microsoft Internet Explorer') {
    //Split Script and Object
    var newResult = result.split("}</script>");

    //Add scoped element
    var resultJS = "<input type=\"hidden\"/>" + newResult[0] + "}";

    // Add DEFER attribute
    var resultJS = resultJS.replace("<script>", "<script defer>");

    //Create new string for IE
    var resCombined = resultJS + "</" + "script>" + newResult[1];

    // For some reason OpenFlashChartComponent gets called twice. So this makes sure we don't write to div twice
    var isAlreadySet=eval(myself.htmlObject).innerHTML.indexOf("embed")
    if(isAlreadySet==-1) {
    eval(myself.htmlObject).innerHTML=resCombined;
    }
    }
    // Original code that works in FF
    else {
    $("#"+myself.htmlObject).html(result);
    }
    }
    Dashboards.decrementRunningCalls();.

    But i have always JSON error with IE8 .
    An idea?

    Do i have an error in CoreComponent.js?
    (Sorry for my bad english)
    Attached Images Attached Images  
    Attached Files Attached Files

  26. #26

  27. #27
    Join Date
    Jan 2008
    Posts
    177

    Default

    uhm....strange because if you put an xaction component that call OFC class inside template.html you'll obtain this one:
    Attached Images Attached Images  

  28. #28
    Join Date
    Jan 2008
    Posts
    177

    Default

    And another: if i use a openflashcomponent (not by xaction but directly via cdf component) into my dashboard it doesnt refresh when a listener parameter change...

  29. #29
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    Is this for IE only or FF too?
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  30. #30
    Join Date
    Jan 2008
    Posts
    177

    Default

    Hi pedro!
    Only with ie () and it's all right with ff.
    I use firefox but my best customer (a big company of post service...) has only ie (7 or 8 with downgrade compatibility).
    Last edited by Marco Mantini; 04-16-2010 at 06:44 PM.

  31. #31
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    well, that part (affected by listeners) is fixed
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  32. #32
    Join Date
    Jan 2008
    Posts
    177

    Default

    GREAT!!
    Into CoreComponent?

  33. #33
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    Yes. Remove the part where it checks if the component is already there.
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  34. #34
    Join Date
    Jan 2008
    Posts
    177

    Default

    Variable isAlreadySet?

  35. #35
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    yep
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  36. #36
    Join Date
    Jan 2008
    Posts
    177

    Default

    Hi to all

    for a newbee user:

    Original code:
    var OpenFlashChartComponent = JFreeChartComponent.extend({

    callPentahoAction: function() {

    Dashboards.incrementRunningCalls();

    var myself = this;

    Dashboards.callPentahoAction(myself,"cdf", "components", "openflashchart.xaction", this.getParameters(),function(jXML){

    if(jXML != null){
    var result = jXML.find("ExecuteActivityResponse:first-child").text().replace(/openflashchart/g,webAppPath + "/openflashchart");
    getDataFuntion = result.match(/getData.*\(\)/gi);

    // IE will strip out script tags without this block of code (CDF-72)
    // Make sure we only apply this to Flash chart rendering...
    if (document.all) { // check for IE
    var needIEFix=((result.indexOf("embed")!=-1) &&
    (result.indexOf("object")!=-1) &&
    (result.indexOf("script")!=-1));
    if (needIEFix){
    //Split Script and Object
    var newResult = result.split("}</script>");

    //Add scoped element "<br>" - this fix will not work without a prefixed
    // scoped element - see CDF-72
    var resultJS = "<br>" + newResult[0] + "}";

    // Add DEFER attribute
    resultJS = resultJS.replace("<script", "<script defer");

    //Create new string for IE
    var resCombined = resultJS + "<" + "/script>" + newResult[1];

    // Currently, CDF does not use Chartbeans, so this part of the fix is not necessary here.

    // create unique javascript function names (all Flash chart functions for
    // Chartbeans are getChartData ... this causes big issues when you have more
    // than one Chartbeans chart
    // var randomnumber=Math.floor(Math.random()*111111);
    // resCombined = resCombined.replace(/getChartData/g, "getChartData" + randomnumber);

    // For some reason this gets called twice. So this makes sure we don't write to div twice
    var isAlreadySet=eval(myself.htmlObject).innerHTML.indexOf("embed");
    if(isAlreadySet==-1) {
    eval(myself.htmlObject).innerHTML=resCombined;
    }
    }else { // all other components...
    $("#"+myself.htmlObject).html(result);
    }
    }
    else { // all other browsers...
    $("#"+myself.htmlObject).html(result);
    }
    }
    Dashboards.decrementRunningCalls();

    });

    OpenFlashChartComponent.prototype.onClick = function(value) {
    if(getDataFuntion != null && myself.chartDefinition.urlTemplate != undefined && myself.chartDefinition.parameterName != undefined){
    myself.data = myself.data != undefined ? myself.data : eval('(' + eval(getDataFuntion[0]) + ')');
    if(myself.data.x_axis != undefined){
    var urlTemplate = myself.chartDefinition.urlTemplate.replace("{" + myself.chartDefinition.parameterName + "}",myself.data.x_axis.labels.labels[value]);
    eval(urlTemplate);
    }

    }
    };

    }

    });
    Fixed Code:
    var OpenFlashChartComponent = JFreeChartComponent.extend({

    callPentahoAction: function() {

    Dashboards.incrementRunningCalls();

    var myself = this;

    Dashboards.callPentahoAction(myself,"cdf", "components", "openflashchart.xaction", this.getParameters(),function(jXML){

    if(jXML != null){
    var result = jXML.find("ExecuteActivityResponse:first-child").text().replace(/openflashchart/g,webAppPath + "/openflashchart");
    getDataFuntion = result.match(/getData.*\(\)/gi);

    // IE will strip out script tags without this block of code (CDF-72)
    // Make sure we only apply this to Flash chart rendering...
    if (document.all) { // check for IE
    var needIEFix=((result.indexOf("embed")!=-1) &&
    (result.indexOf("object")!=-1) &&
    (result.indexOf("script")!=-1));
    if (needIEFix){
    //Split Script and Object
    var newResult = result.split("}</script>");

    //Add scoped element "<br>" - this fix will not work without a prefixed
    // scoped element - see CDF-72
    var resultJS = "<br>" + newResult[0] + "}";

    // Add DEFER attribute
    resultJS = resultJS.replace("<script", "<script defer");

    //Create new string for IE
    var resCombined = resultJS + "<" + "/script>" + newResult[1];

    // Currently, CDF does not use Chartbeans, so this part of the fix is not necessary here.

    // create unique javascript function names (all Flash chart functions for
    // Chartbeans are getChartData ... this causes big issues when you have more
    // than one Chartbeans chart
    // var randomnumber=Math.floor(Math.random()*111111);
    // resCombined = resCombined.replace(/getChartData/g, "getChartData" + randomnumber);

    // Final pedro's fix for IE (CDF-72)
    eval(myself.htmlObject).innerHTML=resCombined;

    }else { // all other components...
    $("#"+myself.htmlObject).html(result);
    }
    }
    else { // all other browsers...
    $("#"+myself.htmlObject).html(result);
    }
    }
    Dashboards.decrementRunningCalls();

    });

    OpenFlashChartComponent.prototype.onClick = function(value) {
    if(getDataFuntion != null && myself.chartDefinition.urlTemplate != undefined && myself.chartDefinition.parameterName != undefined){
    myself.data = myself.data != undefined ? myself.data : eval('(' + eval(getDataFuntion[0]) + ')');
    if(myself.data.x_axis != undefined){
    var urlTemplate = myself.chartDefinition.urlTemplate.replace("{" + myself.chartDefinition.parameterName + "}",myself.data.x_axis.labels.labels[value]);
    eval(urlTemplate);
    }

    }
    };

    }

    });
    Now (thanks to Pedro Alves, Gretchen Moran and other community user's) open flash chart works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.