Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > bc3b37a19f14c9d212f32b1359cbcf6a > files > 431

qtcharts5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- examples-qmlcustomizations.qdoc -->
  <title>Qml Customizations | Qt Charts 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtcharts-index.html">Qt Charts</a></td><td ><a href="qtcharts-examples.html">Qt Charts Examples</a></td><td >Qml Customizations</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtcharts-index.html">Qt Charts | Commercial or GPLv3</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#customizing-chart-views">Customizing Chart Views</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qml Customizations</h1>
<span class="subtitle"></span>
<!-- $$$qmlcustomizations-brief -->
<p>This application shows you how to customize different visual properties of a <a href="qml-qtcharts-chartview.html">ChartView</a> and series.</p>
<!-- @@@qmlcustomizations -->
<!-- $$$qmlcustomizations-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/examples_qmlcustomizations.png" alt="" /></p><p>This example shows a wheel of fortune by customizing a pie series.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="customizing-chart-views"></a>
<h2 id="customizing-chart-views">Customizing Chart Views</h2>
<p>First we create the <a href="qml-qtcharts-chartview.html">ChartView</a> and a couple of series.</p>
<pre class="qml">

  ChartView {
      id: chartView
      anchors.fill: parent
      title: "Wheel of fortune"
      legend.visible: false
      antialiasing: true

      PieSeries {
          id: wheelOfFortune
          horizontalPosition: 0.3
      }

      SplineSeries {
          id: splineSeries
      }

      ScatterSeries {
          id: scatterSeries
      }
  }

</pre>
<p>The application data is generated in Component.onCompleted of the main rectangle:</p>
<pre class="qml">

  Component.onCompleted: {
      __intervalCoefficient = Math.random() + 0.25;

      for (var i = 0; i < 20; i++)
          wheelOfFortune.append("", 1);

      var interval = 1;
      for (var j = 0; interval < 800; j++) {
          interval = __intervalCoefficient * j * j;
          splineSeries.append(j, interval);
      }
      chartView.axisX(scatterSeries).max = j;
      chartView.axisY(scatterSeries).max = 1000;
  }

</pre>
<p>The following customizations are done repeatedly with a timer. To highlight one of the pie slices at time we modify its exploded property:</p>
<pre class="qml">

  wheelOfFortune.at(index).exploded = false;
  __activeIndex++;
  index = __activeIndex % wheelOfFortune.count;
  wheelOfFortune.at(index).exploded = true;

</pre>
<p>Then an animation using a scatter series with one data point:</p>
<pre class="qml">

  scatterSeries.clear();
  scatterSeries.append(__activeIndex, interval);
  scatterSeries.color = Qt.tint(scatterSeries.color, "#05FF0000");
  scatterSeries.markerSize += 0.5;

</pre>
<p>When the wheel of fortune has stopped, we make the active slice blink by modifying its colors.</p>
<pre class="qml">

  // Switch the colors of the slice and the border
  wheelOfFortune.at(index).borderWidth = 2;
  switchColor = wheelOfFortune.at(index).borderColor;
  wheelOfFortune.at(index).borderColor = wheelOfFortune.at(index).color;
  wheelOfFortune.at(index).color = switchColor;

</pre>
<p>Files:</p>
<ul>
<li><a href="qtcharts-qmlcustomizations-main-cpp.html">qmlcustomizations/main.cpp</a></li>
<li><a href="qtcharts-qmlcustomizations-qml-qmlcustomizations-main-qml.html">qmlcustomizations/qml/qmlcustomizations/main.qml</a></li>
<li><a href="qtcharts-qmlcustomizations-qmlcustomizations-pro.html">qmlcustomizations/qmlcustomizations.pro</a></li>
<li><a href="qtcharts-qmlcustomizations-resources-qrc.html">qmlcustomizations/resources.qrc</a></li>
</ul>
</div>
<!-- @@@qmlcustomizations -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>