This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 2, 2011, 4:13 AM
29 Posts
topic has been resolvedResolved

Simple Xpages chart

  • Category: Other
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: Chart
  • Replies: 3
Hi,
 
I'm trying make a little chart. The following xpage gives me what I want. I can't however get my own series into it..
 
As soon as I do something like var myview=database.getView("something") my graph disappears. How can I pass my own array to the result. P.S. A newbie so go easy.
 
I've found a few examples but way way way too hard for me to understand. I'm guessing there is an easy way..
 
Any help will be really appreciated as I've searched all over with no joy.
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom" dojoParseOnLoad="true"
dojoTheme="true" styleClass="tundra">

<xp:this.resources>
<xp:dojoModule name="dojox.charting.widget.Chart2D"></xp:dojoModule>
<xp:styleSheet href="/custom.css"></xp:styleSheet>
</xp:this.resources>
<div id="simplechart" style="width: 175px; height: 125px;">
</div>
    
    <xp:scriptBlock id="scriptBlock1">
    <xp:this.value>
    <![CDATA[ var chart1 = new dojox.charting.Chart2D("simplechart");


    var result = new Array();

result.push(34);
result.push(18);
result.push(34);
result.push(32);
chart1.addPlot("default", {type: "Columns", gap:2});
chart1.addAxis("x");
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1", result,{stroke: {color: "#C0ffC0", width: 1}, fill: "c0c0c0" } );
chart1.render();
]]></xp:this.value>
    </xp:scriptBlock>
</xp:view>
 
 
Sep 2, 2011, 11:31 AM
53 Posts
Re: Simple Xpages chart
Probably best to post the broken code. The possible answer is that database.getView is SSJS so you need to ensure it's integrated properly into your CSJS. But without posting the problem code there's no way to tell really
Sep 5, 2011, 12:59 PM
122 Posts
Re: Simple Xpages chart
Have you looked at the articles I added on the wiki? The first one is going to be most relevant for this http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Dojox_Charting_for_XPages There are links I believe to the download applications, if not check out my blog http://hermes.intec.co.uk/intec/blog.nsf, and the links on the left to tutorials.
 
You'll need to significantly change the code you're using. You can't use database.getView in your script block - the script block is Client-Side JavaScript, database is only available in Server-Side JavaScript. That's why I tend to use a Computed Field to effectively write pass-thru HTML onto the XPage.
 
If you're using IE you'll also need to force compatibility mode. Again, the code for that is in the article.
Sep 6, 2011, 11:43 PM
29 Posts
Re: Simple Xpages chart
Hi Paul,
 
I manged to get it working by using your example as a basis, thanks a lot. I made the following computed field and it works a treat now.
 
I have to say the charting feature is an awesome thing, long needed..
 
var result ="<script language=\JavaScript\" type=\"text/javascript\">";
result +="var series=new Array();"
exerciseview=database.getView("weightAscending");
exerciseview.refresh();
doc=tabledata.getDocument();
athleteName=doc.getItemValueString("athlete");
var vec:NotesViewEntryCollection=exerciseview.getAllEntriesByKey(athleteName);
var entry:NotesViewEntry = vec.getFirstEntry();

while (entry != null) {

doc=entry.getDocument()
weightvalue=doc.getItemValueDouble("weight");
    result +="series.push(" + weightvalue + ");"

    var tmpentry:NotesViewEntry = vec.getNextEntry(entry);

    entry.recycle();

    entry = tmpentry;

}

result +="</script>";
return result

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal