<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QCharts automatic axes scaling problem]]></title><description><![CDATA[<p dir="auto">Dear all,</p>
<p dir="auto">I want to plot data with QCharts. My idea is to create a chart and series in the constructor and add the series to the chart. Then I'd like like to add data to the series in a function and add axes to the chart that are scaled to the data points.</p>
<p dir="auto">createDefaultAxes() seems to do just what I want, but the scaling only works if I add the series to the chart <em>after</em> adding the data points.</p>
<p dir="auto">My code looks like so:</p>
<pre><code>    QLineSeries *series = new QLineSeries();
    QChart *chart = new QChart();
    chart-&gt;setTitle("Simple line chart example");
    ui-&gt;chartView-&gt;setChart(chart);
    ui-&gt;chartView-&gt;setRenderHint(QPainter::Antialiasing);

    chart-&gt;addSeries(series); // &lt;- axes _not_ scaled properly

    series-&gt;append(0, 0);
    series-&gt;append(2, 4);
    series-&gt;append(3, 8);
    series-&gt;append(7, 4);
    series-&gt;append(10, 5);

    // chart-&gt;addSeries(series); // &lt;- axes scaled properly

    chart-&gt;createDefaultAxes();
</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/b21981d5-ff15-4265-a4cb-c26c2027f48f.png" alt="0_1503392158044_QChart.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I don't really understand why it makes a difference, where series is added to chart. In the end, it's just a pointer, right?</p>
<p dir="auto">Does anyone have an idea how I can tell chart that its series has updated?</p>
<p dir="auto">Any help is appreciated :-)</p>
<p dir="auto">Best,<br />
Sebastian</p>
]]></description><link>https://forum.qt.io/topic/82588/qcharts-automatic-axes-scaling-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Apr 2026 23:23:35 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/82588.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Aug 2017 09:00:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QCharts automatic axes scaling problem on Thu, 24 Aug 2017 21:05:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">From a quick look at the documentation, I haven't see anything stating that adding points to a series after it has been added to a chart should trigger anything. The <a href="http://doc.qt.io/qt-5/qabstractseries.html" target="_blank" rel="noopener noreferrer nofollow ugc">QAstractSeries</a> class also doesn't seem to offer anything related to triggering an update.</p>
]]></description><link>https://forum.qt.io/post/412125</link><guid isPermaLink="true">https://forum.qt.io/post/412125</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 24 Aug 2017 21:05:41 GMT</pubDate></item><item><title><![CDATA[Reply to QCharts automatic axes scaling problem on Thu, 24 Aug 2017 10:44:45 GMT]]></title><description><![CDATA[<p dir="auto">Can anyone just confirm that it at least <em>should</em> work? Or am I reading the documentation wrong? Otherwise I'd file a bug...</p>
<p dir="auto">Best,<br />
Sebastian</p>
]]></description><link>https://forum.qt.io/post/412033</link><guid isPermaLink="true">https://forum.qt.io/post/412033</guid><dc:creator><![CDATA[SebastianH]]></dc:creator><pubDate>Thu, 24 Aug 2017 10:44:45 GMT</pubDate></item></channel></rss>