<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Feelinc.Me &#187; Lotus Domino</title>
	<atom:link href="http://www.feelinc.me/category/lotus-domino/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.feelinc.me</link>
	<description>It&#039;s All About Me</description>
	<lastBuildDate>Tue, 24 Aug 2010 21:46:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Lotus Domino – Dojo Pie Chart Legend Color Hack Tips On Zero Value</title>
		<link>http://www.feelinc.me/lotus-domino/dojo-pie-chart-legend-color-hack-tips-on-zero-value/</link>
		<comments>http://www.feelinc.me/lotus-domino/dojo-pie-chart-legend-color-hack-tips-on-zero-value/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 15:55:35 +0000</pubDate>
		<dc:creator>Feelinc</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Lotus Domino]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[chart]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[domino]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[lotus]]></category>
		<category><![CDATA[pie]]></category>

		<guid isPermaLink="false">http://www.feelinc.me/?p=176</guid>
		<description><![CDATA[Dojo Toolkit is a best free JavaScript library currently exist, which had a lot of ready to use widget for web application UI. One of the widget that we can use is the Dojo Chart Widget. This is quite a common issue when we are using the Dojo Pie Chart Widget with Legend and if [...]]]></description>
			<content:encoded><![CDATA[<p>Dojo Toolkit is a best free JavaScript library currently exist, which had a lot of ready to use widget for web application UI. One of the widget that we can use is the Dojo Chart Widget.</p>
<p>This is quite a common issue when we are using the Dojo Pie Chart Widget with Legend and if some of our data are had zero values then the color at the pie slice is different with the needed legend. In here i came up with a simple solution using XHTML JavaScript manipulation to show the right legends color.</p>
<p>Now we start from the beginning of implementing the Dojo Pie Chart.<span id="more-176"></span></p>
<p>Before we go through to the code implementation, we should think about the JSON data format. What do i know is we have to create this below JSON format for Dojo Pie Chart:</p>
<pre class="brush: plain;">
[
{text:&quot;Lhokga Plant (BU)&quot;,stroke:&quot;black&quot;,color:&quot;#5D8AA8&quot;,y:7},
{text:&quot;Lhoknga Project&quot;,stroke:&quot;black&quot;,color:&quot;#F0F8FF&quot;,y:3},
{text:&quot;Lhoknga Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#E32636&quot;,y:0},
{text:&quot;Belawan Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#E52B50&quot;,y:2},
{text:&quot;Dumai Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#CD2682&quot;,y:0},
{text:&quot;Lhokseumawe Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#9F2B68&quot;,y:0},
{text:&quot;Batam Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#ED3CCA&quot;,y:0}
]
</pre>
<p>Let me explain a little bit about the above format.</p>
<p>&#8220;text&#8221; =&gt; is the label for pie slice<br />
&#8220;stroke&#8221; =&gt; is the pie slice stroke color<br />
&#8220;color&#8221; =&gt; is the pie slice color<br />
&#8220;y&#8221; =&gt; is the pie slice data number</p>
<p>Then we have to prepare an LotusScript Agent to create an JSON data output, let&#8217;s create a simple one.</p>
<pre class="brush: plain;">
Sub Initialize
  Print |Content-Type: text/plain|
  Print |[|
  Print |{text:&quot;Lhokga Plant  (BU)&quot;,stroke:&quot;black&quot;,color:&quot;#5D8AA8&quot;,y:7},|
  Print |{text:&quot;Lhoknga  Project&quot;,stroke:&quot;black&quot;,color:&quot;#F0F8FF&quot;,y:3},|
  Print |{text:&quot;Lhoknga  Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#E32636&quot;,y:0},|
  Print |{text:&quot;Belawan  Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#E52B50&quot;,y:2},|
  Print |{text:&quot;Dumai  Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#CD2682&quot;,y:0},|
  Print |{text:&quot;Lhokseumawe  Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#9F2B68&quot;,y:0},|
  Print |{text:&quot;Batam  Terminal&quot;,stroke:&quot;black&quot;,color:&quot;#ED3CCA&quot;,y:0}|
  Print |]|
End Sub
</pre>
<p>Then you have to place needed HTML code container on your HTML page</p>
<pre class="brush: plain;">
&lt;div id=&quot;chart_data&quot; style=&quot;width: 800px; height: 200px;&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;legend_list right&quot;&gt;
    &lt;div class=&quot;legend_example&quot;&gt;
      &lt;div class=&quot;left&quot;&gt;&amp;nbsp;&lt;/div&gt;
      &lt;label class=&quot;legend_text left&quot;&gt;&lt;/label&gt;
      &lt;div style=&quot;clear:both;&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Then we put the JavaScript code</p>
<pre class="brush: plain;">
dojo.addOnLoad(function() {
  dojo.addClass(dojo.body(), &quot;soria&quot;);

  dojo.xhrPost({
    url:  &quot;http://domain.com/database.nsf/dataAgent?OpenAgent&amp;ur=&quot; + new Date().getMilliseconds(),
    handleAs: &quot;json&quot;,
    error: function(response, ioArgs){
      if (ioArgs.xhr.status != 200) {
        console.error(&quot;HTTP status code: &quot;, ioArgs.xhr.status);
      }
    },
    load: function(response, ioArgs){
      if (response.length &gt; 0) {
        dojo.require(&quot;dojox.charting.plot2d.Pie&quot;);
        dojo.require(&quot;dojox.charting.themes.MiamiNice&quot;);

        var chart = new dojox.charting.Chart2D(&quot;chart_data&quot;);
        chart.setTheme(dojox.charting.themes.MiamiNice).addPlot(&quot;default&quot;, {
          type: &quot;Pie&quot;,
          radius: 150,
          precision: 0
        }).addSeries(&quot;Series A&quot;, response);
        chart.render();

        var i_item = 0;
        var item = {};
        for(i_item in response) {
          item = dojo.clone(dojo.query(&quot;.legend_example&quot;));
          item.removeClass(&quot;legend_example&quot;);
          item.addClass(&quot;legend&quot;);
          item.removeClass(&quot;hidden&quot;);
          item.query(&quot;div.left&quot;).style({backgroundColor: response[i_item].color});
          item.query(&quot;.legend_text&quot;).addContent(response[i_item].text + &quot; &lt;strong&gt;(&quot; + response[i_item].y + &quot;)&lt;/strong&gt;&quot;);
          dojo.place(item[0], dojo.byId(&quot;legend_list&quot;), &quot;last&quot;);
        }

        delete i_item;
        delete item;
        delete chart;
      }
    }
  });
});
</pre>
<p>Hope this tips will be very helpfull for Lotus Domino Developer who want to integrate the Dojo Toolkit especially for the Pie Chart.</p>
<p><span style="color: #ff0000;">*Before running any of those above code, please replace all the double quote with your own.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.feelinc.me/lotus-domino/dojo-pie-chart-legend-color-hack-tips-on-zero-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
