@@ -95,6 +95,7 QStringList AxisItem::createLabels(int ticks, qreal min, qreal max) const | |||||
95 | labels << QString::number(value); |
|
95 | labels << QString::number(value); | |
96 | } |
|
96 | } | |
97 | else { |
|
97 | else { | |
|
98 | ||||
98 | QString label = categories->label(value); |
|
99 | QString label = categories->label(value); | |
99 | labels << label; |
|
100 | labels << label; | |
100 | } |
|
101 | } | |
@@ -370,19 +371,12 void AxisItem::handleAxisUpdated() | |||||
370 |
|
371 | |||
371 | void AxisItem::handleRangeChanged(qreal min, qreal max,int tickCount) |
|
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 | m_min = min; |
|
377 | m_min = min; | |
374 | m_max = max; |
|
378 | m_max = max; | |
375 |
m_ticksCount |
|
379 | 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 | */ |
|
|||
386 |
|
380 | |||
387 | if(isEmpty()) return; |
|
381 | if(isEmpty()) return; | |
388 | QVector<qreal> layout = calculateLayout(); |
|
382 | QVector<qreal> layout = calculateLayout(); |
@@ -342,15 +342,10 void QChartAxis::setRange(qreal min, qreal max) | |||||
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 | if(changed) { |
|
344 | if(changed) { | |
345 |
emit rangeChanged(m_min,m_max |
|
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 | Sets \a count for ticks on the axis. |
|
350 | Sets \a count for ticks on the axis. | |
356 | */ |
|
351 | */ | |
@@ -358,7 +353,7 void QChartAxis::setTicksCount(int count) | |||||
358 | { |
|
353 | { | |
359 | if(m_ticksCount!=count) { |
|
354 | if(m_ticksCount!=count) { | |
360 | m_ticksCount=count; |
|
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 | emit updated(); |
|
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 | #include "moc_qchartaxis.cpp" |
|
395 | #include "moc_qchartaxis.cpp" | |
390 |
|
396 | |||
391 | QTCOMMERCIALCHART_END_NAMESPACE |
|
397 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -68,13 +68,15 public: | |||||
68 | signals: |
|
68 | signals: | |
69 | void minChanged(qreal min); |
|
69 | void minChanged(qreal min); | |
70 | void maxChanged(qreal max); |
|
70 | void maxChanged(qreal max); | |
71 |
void rangeChanged(qreal min, qreal max |
|
71 | void rangeChanged(qreal min, qreal max); | |
|
72 | void ticksCountChanged(int count); | |||
72 |
|
73 | |||
73 | //interal signal |
|
74 | //interal signal | |
74 | void updated(); |
|
75 | void updated(); | |
75 | //internal slot |
|
76 | //internal slot | |
76 | public slots: |
|
77 | public slots: | |
77 | void handleAxisRangeChanged(qreal min, qreal max); |
|
78 | void handleAxisRangeChanged(qreal min, qreal max); | |
|
79 | void handleAxisTicksChanged(int count); | |||
78 |
|
80 | |||
79 | private: |
|
81 | private: | |
80 | bool m_axisVisible; |
|
82 | bool m_axisVisible; |
@@ -47,8 +47,12 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) | |||||
47 |
|
47 | |||
48 | if(!domain) { |
|
48 | if(!domain) { | |
49 | domain = new Domain(); |
|
49 | domain = new Domain(); | |
50 |
QObject::connect(axisY,SIGNAL(rangeChanged(qreal,qreal |
|
50 | QObject::connect(axisY,SIGNAL(rangeChanged(qreal,qreal)),domain,SLOT(handleAxisRangeYChanged(qreal,qreal))); | |
51 |
QObject::connect(axisX(),SIGNAL(rangeChanged(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 | //initialize |
|
56 | //initialize | |
53 | m_axisDomainMap.insert(axisY,domain); |
|
57 | m_axisDomainMap.insert(axisY,domain); | |
54 | emit axisAdded(axisY,domain); |
|
58 | emit axisAdded(axisY,domain); |
@@ -18,26 +18,19 Domain::~Domain() | |||||
18 |
|
18 | |||
19 | void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) |
|
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 | bool changed = false; |
|
21 | bool changed = false; | |
27 |
|
22 | |||
28 |
if(m_minX!=minX || m_maxX!=maxX |
|
23 | if(m_minX!=minX || m_maxX!=maxX) | |
29 | { |
|
24 | { | |
30 | m_minX=minX; |
|
25 | m_minX=minX; | |
31 | m_maxX=maxX; |
|
26 | m_maxX=maxX; | |
32 | m_tickXCount=tickXCount; |
|
|||
33 | changed=true; |
|
27 | changed=true; | |
34 | emit rangeXChanged(minX,maxX, m_tickXCount); |
|
28 | emit rangeXChanged(minX,maxX, m_tickXCount); | |
35 | } |
|
29 | } | |
36 |
|
30 | |||
37 |
if(m_minY!=minY || m_maxY!=maxY |
|
31 | if(m_minY!=minY || m_maxY!=maxY){ | |
38 | m_minY=minY; |
|
32 | m_minY=minY; | |
39 | m_maxY=maxY; |
|
33 | m_maxY=maxY; | |
40 | m_tickYCount=tickYCount; |
|
|||
41 | changed=true; |
|
34 | changed=true; | |
42 | emit rangeYChanged(minY,maxY, m_tickYCount); |
|
35 | emit rangeYChanged(minY,maxY, m_tickYCount); | |
43 | } |
|
36 | } | |
@@ -142,14 +135,30 void Domain::move(int dx,int dy,const QSizeF& size) | |||||
142 | emit domainChanged(m_minX, m_maxX, m_minY, m_maxY); |
|
135 | emit domainChanged(m_minX, m_maxX, m_minY, m_maxY); | |
143 | } |
|
136 | } | |
144 |
|
137 | |||
145 |
void Domain::handleAxisRangeXChanged(qreal min,qreal max |
|
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 |
|
145 | setRange(m_minX, m_maxX, min, max); | |
148 | } |
|
146 | } | |
149 |
|
147 | |||
150 |
void Domain::handleAxis |
|
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 | bool operator== (const Domain &domain1, const Domain &domain2) |
|
164 | bool operator== (const Domain &domain1, const Domain &domain2) |
@@ -13,7 +13,6 public: | |||||
13 | virtual ~Domain(); |
|
13 | virtual ~Domain(); | |
14 |
|
14 | |||
15 | void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); |
|
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 | void setRangeX(qreal min, qreal max); |
|
16 | void setRangeX(qreal min, qreal max); | |
18 | void setRangeY(qreal min, qreal max); |
|
17 | void setRangeY(qreal min, qreal max); | |
19 | void setMinX(qreal min); |
|
18 | void setMinX(qreal min); | |
@@ -48,8 +47,10 signals: | |||||
48 |
|
47 | |||
49 |
|
48 | |||
50 | public slots: |
|
49 | public slots: | |
51 |
|
|
50 | void handleAxisRangeXChanged(qreal min,qreal max); | |
52 |
|
|
51 | void handleAxisRangeYChanged(qreal min,qreal max); | |
|
52 | void handleAxisXTicksCountChanged(int tickCount); | |||
|
53 | void handleAxisYTicksCountChanged(int tickCount); | |||
53 |
|
54 | |||
54 | private: |
|
55 | private: | |
55 | qreal m_minX; |
|
56 | qreal m_minX; |
General Comments 0
You need to be logged in to leave comments.
Login now