<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr"><div class="gmail_quote"><br><div dir="ltr"><div>
              <div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_creating-the-multiple-chart-editor-panel"></a></h3><div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_listing-the-registered-chart-services"></a></h3><h3>Hi,</h3><p>documentation is not available at this moment because we are migrating old plone Web. <br></p><p>Above
 this lines, I describe the most useful recipes about chart methods. To 
insert data in the charts take a look to the ChartDataSet class.<br></p><p>Chart
 persistence is controlled by gvSIG and all the charts created will be 
saved in the same way as the other documents (views, maps, tables,...)<br></p><p><br></p><h3><a name="150cd0df94970f73_150cd0a5d93cf247_listing-the-registered-chart-services">- Listing the registered chart services</a></h3>
<p>The different chart types availables on this extension are defined and registered in the org.gvsig.chart.base package.</p>
<p>If it&#39;s useful to know which ones are registered on the application, 
it&#39;s possible to obtain a list of them using this procedure:</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Getting the manager dedicated to adminiter the extension chart services */</span>
ChartServiceManager serviceManager <span style="color:rgb(102,102,102)">=</span> ChartLocator<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getServiceManager</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Obtaining the list with the registered services */</span>
List<span style="color:rgb(102,102,102)">&lt;</span>ChartService<span style="color:rgb(102,102,102)">&gt;</span> registeredServices <span style="color:rgb(102,102,102)">=</span> serviceManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getChartServices</span><span style="color:rgb(102,102,102)">();</span>
</pre></div>
</div></div>
<div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_creating-a-single-chart-of-a-registered-service">- Creating a single chart of a registered service</a></h3>
<p>Using the service manager, it&#39;s possible to create a chart of a specific type (always if it&#39;s in the registered previously)</p>
<p>To generate it, first of all is needed to create its properties, to 
configure it. After that, the associated service will be generated (the 
chart in this case) according to the properties type.</p>
<p>There&#39;s an example about a Pie chart initialization with the default parameters:</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Getting the manager dedicated to adminiter the extension chart services  */</span>
ChartServiceManager serviceManager <span style="color:rgb(102,102,102)">=</span> ChartLocator<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getServiceManager</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Creating a properties of a Pie chart type */</span>
ChartProperties chartProperties <span style="color:rgb(102,102,102)">=</span>    serviceManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getChartManager</span><span style="color:rgb(102,102,102)">().</span><span style="color:rgb(125,144,41)">createProperties</span><span style="color:rgb(102,102,102)">(</span>PieChart<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">class</span><span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getSimpleName</span><span style="color:rgb(102,102,102)">());</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Here it&#39;s possible to modify/edit the default values, before creating the service */</span>
chartProperties<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">setChartTitle</span><span style="color:rgb(102,102,102)">(</span><span style="color:rgb(186,33,33)">&quot;Población&quot;</span><span style="color:rgb(102,102,102)">);</span>
chartProperties<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">setChartDescription</span><span style="color:rgb(102,102,102)">(</span><span style="color:rgb(186,33,33)">&quot;Gráfico de tartas de los habitantes de cada población de la Comunidad Valenciana&quot;</span><span style="color:rgb(102,102,102)">);</span>
<span style="color:rgb(64,128,128);font-style:italic">// …</span>

<span style="color:rgb(64,128,128);font-style:italic">/* And finally, creating the service */</span>
ChartService grafico <span style="color:rgb(102,102,102)">=</span> serviceManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getChartManager</span><span style="color:rgb(102,102,102)">().</span><span style="color:rgb(125,144,41)">createChart</span><span style="color:rgb(102,102,102)">(</span>chartProperties<span style="color:rgb(102,102,102)">)</span>
</pre></div>
</div></div>
<div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_creating-a-multiple-chart">- Creating a multiple chart.</a></h3>
<p>The multiple chart (OverlyaChart) let us to overlay and to establish 
relationships between several simple charts. Each simple chart can 
represent a data variable such as temerature, population, area, etc.</p>
<p>Assuming that variables <i>grafico1</i> and <i>grafico2</i> are generated by the previous process especified lines above, the procedure to create a multiple chart will be teh following:</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Getting the manager dedicated to adminiter the extension chart services */</span>
ChartServiceManager serviceManager <span style="color:rgb(102,102,102)">=</span> ChartLocator<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getServiceManager</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Creating a multiple chart */</span>
ChartService grafico_compuesto <span style="color:rgb(102,102,102)">=</span> serviceManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getChartManager</span><span style="color:rgb(102,102,102)">().</span><span style="color:rgb(125,144,41)">createGroupedCharts</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Adding the simple charts to the multiple */</span>
grafico_compuesto<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">addChartService</span><span style="color:rgb(102,102,102)">(</span>grafico1<span style="color:rgb(102,102,102)">);</span>
grafico_compuesto<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">addChartService</span><span style="color:rgb(102,102,102)">(</span>grafico2<span style="color:rgb(102,102,102)">);</span>
</pre></div>
</div></div>
<div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_drawing-a-chart">- Drawing a chart</a></h3>
<p>When the service is prepared (it doesn&#39;t matter if it&#39;s simple or multiple), the following step will be draw it over a panel.</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Panel where the graph will be drawn */</span>
Jpanel panel <span style="color:rgb(102,102,102)">=</span> <span style="color:rgb(0,128,0);font-weight:bold">new</span> Jpanel<span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* The &#39;grafico&#39; variable has the specific service. If it&#39;s a multiple chart, it will paint each one over the others */</span>
grafico<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">draw</span><span style="color:rgb(102,102,102)">(</span>panel<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getGraphics</span><span style="color:rgb(102,102,102)">(),</span> panel<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getBounds</span><span style="color:rgb(102,102,102)">());</span>
</pre></div>
<br></div></div><h3><a name="150cd0df94970f73_150cd0a5d93cf247_creating-the-multiple-chart-editor-panel">- Creating the multiple chart editor panel</a></h3>
<p>Multiple chart is composed by one or more variables. Each one is a 
chart that represents a data set. It lets to overlay several charts to 
establish erlationships between them or to represent a more complete 
information in the chart. The Swing part of the extension provides a 
panel that allows to manipulate and manage this multiple chart using a 
graphical interface.</p>
<p>Assuming that <i>grafico_compuesto</i> is a multiple chart created and initializated, the proceduer will be the following:</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Panel where the multiple chart form will be placed */</span>
Jpanel panel <span style="color:rgb(102,102,102)">=</span> <span style="color:rgb(0,128,0);font-weight:bold">new</span> Jpanel<span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Obtaining the SWING manager of the extension */</span>
ChartSwingManager chartSwingManager <span style="color:rgb(102,102,102)">=</span> ChartSwingLocator<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getSwingManager</span><span style="color:rgb(102,102,102)">().</span><span style="color:rgb(125,144,41)">getChartSwingManager</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Creating the form and associating it to the grafico_compuesto variable previously created */</span>
EditorGroupedChartPanel editorPanel <span style="color:rgb(102,102,102)">=</span> chartSwingManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">createEditorChartPanel</span><span style="color:rgb(102,102,102)">(</span>grafico_compuesto<span style="color:rgb(102,102,102)">);</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Adding the editor to the panel */</span>
panel<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">add</span><span style="color:rgb(102,102,102)">(</span>editorPanel<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getComponent</span><span style="color:rgb(102,102,102)">());</span>
</pre></div>
</div></div>
<div>
<h3><a name="150cd0df94970f73_150cd0a5d93cf247_wizard-to-create-or-edit-a-chart-service">- Wizard to create or edit a chart service</a></h3>
<p>The Swing part of this extension also provides a way to edit and assign the chart properties using a graphical interface.</p>
<div><div style="background:rgb(248,248,248) none repeat scroll 0% 0%"><pre style="line-height:125%"><span style="color:rgb(64,128,128);font-style:italic">/* Obtaining the SWING manager of the extension */</span>
ChartSwingManager swingManager <span style="color:rgb(102,102,102)">=</span> ChartSwingLocator<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">getSwingManager</span><span style="color:rgb(102,102,102)">().</span><span style="color:rgb(125,144,41)">getChartSwingManager</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* Creating a new instance of the wizard to create a new service*/</span>
EditorChartServicePanel editorChartServicePanel <span style="color:rgb(102,102,102)">=</span> swingManager<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">createNewChartPanel</span><span style="color:rgb(102,102,102)">();</span>

<span style="color:rgb(64,128,128);font-style:italic">/* The form will be added to a special JDialog that returns the service created using the values indicated in the form (or null if there is an error) */</span>
ChartService service <span style="color:rgb(102,102,102)">=</span>  EditorChartServiceJDialog<span style="color:rgb(102,102,102)">.</span><span style="color:rgb(125,144,41)">showDialog</span><span style="color:rgb(102,102,102)">(</span>                                 
      <span style="color:rgb(186,33,33)">&quot;Add_new_variable&quot;</span><span style="color:rgb(102,102,102)">,</span> 
      editorChartServicePanel<span style="color:rgb(102,102,102)">);</span>
</pre></div>
</div></div>


          </div></div>
</div></div>
</div><br></div>