File: classScatterPlotExample.html

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (135 lines) | stat: -rw-r--r-- 15,368 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: ScatterPlotExample Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>ScatterPlotExample Class Reference<br>
<small>
[<a class="el" href="group__chartsexample.html">Charts example</a>]</small>
</h1><!-- doxytag: class="ScatterPlotExample" --><!-- doxytag: inherits="Wt::WContainerWidget" -->A Widget that demonstrates a scatter plot.  
<a href="#_details">More...</a>
<p>
<code>#include &lt;<a class="el" href="ChartsExample_8h-source.html">ChartsExample.h</a>&gt;</code>
<p>
<div class="dynheader">
Inheritance diagram for ScatterPlotExample:</div>
<div class="dynsection">
<p><center><img src="classScatterPlotExample__inherit__graph.png" border="0" usemap="#ScatterPlotExample__inherit__map" alt="Inheritance graph"></center>
<map name="ScatterPlotExample__inherit__map">
<area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html" title="Wt::WContainerWidget" alt="" coords="5,304,157,331"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WInteractWidget.html" title="Wt::WInteractWidget" alt="" coords="11,229,152,256"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html" title="Wt::WWebWidget" alt="" coords="20,155,143,181"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html" title="Wt::WWidget" alt="" coords="33,80,129,107"><area shape="rect" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="33,5,129,32"></map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div>

<p>
<a href="classScatterPlotExample-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classScatterPlotExample.html#75f30afe584a342437d901217fd232db">ScatterPlotExample</a> (<a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *<a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#3461e31818c4d2f516641bdaf508312a">parent</a>)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Creates the scatter plot example.  <a href="#75f30afe584a342437d901217fd232db"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A Widget that demonstrates a scatter plot. 
<p>Definition at line <a class="el" href="ChartsExample_8h-source.html#l00049">49</a> of file <a class="el" href="ChartsExample_8h-source.html">ChartsExample.h</a>.</p>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="75f30afe584a342437d901217fd232db"></a><!-- doxytag: member="ScatterPlotExample::ScatterPlotExample" ref="75f30afe584a342437d901217fd232db" args="(Wt::WContainerWidget *parent)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ScatterPlotExample::ScatterPlotExample           </td>
          <td>(</td>
          <td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *&nbsp;</td>
          <td class="paramname"> <em>parent</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Creates the scatter plot example. 
<p>

<p>Definition at line <a class="el" href="ChartsExample_8C-source.html#l00179">179</a> of file <a class="el" href="ChartsExample_8C-source.html">ChartsExample.C</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00179"></a>00179                                                               :
<a name="l00180"></a>00180   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html#520ba6e52a36a7f2efbef1a31a69e898">WContainerWidget</a>(parent)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182   <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a>(WString::tr(<span class="stringliteral">"scatter plot 2"</span>), <span class="keyword">this</span>);
<a name="l00183"></a>00183 
<a name="l00184"></a>00184   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html">WStandardItemModel</a> *model = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WStandardItemModel.html">WStandardItemModel</a>(40, 2, <span class="keyword">this</span>);
<a name="l00185"></a>00185   model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#57f5d417f933440db0d38ece7dd370f4">setHeaderData</a>(0, boost::any(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">WString</a>(<span class="stringliteral">"X"</span>)));
<a name="l00186"></a>00186   model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#57f5d417f933440db0d38ece7dd370f4">setHeaderData</a>(1, boost::any(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WString.html">WString</a>(<span class="stringliteral">"Y = sin(X)"</span>)));
<a name="l00187"></a>00187 
<a name="l00188"></a>00188   <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; 40; ++i) {
<a name="l00189"></a>00189     <span class="keywordtype">double</span> x = (<span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(i) - 20) / 4;
<a name="l00190"></a>00190 
<a name="l00191"></a>00191     model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#70856db8c322be8c7f397a932165a943">setData</a>(i, 0, boost::any(x));
<a name="l00192"></a>00192     model-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractItemModel.html#70856db8c322be8c7f397a932165a943">setData</a>(i, 1, boost::any(sin(x)));
<a name="l00193"></a>00193   }
<a name="l00194"></a>00194  
<a name="l00195"></a>00195   <span class="comment">/*</span>
<a name="l00196"></a>00196 <span class="comment">   * Create the scatter plot.</span>
<a name="l00197"></a>00197 <span class="comment">   */</span>
<a name="l00198"></a>00198   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html">WCartesianChart</a> *chart = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html">WCartesianChart</a>(<span class="keyword">this</span>);
<a name="l00199"></a>00199   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#a23d116689e939301470398df8ad5c8b">setModel</a>(model);        <span class="comment">// set the model</span>
<a name="l00200"></a>00200   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#6c954fa4ed6d73f00ee973bfe3af5ed0">setXSeriesColumn</a>(0);    <span class="comment">// set the column that holds the X data</span>
<a name="l00201"></a>00201   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#26c3d97f4884da079e01e7b50447a915">setLegendEnabled</a>(<span class="keyword">true</span>); <span class="comment">// enable the legend</span>
<a name="l00202"></a>00202 
<a name="l00203"></a>00203   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#02775290965d59ffba03da574925e387">setType</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#gg8d63464f873580c77508e1c0c26cbfea6ddab43d32242eb28831938a1e469a1f">ScatterPlot</a>);   <span class="comment">// set type to ScatterPlot</span>
<a name="l00204"></a>00204 
<a name="l00205"></a>00205   <span class="comment">// Typically, for mathematical functions, you want the axes to cross</span>
<a name="l00206"></a>00206   <span class="comment">// at the 0 mark:</span>
<a name="l00207"></a>00207   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#f966d6ee6b2e43e6b26e794459005375">axis</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#ggddb678f67fbd9f374fcee0922f158c9f2a592919e6cbd94bf09e1259559499b5">XAxis</a>).<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WAxis.html#6dab2f46117b85a4a6f439e4f194ee82">setLocation</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#gg77eb6d0cefa4a012950ea972b471b849f2e58ce3483a5ec496f65fb808ce72b9">ZeroValue</a>);
<a name="l00208"></a>00208   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#f966d6ee6b2e43e6b26e794459005375">axis</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#ggddb678f67fbd9f374fcee0922f158c9f2e1017fdef77b4663715c3d7663a4db4">YAxis</a>).<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WAxis.html#6dab2f46117b85a4a6f439e4f194ee82">setLocation</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#gg77eb6d0cefa4a012950ea972b471b849f2e58ce3483a5ec496f65fb808ce72b9">ZeroValue</a>);
<a name="l00209"></a>00209 
<a name="l00210"></a>00210   <span class="comment">// Provide space for the X and Y axis and title. </span>
<a name="l00211"></a>00211   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ce6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(100, Left);
<a name="l00212"></a>00212   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ce6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(50, Top | Bottom);
<a name="l00213"></a>00213 
<a name="l00214"></a>00214   <span class="comment">// Add the curves</span>
<a name="l00215"></a>00215   <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WDataSeries.html">WDataSeries</a> s(1, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#gg44d64e4a9d08c7ef69648f4a9c3e4053805880e23c0292fb7a66b2cda2a2f5bf">CurveSeries</a>);
<a name="l00216"></a>00216   s.setShadow(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WShadow.html">WShadow</a>(3, 3, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WColor.html">WColor</a>(0, 0, 0, 127), 3));
<a name="l00217"></a>00217   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#fa4ac6588e6e2e0dd93320c3a0541d46">addSeries</a>(s);
<a name="l00218"></a>00218 
<a name="l00219"></a>00219   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WPaintedWidget.html#a57b940110d240951d0e3a6d03390319">resize</a>(800, 300); <span class="comment">// WPaintedWidget must be given explicit size</span>
<a name="l00220"></a>00220 
<a name="l00221"></a>00221   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#07719d06da0dd17af2381c663e8fb0b7">setMargin</a>(10, Top | Bottom);            <span class="comment">// add margin vertically</span>
<a name="l00222"></a>00222   chart-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#07719d06da0dd17af2381c663e8fb0b7">setMargin</a>(WLength::Auto, Left | Right); <span class="comment">// center horizontally</span>
<a name="l00223"></a>00223 
<a name="l00224"></a>00224   <a class="code" href="classChartConfig.html" title="A class that allows configuration of a cartesian chart.">ChartConfig</a> *config = <span class="keyword">new</span> <a class="code" href="classChartConfig.html" title="A class that allows configuration of a cartesian chart.">ChartConfig</a>(chart, <span class="keyword">this</span>);
<a name="l00225"></a>00225   config-&gt;<a class="code" href="classChartConfig.html#5f4ddb33c53dc6907dcf73c2598ad0fa">setValueFill</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/group__charts.html#gg7236e5b04bdb6f393162842982b4d1a050b16db97a187f9acccdbeecf8732ff0">ZeroValueFill</a>);
<a name="l00226"></a>00226 }

</pre></div>
<p>

</div>
</div><p>
<hr>The documentation for this class was generated from the following files:<ul>
<li>/home/koen/project/wt/public-git/wt/examples/charts/<a class="el" href="ChartsExample_8h-source.html">ChartsExample.h</a><li>/home/koen/project/wt/public-git/wt/examples/charts/<a class="el" href="ChartsExample_8C-source.html">ChartsExample.C</a></ul>
</div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>