Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Spline Chart
Forum Updated to NodeBB v4.3 + New Features

Spline Chart

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 197 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by IknowQT
    #1

    52551c4f-52dd-42cf-9f74-2e1b5cf74e1c-image.png

    QChart* QTemperatureChart::createSplineChart()
    {
    	m_pChart = new QChart();
    	m_pChart->setTitle("Spline chart");
    
    	// The lower series initialized to zero values
    	QString name("Series ");
    	int nameIndex = 0;
    
    	m_pSplineSeries = new QSplineSeries(m_pChart);
    	
    	m_pChart->addSeries(m_pSplineSeries);
    
    	m_pChart->addAxis(m_valueAxisX = new QValueAxis(), Qt::AlignBottom);
    	m_pChart->addAxis(m_valueAxisY = new QValueAxis(), Qt::AlignLeft);
    
    	m_pSplineSeries->attachAxis(m_valueAxisX);
    	m_pSplineSeries->attachAxis(m_valueAxisY);
    
    	m_valueAxisX->setTickCount(7);
    	m_valueAxisX->setRange(0, 6);
    	m_valueAxisY->setRange(0, 100);
    
    	//m_pChart->createDefaultAxes();
    	//m_pChart->axes(Qt::Vertical).first()->setRange(0, 10);
    
    	return m_pChart;
    }
    
    void QTemperatureChart::UpdateChart(QPointF point)
    {
    	int randomx = QRandomGenerator::global()->bounded(0, 100);
    	int randomy = QRandomGenerator::global()->bounded(0, 100);
    
    	
    	m_pSplineSeries->append(m_pSplineSeries->count(), randomy);
    	m_pChart->scroll(10, 0);
    }
    

    595b7252-b6f3-495c-9bc2-ed89e3bb5383-image.png

    I want to increase the x-axis by one on the chart, but it's increasing by 0.1.
    And I want to fix the graph in the middle, so I think I can use Scroll.
    But it doesn't work.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved