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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Wt examples: TimeSeriesExample Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Wt examples
 <span id="projectnumber">3.2.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main 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 id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> </div>
<div class="headertitle">
<div class="title">TimeSeriesExample Class Reference<div class="ingroups"><a class="el" href="group__chartsexample.html">Charts example</a></div></div> </div>
</div>
<div class="contents">
<!-- doxytag: class="TimeSeriesExample" --><!-- doxytag: inherits="Wt::WContainerWidget" -->
<p>A widget that demonstrates a times series chart.
<a href="classTimeSeriesExample.html#details">More...</a></p>
<p><code>#include <<a class="el" href="ChartsExample_8h_source.html">ChartsExample.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for TimeSeriesExample:</div>
<div class="dyncontent">
<div class="center"><img src="classTimeSeriesExample__inherit__graph.png" border="0" usemap="#TimeSeriesExample_inherit__map" alt="Inheritance graph"/></div>
<map name="TimeSeriesExample_inherit__map" id="TimeSeriesExample_inherit__map">
<area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html" title="Wt::WContainerWidget" alt="" coords="5,304,160,331"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html" title="Wt::WInteractWidget" alt="" coords="11,229,155,256"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html" title="Wt::WWebWidget" alt="" coords="19,155,147,181"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html" title="Wt::WWidget" alt="" coords="33,80,132,107"/><area shape="rect" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WObject.html" title="Wt::WObject" alt="" coords="35,5,131,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<p><a href="classTimeSeriesExample-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classTimeSeriesExample.html#a696c3e952d1f9b4ed3bdbf415f1634a5">TimeSeriesExample</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#a3461e31818c4d2f516641bdaf508312a">parent</a>)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Creates the time series scatter plot example. <a href="#a696c3e952d1f9b4ed3bdbf415f1634a5"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A widget that demonstrates a times series chart. </p>
<p>Definition at line <a class="el" href="ChartsExample_8h_source.html#l00029">29</a> of file <a class="el" href="ChartsExample_8h_source.html">ChartsExample.h</a>.</p>
</div><hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="a696c3e952d1f9b4ed3bdbf415f1634a5"></a><!-- doxytag: member="TimeSeriesExample::TimeSeriesExample" ref="a696c3e952d1f9b4ed3bdbf415f1634a5" args="(Wt::WContainerWidget *parent)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">TimeSeriesExample::TimeSeriesExample </td>
<td>(</td>
<td class="paramtype"><a class="elRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> * </td>
<td class="paramname"><em>parent</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Creates the time series scatter plot example. </p>
<p>Definition at line <a class="el" href="ChartsExample_8C_source.html#l00163">163</a> of file <a class="el" href="ChartsExample_8C_source.html">ChartsExample.C</a>.</p>
<div class="fragment"><pre class="fragment"> :
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a520ba6e52a36a7f2efbef1a31a69e898">WContainerWidget</a>(parent)
{
<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"</span>), <span class="keyword">this</span>);
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html">WAbstractItemModel</a> *model = readCsvFile(
WApplication::appRoot() + <span class="stringliteral">"timeseries.csv"</span>, <span class="keyword">this</span>);
<span class="keywordflow">if</span> (!model)
<span class="keywordflow">return</span>;
<span class="comment">/*</span>
<span class="comment"> * Parses the first column as dates, to be able to use a date scale</span>
<span class="comment"> */</span>
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < model-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#ab0709a8f71fd5df882f29bb29fd055f0">rowCount</a>(); ++i) {
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">WString</a> s = <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__modelview.html#ga57b5cadd177847f51eaeb0cee23782c1">asString</a>(model-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#a9112b74d160f916ef75fb6c1c09dd8fe">data</a>(i, 0));
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WDate.html">WDate</a> d = WDate::fromString(s, <span class="stringliteral">"dd/MM/yy"</span>);
model-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#a70856db8c322be8c7f397a932165a943">setData</a>(i, 0, d);
}
<span class="comment">// Show a view that allows editing of the model.</span>
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a> *w = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a520ba6e52a36a7f2efbef1a31a69e898">WContainerWidget</a>(<span class="keyword">this</span>);
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html">WTableView</a> *table = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html">WTableView</a>(w);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCompositeWidget.html#addf49ace29b76331067c86bc4ae6ac38">setMargin</a>(10, Top | Bottom);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WCompositeWidget.html#addf49ace29b76331067c86bc4ae6ac38">setMargin</a>(WLength::Auto, Left | Right);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a2e3629fbaee86da21c77c4583efb79ed">setModel</a>(model);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#ae1c86a0f37f97f63aed3b00fd8ffad7c">setSortingEnabled</a>(<span class="keyword">false</span>); <span class="comment">// Does not make much sense for time series</span>
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a4fe24c3ed80cc59f6bed2ed7795bc127">setColumnResizeEnabled</a>(<span class="keyword">true</span>);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#af6fcd9761e2f7a3b497d3563c849d320">setSelectionMode</a>(NoSelection);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#afbc128d312f1d5aa75c65352cb43e4ca">setAlternatingRowColors</a>(<span class="keyword">true</span>);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#aafd2a6edd366b620c71d9b3a89ed6590">setColumnAlignment</a>(0, AlignCenter);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a036e6a392c5e38470326d71157140d1a">setHeaderAlignment</a>(0, AlignCenter);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#ab17c45b65e38c22c0230062696c36e61">setRowHeight</a>(22);
<span class="comment">// Editing does not really work without Ajax, it would require an</span>
<span class="comment">// additional button somewhere to confirm the edited value.</span>
<span class="keywordflow">if</span> (WApplication::instance()->environment().ajax()) {
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a921a3a6c489b584b261c6b7c7bf720d8">resize</a>(800, 20 + 5*22);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a93d2efc8642a6b9c55b35b7665a13da5">setEditTriggers</a>(WAbstractItemView::SingleClicked);
} <span class="keywordflow">else</span> {
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#a921a3a6c489b584b261c6b7c7bf720d8">resize</a>(800, 20 + 5*22 + 25);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a93d2efc8642a6b9c55b35b7665a13da5">setEditTriggers</a>(WAbstractItemView::NoEditTrigger);
}
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html">WItemDelegate</a> *delegate = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html">WItemDelegate</a>(<span class="keyword">this</span>);
delegate-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html#ad886d265dc00b95d9fb90c022a6322f9">setTextFormat</a>(<span class="stringliteral">"%.1f"</span>);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a2954ce5999e6ca683fef576777973496">setItemDelegate</a>(delegate);
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemView.html#a574bc36ec752012ba4a613e0e11e064e">setItemDelegateForColumn</a>(0, <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WItemDelegate.html">WItemDelegate</a>(<span class="keyword">this</span>));
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#af37d27044e96919e2fa6af4e25f3ef67">setColumnWidth</a>(0, 80);
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < model-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WAbstractItemModel.html#abcf7912a95a0a60f8e9b1c37d30b8383">columnCount</a>(); ++i)
table-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WTableView.html#af37d27044e96919e2fa6af4e25f3ef67">setColumnWidth</a>(i, 90);
<span class="comment">/*</span>
<span class="comment"> * Create the scatter plot.</span>
<span class="comment"> */</span>
<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>);
<span class="comment">//chart->setPreferredMethod(WPaintedWidget::PngImage);</span>
<span class="comment">//chart->setBackground(gray);</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#aa23d116689e939301470398df8ad5c8b">setModel</a>(model); <span class="comment">// set the model</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#a6c954fa4ed6d73f00ee973bfe3af5ed0">setXSeriesColumn</a>(0); <span class="comment">// set the column that holds the X data</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#a26c3d97f4884da079e01e7b50447a915">setLegendEnabled</a>(<span class="keyword">true</span>); <span class="comment">// enable the legend</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#a02775290965d59ffba03da574925e387">setType</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__charts.html#gga8d63464f873580c77508e1c0c26cbfeaa6ddab43d32242eb28831938a1e469a1f">ScatterPlot</a>); <span class="comment">// set type to ScatterPlot</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#af966d6ee6b2e43e6b26e794459005375">axis</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__charts.html#ggaddb678f67fbd9f374fcee0922f158c9fa2a592919e6cbd94bf09e1259559499b5">XAxis</a>).<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAxis.html#ab067037b83d1d663535250968a1776d8">setScale</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__charts.html#ggadfcaed8cd6ff52f5747f7df48f2eeab6aaa627030efa552170a889d7a80a65a12">DateScale</a>); <span class="comment">// set scale of X axis to DateScale</span>
<span class="comment">// Provide space for the X and Y axis and title. </span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ace6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(80, Left);
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WAbstractChart.html#ace6ea85014f731c7034e4215710a8a48">setPlotAreaPadding</a>(40, Top | Bottom);
<span class="comment">/*</span>
<span class="comment"> * Add first two columns as line series</span>
<span class="comment"> */</span>
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i < 3; ++i) {
<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WDataSeries.html">WDataSeries</a> s(i, <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/group__charts.html#gga44d64e4a9d08c7ef69648f4a9c3e4053a2582c20d00d806d8a175e2f5c0207591">LineSeries</a>);
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));
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1Chart_1_1WCartesianChart.html#afa4ac6588e6e2e0dd93320c3a0541d46">addSeries</a>(s);
}
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WPaintedWidget.html#aa57b940110d240951d0e3a6d03390319">resize</a>(800, 400); <span class="comment">// WPaintedWidget must be given explicit size</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a9795c18e926b26b97fcbabc62a1dd4e3">setMargin</a>(10, Top | Bottom); <span class="comment">// add margin vertically</span>
chart-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a9795c18e926b26b97fcbabc62a1dd4e3">setMargin</a>(WLength::Auto, Left | Right); <span class="comment">// center horizontally</span>
<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>);
}
</pre></div>
</div>
</div>
<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>
<li>/home/koen/project/wt/public-git/wt/examples/charts/<a class="el" href="ChartsExample_8C_source.html">ChartsExample.C</a></li>
</ul>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Fri Mar 30 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by <a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>
|