Sophie

Sophie

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

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-qmlcustomlegend.qdoc -->
  <title>Qml Custom Legend | 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 Custom Legend</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-legends">Customizing Legends</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qml Custom Legend</h1>
<span class="subtitle"></span>
<!-- $$$qmlcustomlegend-brief -->
<p>This example shows you how to create your own custom legend.</p>
<!-- @@@qmlcustomlegend -->
<!-- $$$qmlcustomlegend-description -->
<div class="descr"> <a name="details"></a>
<p>This application shows you how to create your own custom legend instead of using the built-in legend of <a href="qml-qtcharts-chartview.html">ChartView</a> API.</p>
<p>The main view of the application shows a stacked area chart. This is how one of the stacked areas is created. See ChartViewStacked.qml and AnimatedAreaSeries.qml.</p>
<p class="centerAlign"><img src="images/examples_qmlcustomlegend1.png" alt="" /></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-legends"></a>
<h2 id="customizing-legends">Customizing Legends</h2>
<pre class="qml">

  AnimatedAreaSeries {
      id: municipalSeries
      name: "municipal"
      axisX: axisX
      axisY: axisY
      borderWidth: 0
      upperSeries: LineSeries {
          id: municipalUpper
          XYPoint { x: 2006; y: 33119 + 13443 }
          XYPoint { x: 2007; y: 37941 + 15311 }
          XYPoint { x: 2008; y: 40122 + 16552 }
          XYPoint { x: 2009; y: 38991 + 17904 }
          XYPoint { x: 2010; y: 34055 + 17599 }
          XYPoint { x: 2011; y: 34555 + 19002 }
          XYPoint { x: 2012; y: 38991 + 19177 }
      }
      lowerSeries: stateUpper
  }

</pre>
<p>Hovering with mouse on top of the legend will highlight the hovered series. (see CustomLegend.qml).</p>
<p class="centerAlign"><img src="images/examples_qmlcustomlegend2.png" alt="" /></p><pre class="qml">

  Row {
      id: legendRow
      anchors.centerIn: parent
      spacing: 10

      Repeater {
          id: legendRepeater
          model: seriesCount
          delegate: legendDelegate
      }
  }
  Component {
      id: legendDelegate
      Rectangle {
          id: rect
      ...
          MouseArea {
              id: mouseArea
              anchors.fill: parent
              hoverEnabled: true
              onEntered: {
                  rect.gradient = buttonGradientHovered;
                  legend.entered(label.text);
              }
              onExited: {
                  rect.gradient = buttonGradient;
                  legend.exited(label.text);
                  marker.opacity = 0.3;
                  marker.height = 10;
              }
              onClicked: {
                  legend.selected(label.text);
                  marker.opacity = 1.0;
                  marker.height = 12;
              }
          }

</pre>
<p>You can also select one of the stacked areas for a closer look as a line series by a mouse click (see ChartViewHighlighted.qml).</p>
<p class="centerAlign"><img src="images/examples_qmlcustomlegend3.png" alt="" /></p><pre class="qml">

  ChartView {
      id: chartViewHighlighted
      title: ""
      property variant selectedSeries
      signal clicked
      legend.visible: false
      margins.top: 10
      margins.bottom: 0
      antialiasing: true

      LineSeries {
          id: lineSeries

          axisX: ValueAxis {
              min: 2006
              max: 2012
              labelFormat: "%.0f"
              tickCount: 7
          }
          axisY: ValueAxis {
              id: axisY
              titleText: "EUR"
              min: 0
              max: 40000
              labelFormat: "%.0f"
              tickCount: 5
          }
      }

</pre>
<p>Files:</p>
<ul>
<li><a href="qtcharts-qmlcustomlegend-main-cpp.html">qmlcustomlegend/main.cpp</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-animatedareaseries-qml.html">qmlcustomlegend/qml/qmlcustomlegend/AnimatedAreaSeries.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-chartviewhighlighted-qml.html">qmlcustomlegend/qml/qmlcustomlegend/ChartViewHighlighted.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-chartviewselector-qml.html">qmlcustomlegend/qml/qmlcustomlegend/ChartViewSelector.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-chartviewstacked-qml.html">qmlcustomlegend/qml/qmlcustomlegend/ChartViewStacked.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-customlegend-qml.html">qmlcustomlegend/qml/qmlcustomlegend/CustomLegend.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qml-qmlcustomlegend-main-qml.html">qmlcustomlegend/qml/qmlcustomlegend/main.qml</a></li>
<li><a href="qtcharts-qmlcustomlegend-qmlcustomlegend-pro.html">qmlcustomlegend/qmlcustomlegend.pro</a></li>
<li><a href="qtcharts-qmlcustomlegend-resources-qrc.html">qmlcustomlegend/resources.qrc</a></li>
</ul>
</div>
<!-- @@@qmlcustomlegend -->
        </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>