##// END OF EJS Templates
Adds missing ticks hadnling
Michal Klocek -
r554:7777ba21b3a6
parent child
Show More
@@ -95,6 +95,7 QStringList AxisItem::createLabels(int ticks, qreal min, qreal max) const
95 95 labels << QString::number(value);
96 96 }
97 97 else {
98
98 99 QString label = categories->label(value);
99 100 labels << label;
100 101 }
@@ -370,19 +371,12 void AxisItem::handleAxisUpdated()
370 371
371 372 void AxisItem::handleRangeChanged(qreal min, qreal max,int tickCount)
372 373 {
374 qDebug()<<min<<max<<tickCount;
375 if(min==max || tickCount<2) return;
376
373 377 m_min = min;
374 378 m_max = max;
375 m_ticksCount = tickCount;
376
377 /*= qrand()%10;
378
379 while(m_ticksCount<2){
380 m_ticksCount = qrand()%10;
381 }
382
383 qDebug()<<"Warning : This is testing . Simulating new random ticks "<< m_ticksCount;
384 //m_chartAxis->setTicksCount(m_ticksCount);
385 */
379 m_ticksCount= tickCount;
386 380
387 381 if(isEmpty()) return;
388 382 QVector<qreal> layout = calculateLayout();
@@ -342,15 +342,10 void QChartAxis::setRange(qreal min, qreal max)
342 342 }
343 343
344 344 if(changed) {
345 emit rangeChanged(m_min,m_max,m_ticksCount);
345 emit rangeChanged(m_min,m_max);
346 346 }
347 347 }
348 348
349 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max)
350 {
351 setRange(min,max);
352 }
353
354 349 /*!
355 350 Sets \a count for ticks on the axis.
356 351 */
@@ -358,7 +353,7 void QChartAxis::setTicksCount(int count)
358 353 {
359 354 if(m_ticksCount!=count) {
360 355 m_ticksCount=count;
361 emit rangeChanged(m_min,m_max,m_ticksCount);
356 emit ticksCountChanged(count);
362 357 }
363 358 }
364 359
@@ -386,6 +381,17 void QChartAxis::hide()
386 381 emit updated();
387 382 }
388 383
384 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max)
385 {
386 qDebug()<<__FUNCTION__<<min<<max;
387 setRange(min,max);
388 }
389
390 void QChartAxis::handleAxisTicksChanged(int count)
391 {
392 setTicksCount(count);
393 }
394
389 395 #include "moc_qchartaxis.cpp"
390 396
391 397 QTCOMMERCIALCHART_END_NAMESPACE
@@ -68,13 +68,15 public:
68 68 signals:
69 69 void minChanged(qreal min);
70 70 void maxChanged(qreal max);
71 void rangeChanged(qreal min, qreal max,int ticksCount);
71 void rangeChanged(qreal min, qreal max);
72 void ticksCountChanged(int count);
72 73
73 74 //interal signal
74 75 void updated();
75 76 //internal slot
76 77 public slots:
77 78 void handleAxisRangeChanged(qreal min, qreal max);
79 void handleAxisTicksChanged(int count);
78 80
79 81 private:
80 82 bool m_axisVisible;
@@ -47,8 +47,12 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
47 47
48 48 if(!domain) {
49 49 domain = new Domain();
50 QObject::connect(axisY,SIGNAL(rangeChanged(qreal,qreal,int)),domain,SLOT(handleAxisRangeYChanged(qreal,qreal,int)));
51 QObject::connect(axisX(),SIGNAL(rangeChanged(qreal,qreal,int)),domain,SLOT(handleAxisRangeXChanged(qreal,qreal,int)));
50 QObject::connect(axisY,SIGNAL(rangeChanged(qreal,qreal)),domain,SLOT(handleAxisRangeYChanged(qreal,qreal)));
51 QObject::connect(axisX(),SIGNAL(rangeChanged(qreal,qreal)),domain,SLOT(handleAxisRangeXChanged(qreal,qreal)));
52 QObject::connect(axisY,SIGNAL(ticksCountChanged(int)),domain,SLOT(handleAxisYTicksCountChanged(int)));
53 QObject::connect(axisX(),SIGNAL(ticksCountChanged(int)),domain,SLOT(handleAxisXTicksCountChanged(int)));
54 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal)));
55 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal)));
52 56 //initialize
53 57 m_axisDomainMap.insert(axisY,domain);
54 58 emit axisAdded(axisY,domain);
@@ -18,26 +18,19 Domain::~Domain()
18 18
19 19 void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
20 20 {
21 setRange(minX, maxX, minY, maxY, m_tickXCount, m_tickYCount);
22 }
23
24 void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount,int tickYCount)
25 {
26 21 bool changed = false;
27 22
28 if(m_minX!=minX || m_maxX!=maxX || m_tickXCount!=tickXCount)
23 if(m_minX!=minX || m_maxX!=maxX)
29 24 {
30 25 m_minX=minX;
31 26 m_maxX=maxX;
32 m_tickXCount=tickXCount;
33 27 changed=true;
34 28 emit rangeXChanged(minX,maxX, m_tickXCount);
35 29 }
36 30
37 if(m_minY!=minY || m_maxY!=maxY || m_tickYCount!=tickYCount){
31 if(m_minY!=minY || m_maxY!=maxY){
38 32 m_minY=minY;
39 33 m_maxY=maxY;
40 m_tickYCount=tickYCount;
41 34 changed=true;
42 35 emit rangeYChanged(minY,maxY, m_tickYCount);
43 36 }
@@ -142,14 +135,30 void Domain::move(int dx,int dy,const QSizeF& size)
142 135 emit domainChanged(m_minX, m_maxX, m_minY, m_maxY);
143 136 }
144 137
145 void Domain::handleAxisRangeXChanged(qreal min,qreal max,int tickCount)
138 void Domain::handleAxisRangeXChanged(qreal min,qreal max)
139 {
140 setRange(min,max,m_minY, m_maxY);
141 }
142
143 void Domain::handleAxisRangeYChanged(qreal min,qreal max)
146 144 {
147 setRange(min,max,m_minY, m_maxY,tickCount,m_tickYCount);
145 setRange(m_minX, m_maxX, min, max);
148 146 }
149 147
150 void Domain::handleAxisRangeYChanged(qreal min,qreal max,int tickCount)
148 void Domain::handleAxisXTicksCountChanged(int tickCount)
151 149 {
152 setRange(m_minX, m_maxX, min, max,m_tickXCount, tickCount);
150 if(m_tickXCount!=tickCount){
151 m_tickXCount=tickCount;
152 emit rangeXChanged(m_minX,m_maxX, m_tickXCount);
153 }
154 }
155
156 void Domain::handleAxisYTicksCountChanged(int tickCount)
157 {
158 if(m_tickYCount!=tickCount){
159 m_tickYCount=tickCount;
160 emit rangeYChanged(m_minY,m_maxY, m_tickYCount);
161 }
153 162 }
154 163
155 164 bool operator== (const Domain &domain1, const Domain &domain2)
@@ -13,7 +13,6 public:
13 13 virtual ~Domain();
14 14
15 15 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY);
16 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY,int tickXCount,int tickYCount);
17 16 void setRangeX(qreal min, qreal max);
18 17 void setRangeY(qreal min, qreal max);
19 18 void setMinX(qreal min);
@@ -48,8 +47,10 signals:
48 47
49 48
50 49 public slots:
51 void handleAxisRangeXChanged(qreal min,qreal max,int tickCount);
52 void handleAxisRangeYChanged(qreal min,qreal max,int tickCount);
50 void handleAxisRangeXChanged(qreal min,qreal max);
51 void handleAxisRangeYChanged(qreal min,qreal max);
52 void handleAxisXTicksCountChanged(int tickCount);
53 void handleAxisYTicksCountChanged(int tickCount);
53 54
54 55 private:
55 56 qreal m_minX;
General Comments 0
You need to be logged in to leave comments. Login now