• Content count

  • Joined

  • Last visited

About pca

  • Rank
    Junior Member
  1. Encoding problem

    Hello. Although I still can't say what, exactly, was wrong with my previous code, I was able to solve it by implementing a similar solution. First I wrote my code to load the chart on the onSuccess method of the Ajax request. This way I could easily get rid of errors caused by the request being asynchronous. This didn't solve my problem. In fact it made it worst because before the chart did load sometimes and like this it didn't load at all, returning an error in the XML. I made an output of the XML and stored it in a file to use it with xmllint to check for errors. It didn't find any. I then used that same XML file with a chart on one of the Evaluation pages and it worked. Moving back to the application, I used the javascript escape function on the XML before sending it to the chart, and it worked but text with accented characters was all gibberish. Long story short, after playing a little with static strings containing a sample XML I found what was causing the XML error. It was the quote marks ("). I replaced them with apostrophes ('), and while I was at it, I also URL encoded the characters & and % that might appear in the XML. I can now build the charts correctly, with the right characters and without errors (so far...). It still eludes me why in the previous setting the chart load only on some occasions and mostly after trying several times to load a chart. The XML sent to the chart was the same, but sometimes it would return an error. I send the working code in attachment. Hope it helps someone Thank you all for your help workingCode.txt
  2. Encoding problem

    Hi Your solution did help in eliminating the errors. But I'm still left with the question of why some times the chart loads, and others it doesn't. After some debugging I found that whatever it is, it happens during the instruction: chartObj.setDataXML(transport.responseText); Since the request is asynchronous could the cause be the application is trying to supply the chart with XML when the chart isn't fully loaded? Thank you for your help so far
  3. Encoding problem

    Hi I decided to change my strategy, and instead of using setDataURL, I now use setDataXML and the encoding problem appears to be solved. I create the chart without giving it any XML and then use an Ajax request to obtain the XML and send it to the chart using setDataXML. However, I ended up trading one problem for another. For some unexplained reason the chart sometimes does not load the XML or it returns a error in the XML when there is none. My current code is in the attachment. chartCode.txt
  4. Encoding problem

    Hello and thank you again for your help This didn't work. I've tried it with multiple files and the result was the same. With the static file it worked. Using the xslt code it still doesn't work. In attachment I send the html for the chart and a screenshot of a chart with the wrong characters. htmlcode.txt
  5. Encoding problem

    Your understanding of the application is correct, and thank you for your suggestion, but unfortunately I have already tried it and the result was the same. I tried using it on the file you suggested, and on every file that helps to create the xml for the charts at the same time. I also tried passing the xml through another xsl with the sole purpose of converting to utf-8 and it still didn't work. I have also tried to convert the strings to utf-8 using javascript, with and without . I may be doing something wrong, but I still haven't discovered what it is.
  6. Encoding problem

    I'm using setDataURL. The link used leads to the sitemap pattern get-chart-xml that was on the attachment in my previous post. buildFusionChart = function(id, chartXML, isPie, multiAxis, width, heigth, CHARTS_PATH, renderDivId) { var registerWithJS = "1", c = null, scaleMode = null, lang = null, detectFlashVersion = null, autoInstallRedirect = null ; var debug = "0" ; var swfUrl = "" ; if (isPie == "1") { swfUrl = CHARTS_PATH + "charts/Pie3D.swf" ; } else { if (multiAxis == "1") { swfUrl = CHARTS_PATH + "charts/MSCombiDY2D.swf" ; } else { swfUrl = CHARTS_PATH + "charts/MSCombi2D.swf" ; } } var chart = new FusionCharts(swfUrl, id, width, heigth, debug, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect) ; chart.addParam("WMode", "Transparent"); chart.setDataURL(CHARTS_PATH + escape(chartXML)); chart.render(renderDivId); } Thank you for your assistance
  7. Encoding problem

    I'm using the Apache Cocoon Framework, on a Tomcat server. As for the sample code I sent it as an attachment. If you need more, please let me know. codesample.txt
  8. Encoding problem

    Hi everyone I'm having a problem with some characters. I've searched and I know that I have to add the BOM bytes for UTF-8 encoding. However, I've searched the forum and then googled and I can't seem to find a solution for my problem. I am using xslt to dynamically create my xml file and I would like to know how can I add the BOM to the XML file. Thanks in advance
  9. Saving and mailing charts

    So my choices are to reload the chart on the client side, or load it on the server side. Is there no setImageSaveURL? It would be immensely helpful. I can now send an email with the chart as an attachment, but I'm left with another problem. After I send the email, it moves to a blank page. If I redirect to the previous pages it loses the components that were on it. How can I stay on the same page? Like what happens when it sends back the image file to the client side. Anyway, here is what I have so far. For now there are no settings defined by parameters. Hope it helps someone <%@ page import="java.io.OutputStream"%> <%@ page import="java.io.PrintWriter"%> <%@ page import="java.io.File"%> <%@ page import="java.awt.Color"%> <%@ page import="java.awt.Graphics"%> <%@ page import="java.awt.image.BufferedImage"%> <%@ page import="javax.imageio.ImageIO"%> <%@ page import="java.util.Properties"%> <%@ page import="javax.mail.*"%> <%@ page import="javax.mail.internet.*"%> <%@ page import="javax.activation.*"%> <% //Decoded data from charts. String data=""; //Rows of color values. String[] rows; //Width and height of chart. int width=0; int height=0; //Default background color of the chart String bgcolor=""; Color bgColor; (..... rest of the script given by FusioCharts .....) for (int k=1; k<=r; k++){ //Draw each pixel gr.setColor(new Color(Integer.parseInt(c,16))); gr.fillRect(ri, i,1,1); //Increment horizontal row count ri++; } }else{ //Just increment horizontal index ri = ri + r; } } } // No need to send the image file as a response so you can comment it, if you like String filename = "FusionChart" + System.currentTimeMillis() + ".jpg" ; File outfile = new File(filename) ; ImageIO.write(chart, "jpeg", outfile); String from="your@mail"; String to="yourdestination@mail"; String host="you.mail.smtp.server"; // String port="111"; // define if needed // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", host); // props.put("mail.smtp.port", port); // define if needed // props.put("mail.smtp.auth", "true"); // define if needed // Get session Session s = Session.getInstance(props, null); // Define message MimeMessage message = new MimeMessage(s); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("A sugestive subject here"); MimeBodyPart messageBodyPart = new MimeBodyPart(); //fill message messageBodyPart.setText("any text you want to send"); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(outfile); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send the message Transport transport = s.getTransport("smtp"); transport.connect(host, "your username here","your password here"); transport.send( message,message.getAllRecipients() ); transport.close() ; %>
  10. Saving and mailing charts

    One of the parameters I had in mind was the destination mail. By passing them to the jsp file that way I would need to redraw the chart everytime I wanted to send a mail to a different destination, right? Is there a way around that?
  11. Hi everyone In the FAQ section you mention that it is possible to mail the charts. How? Due to the security problems mentioned there I'm trying to mail the chart after saving it as a file in the server by modifying the FusionChartsSave.jsp. The problem is that I want to have the options of saving the chart as an image, and mail it too. But if I change the FusionChartsSave.jsp file I can only do one of them. Which brings me to my question. Is is possible to send a parameter to the FusionChartsSave.jsp file or even to change the imageSaveURL according to the intended action? Thanks in advance
  12. Hi First of all a correction. In my first post where it says should be: xmlStr += " link=& quot;JavaScript:jsMethod('" + parameter + "')& quot;" ; I can see now why it would return 'Invalid XML data'. But I still can't understand why it wouldn't return that error on all ocasions.
  13. It worked Thank you very much. But any idea on the reason of the problem?
  14. Hello everyone, I'm using Java to create the XML data required for the Fusion Charts. I create a string containing the xml code and then pass it to the Chart with setDataXML. The chart will load with data obtained from a DB and that data may change if a new timeline is selected. I'm trying to create a pie chart with a link to a javascript function. Here is where things get tricky. If I do: xmlStr += " link="JavaScript:jsMethod('" + parameter + "')"" ; the chart loads correctly at first, but if I try to get a different set of data it will return 'Invalid XML data' If I try: xmlStr += " link="JavaScript:jsMethod('" + parameter + "')"" ; the page loads with 'Invalid XML data' but it works fine when selecting a different set of data. The same happens if I try: xmlStr += " link='JavaScript:jsMethod(& apos;" + parameter + "& apos; )'" ; (In my code the & apos; is together) Any idea of what is wrong? Does the setDataXML method do something different the first time it is called from following calls? Thanks in advance
  15. Reload / reInit / remove a chart??

    In the same function you use to update chart C can't you update the other charts?