32#include <KDDrawText.h>
33#include "KDChartAxesPainter.h"
45int secondsSinceUTCStart( const TQDateTime& dt )
47 TQDateTime dtStart( TQDate( 1970, 1, 1 ) );
48 return dtStart.secsTo( dt );
86void reCalculateLabelTexts(
91 double averageValueP1000,
93 internal__KDChart__CalcValues& cv )
108 cv.pXDelimDeltaFaktor,
109 cv.pYDelimDeltaFaktor,
135bool KDChartAxesPainter::calculateAllAxesLabelTextsAndCalcValues(
138 double areaWidthP1000,
139 double areaHeightP1000,
143 double averageValueP1000 = TQMIN(areaWidthP1000, areaHeightP1000);
146 delimLen = 20.0 * averageValueP1000;
153 internal__KDChart__CalcValues& cv = calcVal[iAxis];
155 && KDChartAxisParams::AxisTypeUnknown
157 if( cv.processThisAxis ){
158 cv.nSubDelimFactor = 0.0;
159 cv.pDelimDelta = 0.0;
165 cv.textAlign = TQt::AlignHCenter | TQt::AlignVCenter;
166 cv.isDateTime = false;
167 cv.autoDtLabels = false;
180 cv.pXDelimDeltaFaktor,
181 cv.pYDelimDeltaFaktor,
203 cv.pLastX = cv.dest.x();
204 cv.pLastY = cv.dest.y();
210 internal__KDChart__CalcValues& cv = calcVal[iAxis];
211 if( cv.processThisAxis
215 if( KDCHART_NO_AXIS != isoRef
218 || KDCHART_ALL_AXES == isoRef ) ){
219 if( KDCHART_ALL_AXES == isoRef ){
222 double nDelta = cv.nDelta;
223 double nDeltaPix = cv.nDeltaPix;
224 double nSubDelimFactor = cv.nSubDelimFactor;
228 internal__KDChart__CalcValues& cv2 = calcVal[iAxis2];
229 if( cv2.processThisAxis
231 && (0.0 != cv2.nDelta)
232 && (fabs(cv2.nDeltaPix / cv2.nDelta) < fabs(nDeltaPix / nDelta)) ){
233 if( (nDelta >= 0.0) == (cv2.nDelta >= 0.0) )
236 nDelta = cv2.nDelta * -1.0;
237 if( (nDeltaPix >= 0.0) == (cv2.nDeltaPix >= 0.0) )
238 nDeltaPix = cv2.nDeltaPix;
240 nDeltaPix = cv2.nDeltaPix * -1.0;
241 if( (nSubDelimFactor >= 0.0) == (cv2.nSubDelimFactor >= 0.0) )
242 nSubDelimFactor = cv2.nSubDelimFactor;
244 nSubDelimFactor = cv2.nSubDelimFactor * -1.0;
251 internal__KDChart__CalcValues& cv2 = calcVal[iAxis2];
252 if( cv2.processThisAxis
254 && ( fabs(cv2.nDelta) != fabs(nDelta)
255 || fabs(cv2.nDeltaPix) != fabs(nDeltaPix) ) ){
259 if( (cv2.nDelta >= 0.0) == (nDelta >= 0.0) )
262 cv2.nDelta = nDelta * -1.0;
263 if( (cv2.nDeltaPix >= 0.0) == (nDeltaPix >= 0.0) )
264 cv2.nDeltaPix = nDeltaPix;
266 cv2.nDeltaPix = nDeltaPix * -1.0;
267 reCalculateLabelTexts( painter,
274 if( (cv2.nSubDelimFactor >= 0.0) == (nSubDelimFactor >= 0.0) )
275 cv2.nSubDelimFactor = nSubDelimFactor;
277 cv2.nSubDelimFactor = nSubDelimFactor * -1.0;
281 internal__KDChart__CalcValues& cv2 = calcVal[isoRef];
283 if( cv2.processThisAxis
285 && ( cv2.nDelta != cv.nDelta
286 || cv2.nDeltaPix != cv.nDeltaPix ) ){
287 if( cv2.nDelta > cv.nDelta
288 || ( cv2.nDelta == cv.nDelta
289 && cv2.nDeltaPix < cv.nDeltaPix ) ){
292 cv.nDelta = cv2.nDelta;
293 cv.nDeltaPix = cv2.nDeltaPix;
294 reCalculateLabelTexts(
302 cv.nSubDelimFactor = cv2.nSubDelimFactor;
308 cv2.nDelta = cv.nDelta;
309 cv2.nDeltaPix = cv.nDeltaPix;
310 reCalculateLabelTexts(
318 cv2.nSubDelimFactor = cv.nSubDelimFactor;
338 if ( !painter || !data || 0 == params() )
341 const bool bMultiRowBarChart = KDChartParams::Bar == params()-> chartType() &&
344 double areaWidthP1000 = _logicalWidth / 1000.0;
345 double areaHeightP1000 = _logicalHeight / 1000.0;
346 double averageValueP1000 = TQMIN(areaWidthP1000, areaHeightP1000);
352 calculateAllAxesLabelTextsAndCalcValues( painter, data, areaWidthP1000, areaHeightP1000, delimLen );
357 painter->setPen( TQt::NoPen );
363 internal__KDChart__CalcValues& cv = calcVal[iAxis];
364 if( cv.processThisAxis ){
368 internal__KDChart__CalcValues& cv = calcVal[iAxis];
378 * averageValueP1000 );
388 * averageValueP1000 ) );
390 uint gridSubLineWidth
397 * averageValueP1000 ) );
449 if( cv.bLogarithmic )
450 cv.nSubDelimFactor = 0.1;
452 const double nUsableAxisHeight = cv.pTextsH;
453 const double nUsableAxisWidth = cv.pTextsW;
455 const bool isHorizontalAxis
456 = (KDChartAxisParams::AxisPosBottom == cv.basicPos) ||
457 (KDChartAxisParams::AxisPosTop == cv.basicPos);
459 TQStringList* labelTexts = ( TQStringList* ) para.axisLabelTexts();
460 uint nLabels = ( 0 != labelTexts )
461 ? labelTexts->count()
464 TQPoint p1( cv.orig );
466 TQPoint p2( cv.orig );
468 TQPoint p2a( cv.orig );
470 TQPoint pGA( cv.orig );
472 TQPoint pGZ( cv.orig );
475 double axisZeroLineStartX = p1.x();
476 double axisZeroLineStartY = p1.y();
478 p2.setX( p2.x() + static_cast < int > ( cv.pXDelimDeltaFaktor * delimLen ) );
479 p2.setY( p2.y() + static_cast < int > ( cv.pYDelimDeltaFaktor * delimLen ) );
480 p2a.setX( p2a.x() + static_cast < int > ( cv.pXDelimDeltaFaktor * delimLen * 2.0 / 3.0 ) );
481 p2a.setY( p2a.y() + static_cast < int > ( cv.pYDelimDeltaFaktor * delimLen * 2.0 / 3.0 ) );
482 pGZ.setX( pGZ.x() - static_cast < int > ( cv.pXDelimDeltaFaktor * (_dataRect.width() - 1) ) );
483 pGZ.setY( pGZ.y() - static_cast < int > ( cv.pYDelimDeltaFaktor * (_dataRect.height() - 1) ) );
488 const bool oldClippingFlag = painter->hasClipping();
489 painter->setClipping( false );
491 if( para.hasAxisFirstLabelText() )
492 labelTexts->first() = para.axisFirstLabelText();
493 if( para.hasAxisLastLabelText() )
494 labelTexts->last() = para.axisLastLabelText();
496 const double pXDelta = cv.pXDeltaFactor * cv.pDelimDelta;
497 const double pYDelta = cv.pYDeltaFactor * cv.pDelimDelta;
503 const TQString formatDT = cv.isDateTime
508 const double minTextHeight = para.axisLabelsFontMinSize();
510 if ( minTextHeight > cv.nTxtHeight )
511 cv.nTxtHeight = minTextHeight;
514 actFont.setPixelSize( static_cast < int > ( cv.nTxtHeight ) );
516 painter->setFont( actFont );
517 TQFontMetrics fm( painter->fontMetrics() );
524 TQString commonDtHeader;
525 if( cv.autoDtLabels ){
526 cv.textAlign = TQt::AlignCenter;
529 const TQDate& dLow = cv.dtLow.date();
530 const TQTime& tLow = cv.dtLow.time();
531 const TQDate& dHigh = cv.dtHigh.date();
532 const TQTime& tHigh = cv.dtHigh.time();
533 bool sameYear = dLow.year() == dHigh.year();
534 bool sameMonth = sameYear && (dLow.month() == dHigh.month() );
535 bool sameDay = sameMonth && (dLow.day() == dHigh.day() );
536 bool sameHour = sameDay && (tLow.hour() == tHigh.hour() );
537 bool sameMinute = sameHour && (tLow.minute() == tHigh.minute());
538 bool sameSecond = sameMinute && (tLow.second() == tHigh.second());
540 commonDtHeader = TQString::number( dLow.day() )
542 + TQDate::longMonthName( dLow.month() )
544 + TQString::number( dLow.year() );
546 commonDtHeader += " / "
547 + TQString::number( tLow.hour() )
550 if( 10 > tLow.minute() )
551 commonDtHeader += '0';
552 commonDtHeader += TQString::number( tLow.minute() )
555 if( 10 > tLow.second() )
556 commonDtHeader += '0';
557 commonDtHeader += TQString::number( tLow.second() );
569 commonDtHeader += "00";
572 commonDtHeader += "00";
574 } else if( sameMonth )
575 commonDtHeader = TQDate::longMonthName( dLow.month() )
577 + TQString::number( dLow.year() );
579 commonDtHeader = TQString::number( dLow.year() );
586 TQRegion unitedRegions;
588 const bool tryLeavingOut =
591 if( tryLeavingOut ) {
601 int stepWidthLeaveOut = nLeaveOut+1;
602 int iStepsLeaveOut = 0;
605 const double nInitialTxtHeight = cv.nTxtHeight;
607 const bool tryRotating = isHorizontalAxis
613 nRotation = nInitialRotation;
615 bool textsDontFitIntoArea;
616 bool textsOverlapping;
619 textsDontFitIntoArea = false;
620 textsOverlapping = false;
621 textsMatching = true;
623 unitedRegions = TQRegion();
624 int align = nRotation
625 ? (TQt::AlignRight | TQt::AlignVCenter)
627 TQPoint anchor(200,200);
630 for ( TQStringList::Iterator it = labelTexts->begin();
631 it != labelTexts->end();
634 if( iLeaveOut < nLeaveOut ) {
638 anchor.setX( p2.x() + static_cast < int > ( pXDelta * (iLabel - 0.5) ) );
639 anchor.setY( p2.y() + static_cast < int > ( pYDelta * (iLabel - 0.5) ) );
642 anchor = painter->worldMatrix().map( anchor );
646 TQDateTime dt( TQDateTime::fromString( *it,
648 text = dt.toString( formatDT );
652 KDDrawTextRegionAndTrueRect infosKDD =
653 KDDrawText::measureRotatedText( painter,
663 if( infosKDD.region.boundingRect().left()
664 < params()->globalLeadingLeft()+1 ){
665 textsMatching = false;
666 textsDontFitIntoArea = true;
673 sectReg = infosKDD.region.intersect( unitedRegions );
676 TQRect rect( infosKDD.region.boundingRect() );
677 rect.addCoords(-2,-2,2,2);
678 TQRegion biggerRegion( rect );
679 sectReg = biggerRegion.intersect( unitedRegions );
681 if ( sectReg.isEmpty() )
682 unitedRegions = unitedRegions.unite( infosKDD.region );
684 textsMatching = false;
685 textsOverlapping = true;
700 if( isHorizontalAxis ) {
701 if( nUsableAxisHeight < unitedRegions.boundingRect().height() ){
703 textsDontFitIntoArea = true;
706 if( nUsableAxisWidth < unitedRegions.boundingRect().width() ){
708 textsMatching = false;
709 textsDontFitIntoArea = true;
721 if( !textsMatching ) {
722 bool rotatingDoesNotHelp = false;
732 if( textsDontFitIntoArea ){
733 if( nRotation != nInitialRotation ){
735 nRotation = nInitialRotation;
737 rotatingDoesNotHelp = true;
742 if( 270 < nRotation ) {
744 if( 270 > nRotation )
747 if( nInitialRotation )
748 nRotation = nInitialRotation;
751 rotatingDoesNotHelp = true;
755 if( nInitialRotation )
756 nRotation = nInitialRotation;
762 if ( !tryRotating || rotatingDoesNotHelp ) {
767 if ( tryShrinking && (minTextHeight < cv.nTxtHeight) ) {
769 cv.nTxtHeight -= 1.0;
770 if ( minTextHeight > cv.nTxtHeight )
771 cv.nTxtHeight = minTextHeight;
779 && (nLeaveOut+1 < static_cast < int > ( nLabels ) ) ) {
784 iStepsLeaveOut*stepWidthLeaveOut - 1;
786 cv.nTxtHeight = nInitialTxtHeight;
792 actFont.setPixelSize( static_cast < int > ( cv.nTxtHeight ) );
794 painter->setFont( actFont );
795 fm = painter->fontMetrics();
800 } while( !textsMatching );
809 cv.textAlign = TQt::AlignRight | TQt::AlignVCenter;
813 double dx = (pXDelta / 2) - (cv.nTxtHeight / 4);
814 double dy = (cv.nTxtHeight / 2.0);
834 painter->setFont( actFont );
835 fm = TQFontMetrics( painter->fontMetrics() );
838 TQPen gridPen, leaveOutGridPen;
842 const int pXDeltaDiv2 = static_cast < int > ( pXDelta / 2.0 );
843 const int pYDeltaDiv2 = static_cast < int > ( pYDelta / 2.0 );
845 bool bDrawAdditionalSubGridLine = false;
846 double pGXMicroAdjust = 0.0;
847 double pGYMicroAdjust = 0.0;
848 if ( !bTouchEdges ) {
850 p1.setX( p1.x() + pXDeltaDiv2 );
851 p1.setY( p1.y() + pYDeltaDiv2 );
852 p2.setX( p2.x() + pXDeltaDiv2 );
853 p2.setY( p2.y() + pYDeltaDiv2 );
855 p2a.setX( p2a.x() + pXDeltaDiv2 );
856 p2a.setY( p2a.y() + pYDeltaDiv2 );
858 bDrawAdditionalSubGridLine =
859 isHorizontalAxis && !
863 pGA.setX( pGA.x() + pXDeltaDiv2 );
864 pGA.setY( pGA.y() + pYDeltaDiv2 );
865 pGZ.setX( pGZ.x() + pXDeltaDiv2 );
866 pGZ.setY( pGZ.y() + pYDeltaDiv2 );
868 if( KDChartAxisParams::AxisTypeNORTH == para. axisType() ) {
869 pGXMicroAdjust = cv.pXDeltaFactor * lineWidth / 2.0;
870 pGYMicroAdjust = cv.pYDeltaFactor * lineWidth / 2.0;
873 double x1, y1, x2, y2, xGA, yGA, xGZ, yGZ,
874 p1X, p1Y, p2X, p2Y, pGAX, pGAY, pGZX, pGZY, xT, yT;
876 double pXSubDelimDelta = pXDelta * cv.nSubDelimFactor;
877 double pYSubDelimDelta = pYDelta * cv.nSubDelimFactor;
879 if ( !cv.autoDtLabels
880 && 0.0 != cv.nSubDelimFactor
884 TQPen pen( para. axisLineColor(), static_cast < int > ( 0.5 * lineWidth ) );
885 uint penWidth = pen.width();
888 if( cv.bLogarithmic )
889 cv.nSubDelimFactor = 0.1;
891 while ( fabs( ( pXDelta + pYDelta ) * cv.nSubDelimFactor / 6.0 )
894 if ( 0 < penWidth ) {
896 pen.setWidth( penWidth );
898 if( cv.bLogarithmic ){
902 if ( 0.5 != cv.nSubDelimFactor ) {
904 cv.nSubDelimFactor = 0.5;
906 pXSubDelimDelta = pXDelta * cv.nSubDelimFactor;
907 pYSubDelimDelta = pYDelta * cv.nSubDelimFactor;
932 const TQPen oldGridPen( gridPen );
935 gridPen.setWidth( gridSubLineWidth );
938 const TQPen oldPen( painter->pen() );
939 painter->setPen( pen );
940 double nSubDelim = ( labelTexts->count() - 1 )
941 / cv.nSubDelimFactor;
944 modf( nSubDelim, &nSubDelim );
947 double xLogarithOffs = 0;
948 double yLogarithOffs = 0;
950 double mainDelim = 0.0;
953 for ( double iDelim = 1.0;
954 iDelim <= nSubDelim + 1.0;
955 iDelim += 1.0, logarithCnt++ ) {
957 if ( mainDelim > 0.0 )
962 if ( cv.bLogarithmic )
964 if ( logarithCnt == 11 )
967 pXDelta * log10( 10*cv.nSubDelimFactor*10 );
969 pYDelta * log10( 10*cv.nSubDelimFactor*10 );
974 pXDelta * log10( 10*cv.nSubDelimFactor*logarithCnt );
976 pYDelta * log10( 10*cv.nSubDelimFactor*logarithCnt );
981 if( 0.0 != modf((iDelim-1.0) * cv.nSubDelimFactor, &dDummy) )
983 saveDrawLine( *painter,
984 TQPoint( static_cast<int>( pGAX - pGXMicroAdjust ),
985 static_cast<int>( pGAY - pGYMicroAdjust ) ),
986 TQPoint( static_cast<int>( pGZX - pGXMicroAdjust ),
987 static_cast<int>( pGZY - pGYMicroAdjust ) ),
990 if( cv.bLogarithmic ){
991 pGAX = xGA + pXSubDelimDelta + xLogarithOffs;
992 pGAY = yGA + pYSubDelimDelta + yLogarithOffs;
993 pGZX = xGZ + pXSubDelimDelta + xLogarithOffs;
994 pGZY = yGZ + pYSubDelimDelta + yLogarithOffs;
996 pGAX = xGA + iDelim * pXSubDelimDelta;
997 pGAY = yGA + iDelim * pYSubDelimDelta;
998 pGZX = xGZ + iDelim * pXSubDelimDelta;
999 pGZY = yGZ + iDelim * pYSubDelimDelta;
1016 painter->drawLine( TQPoint( static_cast<int>( p1X ), static_cast<int>( p1Y ) ),
1017 TQPoint( static_cast<int>( p2X ), static_cast<int>( p2Y ) ) );
1022 if( cv.bLogarithmic ){
1023 p1X = x1 + pXSubDelimDelta + xLogarithOffs;
1024 p1Y = y1 + pYSubDelimDelta + yLogarithOffs;
1025 p2X = x2 + pXSubDelimDelta + xLogarithOffs;
1026 p2Y = y2 + pYSubDelimDelta + yLogarithOffs;
1028 p1X = x1 + iDelim * pXSubDelimDelta;
1029 p1Y = y1 + iDelim * pYSubDelimDelta;
1030 p2X = x2 + iDelim * pXSubDelimDelta;
1031 p2Y = y2 + iDelim * pYSubDelimDelta;
1034 if ( mainDelim >= nSubDelim/(labelTexts->count() -1) )
1040 if( bDrawAdditionalSubGridLine
1043 saveDrawLine( *painter,
1044 TQPoint( static_cast<int>( pGAX - pGXMicroAdjust ),
1045 static_cast<int>( pGAY - pGYMicroAdjust ) ),
1046 TQPoint( static_cast<int>( pGZX - pGXMicroAdjust ),
1047 static_cast<int>( pGZY - pGYMicroAdjust ) ),
1051 painter->setPen( oldPen );
1052 gridPen = oldGridPen;
1075 gridPen.setWidth( gridLineWidth );
1079 saveDrawLine( *painter, cv.orig, cv.dest, gridPen );
1082 leaveOutGridPen = gridPen;
1083 leaveOutGridPen.setWidth( gridLineWidth / 2 );
1084 leaveOutGridPen.setStyle( TQt::DotLine );
1090 double iLabel = 0.0;
1091 if( cv.autoDtLabels )
1109 int pXD = static_cast <int> (cv.pXDelimDeltaFaktor * 1.25 * (cv.nTxtHeight+4));
1110 int pYD = static_cast <int> (cv.pYDelimDeltaFaktor * 1.25 * (cv.nTxtHeight+4));
1113 cv.pTextsW = fabs( (0.0 == pXDelta) ? pXD : pXDelta );
1114 cv.pTextsH = fabs( (0.0 == pYDelta) ? pYD : pYDelta );
1118 bool secPaint= false;
1121 bool minPaint= false;
1124 bool hourPaint= false;
1127 bool dayPaint= false;
1133 double pMonthX = x1;
1134 double pMonthY = y1;
1135 bool monthPaint= false;
1142 bool yearPaint= false;
1144 double pXYDelta = fabs( pXDelta ) + fabs( pYDelta );
1147 ( ( KDChartAxisParams& ) para ).setTrueAxisDeltaPixels( TQMIN(_logicalWidth, _logicalHeight) / 150 );
1149 bool dtGoDown = cv.dtLow > cv.dtHigh;
1150 int mult = dtGoDown ? -1 : 1;
1151 const TQDateTime& startDt = dtGoDown ? cv.dtHigh : cv.dtLow;
1158 int gridDX = pGZ.x() - pGA.x();
1159 int gridDY = pGZ.y() - pGA.y();
1162 gridPen.setWidth( gridLineWidth );
1165 TQPen subGridPen( gridPen.color(), 1, para. axisGridStyle() );
1167 TQPen pen = subGridPen;
1169 TQDateTime dt( startDt );
1170 TQDateTime newDt( startDt );
1171 for( uint i=1; i <= nLabels; ++i ){
1172 switch( cv.dtDeltaScale ) {
1173 case KDChartAxisParams::ValueScaleSecond:
1174 dtAddSecs( dt, 1 * mult, newDt );
1176 case KDChartAxisParams::ValueScaleMinute:
1177 dtAddSecs( dt, 60 * mult, newDt );
1179 case KDChartAxisParams::ValueScaleHour:
1180 dtAddSecs( dt, 3600 * mult, newDt );
1182 case KDChartAxisParams::ValueScaleDay:
1183 dtAddDays( dt, 1 * mult, newDt );
1185 case KDChartAxisParams::ValueScaleWeek:
1186 dtAddDays( dt, 7 * mult, newDt );
1188 case KDChartAxisParams::ValueScaleMonth:
1189 dtAddMonths( dt,1 * mult, newDt );
1191 case KDChartAxisParams::ValueScaleQuarter:
1192 dtAddMonths( dt,3 * mult, newDt );
1194 case KDChartAxisParams::ValueScaleYear:
1195 dtAddYears( dt, 1 * mult, newDt );
1198 dtAddDays( dt, 1 * mult, newDt );
1201 const TQDateTime& testDt
1203 ? ( ( newDt < cv.dtLow )
1206 : ( ( newDt > cv.dtHigh )
1217 bool endLoop = (i == nLabels) || (&testDt != &newDt);
1219 secPaint = ( KDChartAxisParams::ValueScaleSecond >= cv.dtDeltaScale ) &&
1220 ( testDt.time().second() != dt.time().second() ||
1221 ( endLoop && ((pSecX != x1) || (pSecY != y1))));
1222 minPaint = ( KDChartAxisParams::ValueScaleMinute >= cv.dtDeltaScale ) &&
1223 ( testDt.time().minute() != dt.time().minute() ||
1224 ( endLoop && ((pMinX != x1) || (pMinY != y1))));
1225 hourPaint = ( KDChartAxisParams::ValueScaleHour >= cv.dtDeltaScale ) &&
1226 ( testDt.time().hour() != dt.time().hour() ||
1227 ( endLoop && ((pHourX != x1) || (pHourY != y1))));
1228 dayPaint = ( KDChartAxisParams::ValueScaleDay >= cv.dtDeltaScale ) &&
1229 ( testDt.date().day() != dt.date().day() ||
1230 ( endLoop && ((pDayX != x1) || (pDayY != y1))));
1236 monthPaint = ( KDChartAxisParams::ValueScaleMonth >= cv.dtDeltaScale ) &&
1237 ( testDt.date().month() != dt.date().month() ||
1238 ( endLoop && ((pMonthX != x1) || (pMonthY != y1))));
1239 yearPaint = ( KDChartAxisParams::ValueScaleYear >= cv.dtDeltaScale ) &&
1240 ( testDt.date().year() != dt.date().year() ||
1241 ( endLoop && ((pYearX != x1) || (pYearY != y1))));
1243 p1X = x1 + iLabel * pXDelta;
1244 p1Y = y1 + iLabel * pYDelta;
1245 p2X = p1X + pXDelta;
1246 p2Y = p1Y + pYDelta;
1273 painter->drawLine( TQPoint( static_cast<int>( pSecX+pXD ),
1274 static_cast<int>( pSecY+pYD ) ),
1275 TQPoint( static_cast<int>( p2X + pXD ),
1276 static_cast<int>( p2Y + pYD ) ) );
1277 if( (pXDelta/2.0 < p2X - pSecX) || (pYDelta/2.0 < p2Y - pSecY) ){
1278 TQPen oldPen( painter->pen() );
1279 painter->setPen( TQPen( labelsColor ) );
1280 painter->drawText( static_cast<int>( pSecX+pXD-orgXD ),
1281 static_cast<int>( pSecY+pYD-orgYD ),
1282 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pSecX))),
1283 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pSecY))),
1284 cv.textAlign | TQt::DontClip,
1285 TQString::number( dt.time().second() ) );
1286 painter->setPen( oldPen );
1289 saveDrawLine( *painter,
1290 TQPoint( static_cast<int>( pSecX ),
1291 static_cast<int>( pSecY ) ),
1292 TQPoint( static_cast<int>( pSecX + gridDX ),
1293 static_cast<int>( pSecY + gridDY ) ),
1297 if( !minPaint || pMinX != pSecX || pMinY != pSecY ){
1298 painter->drawLine( TQPoint( static_cast<int>( pSecX ),
1299 static_cast<int>( pSecY ) ),
1300 TQPoint( static_cast<int>( pSecX+pXD ),
1301 static_cast<int>( pSecY+pYD ) ) );
1304 if( endLoop && !minPaint )
1305 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1306 static_cast<int>( p2Y ) ),
1307 TQPoint( static_cast<int>( p2X+pXD ),
1308 static_cast<int>( p2Y+pYD ) ) );
1309 pSecX = p1X + pXDelta;
1310 pSecY = p1Y + pYDelta;
1315 painter->drawLine( TQPoint( static_cast<int>( pMinX+pXD ),
1316 static_cast<int>( pMinY+pYD ) ),
1317 TQPoint( static_cast<int>( p2X + pXD ),
1318 static_cast<int>( p2Y + pYD ) ) );
1319 if( (pXDelta/2.0 < p2X - pMinX) || (pYDelta/2.0 < p2Y - pMinY) ){
1320 TQPen oldPen( painter->pen() );
1321 painter->setPen( TQPen( labelsColor ) );
1322 painter->drawText( static_cast<int>( pMinX+pXD-orgXD ),
1323 static_cast<int>( pMinY+pYD-orgYD ),
1324 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pMinX)) ),
1325 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pMinY)) ),
1326 cv.textAlign | TQt::DontClip,
1327 TQString::number( dt.time().minute() ) );
1328 painter->setPen( oldPen );
1330 if( !secPaint && 10 < pXYDelta ){
1331 saveDrawLine( *painter,
1332 TQPoint( static_cast<int>( pMinX+pXDelta/2 ),
1333 static_cast<int>( pMinY+pYDelta/2 ) ),
1334 TQPoint( static_cast<int>( pMinX+pXDelta/2 + gridDX ),
1335 static_cast<int>( pMinY+pYDelta/2 + gridDY ) ),
1338 saveDrawLine( *painter,
1339 TQPoint( static_cast<int>( pMinX ),
1340 static_cast<int>( pMinY ) ),
1341 TQPoint( static_cast<int>( pMinX + gridDX ),
1342 static_cast<int>( pMinY + gridDY ) ),
1346 if( !hourPaint || pHourX != pMinX || pHourY != pMinY ){
1347 painter->drawLine( TQPoint( static_cast<int>( pMinX ),
1348 static_cast<int>( pMinY ) ),
1349 TQPoint( static_cast<int>( pMinX+pXD ),
1350 static_cast<int>( pMinY+pYD ) ) );
1353 if( endLoop && !hourPaint )
1354 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1355 static_cast<int>( p2Y ) ),
1356 TQPoint( static_cast<int>( p2X+pXD ),
1357 static_cast<int>( p2Y+pYD ) ) );
1358 pMinX = p1X + pXDelta;
1359 pMinY = p1Y + pYDelta;
1364 painter->drawLine( TQPoint( static_cast<int>( pHourX+pXD ),
1365 static_cast<int>( pHourY+pYD ) ),
1366 TQPoint( static_cast<int>( p2X + pXD ),
1367 static_cast<int>( p2Y + pYD ) ) );
1373 if( (pXDelta/2.0 < p2X - pHourX) || (pYDelta/2.0 < p2Y - pHourY) ){
1382 TQPen oldPen( painter->pen() );
1383 painter->setPen( TQPen( labelsColor ) );
1384 painter->drawText( static_cast<int>( pHourX+pXD-orgXD ),
1385 static_cast<int>( pHourY+pYD-orgYD ),
1386 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pHourX))),
1387 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pHourY))),
1388 cv.textAlign | TQt::DontClip,
1389 TQString::number( dt.time().hour() ) );
1390 painter->setPen( oldPen );
1392 if( !minPaint && 10 < pXYDelta ){
1393 saveDrawLine( *painter,
1394 TQPoint( static_cast<int>( pHourX+pXDelta/2 ),
1395 static_cast<int>( pHourY+pYDelta/2 ) ),
1396 TQPoint( static_cast<int>( pHourX+pXDelta/2 + gridDX ),
1397 static_cast<int>( pHourY+pYDelta/2 + gridDY ) ),
1400 saveDrawLine( *painter,
1401 TQPoint( static_cast<int>( pHourX ),
1402 static_cast<int>( pHourY ) ),
1403 TQPoint( static_cast<int>( pHourX + gridDX ),
1404 static_cast<int>( pHourY + gridDY ) ),
1408 if( !dayPaint || pDayX != pHourX || pDayY != pHourY ){
1409 painter->drawLine( TQPoint( static_cast<int>( pHourX ),
1410 static_cast<int>( pHourY ) ),
1411 TQPoint( static_cast<int>( pHourX+pXD ),
1412 static_cast<int>( pHourY+pYD ) ) );
1415 if( endLoop && !dayPaint )
1416 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1417 static_cast<int>( p2Y ) ),
1418 TQPoint( static_cast<int>( p2X+pXD ),
1419 static_cast<int>( p2Y+pYD ) ) );
1420 pHourX = p1X + pXDelta;
1421 pHourY = p1Y + pYDelta;
1426 painter->drawLine( TQPoint( static_cast<int>( pDayX+pXD ),
1427 static_cast<int>( pDayY+pYD ) ),
1428 TQPoint( static_cast<int>( p2X + pXD ),
1429 static_cast<int>( p2Y + pYD ) ) );
1430 if( (pXDelta/2.0 < p2X - pDayX) || (pYDelta/2.0 < p2Y - pDayY) ){
1431 TQPen oldPen( painter->pen() );
1432 painter->setPen( TQPen( labelsColor ) );
1433 painter->drawText( static_cast<int>( pDayX+pXD-orgXD ),
1434 static_cast<int>( pDayY+pYD-orgYD ),
1435 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pDayX)) ),
1436 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pDayY)) ),
1437 cv.textAlign | TQt::DontClip,
1438 TQString::number( dt.date().day() ) );
1439 painter->setPen( oldPen );
1444 if( !hourPaint && 10 < pXYDelta ){
1445 saveDrawLine( *painter,
1446 TQPoint( static_cast<int>( pDayX+pXDelta/2 ),
1447 static_cast<int>( pDayY+pYDelta/2 ) ),
1448 TQPoint( static_cast<int>( pDayX+pXDelta/2 + gridDX ),
1449 static_cast<int>( pDayY+pYDelta/2 + gridDY ) ),
1452 saveDrawLine( *painter,
1453 TQPoint( static_cast<int>( pDayX ),
1454 static_cast<int>( pDayY ) ),
1455 TQPoint( static_cast<int>( pDayX + gridDX ),
1456 static_cast<int>( pDayY + gridDY ) ),
1460 if( !monthPaint || pMonthX != pDayX || pMonthY != pDayY ){
1461 painter->drawLine( TQPoint( static_cast<int>( pDayX ),
1462 static_cast<int>( pDayY ) ),
1463 TQPoint( static_cast<int>( pDayX+pXD ),
1464 static_cast<int>( pDayY+pYD ) ) );
1470 if( endLoop && !monthPaint )
1471 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1472 static_cast<int>( p2Y ) ),
1473 TQPoint( static_cast<int>( p2X+pXD ),
1474 static_cast<int>( p2Y+pYD ) ) );
1475 pDayX = p1X + pXDelta;
1476 pDayY = p1Y + pYDelta;
1524 painter->drawLine( TQPoint( static_cast<int>( pMonthX+pXD ),
1525 static_cast<int>( pMonthY+pYD ) ),
1526 TQPoint( static_cast<int>( p2X + pXD ),
1527 static_cast<int>( p2Y + pYD ) ) );
1528 if( (pXDelta/2.0 < p2X - pMonthX) || (pYDelta/2.0 < p2Y - pMonthY) ){
1529 TQPen oldPen( painter->pen() );
1530 painter->setPen( TQPen( labelsColor ) );
1531 painter->drawText( static_cast<int>( pMonthX+pXD-orgXD ),
1532 static_cast<int>( pMonthY+pYD-orgYD ),
1533 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pMonthX)) ),
1534 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pMonthY)) ),
1535 cv.textAlign | TQt::DontClip,
1536 TQString::number( dt.date().month() ) );
1537 painter->setPen( oldPen );
1550 saveDrawLine( *painter,
1551 TQPoint( static_cast<int>( pMonthX ),
1552 static_cast<int>( pMonthY ) ),
1553 TQPoint( static_cast<int>( pMonthX + gridDX ),
1554 static_cast<int>( pMonthY + gridDY ) ),
1558 if( !yearPaint || pYearX != pMonthX || pYearY != pMonthY ){
1559 painter->drawLine( TQPoint( static_cast<int>( pMonthX ),
1560 static_cast<int>( pMonthY ) ),
1561 TQPoint( static_cast<int>( pMonthX+pXD ),
1562 static_cast<int>( pMonthY+pYD ) ) );
1565 if( endLoop && !yearPaint )
1566 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1567 static_cast<int>( p2Y ) ),
1568 TQPoint( static_cast<int>( p2X+pXD ),
1569 static_cast<int>( p2Y+pYD ) ) );
1570 pMonthX = p1X + pXDelta;
1571 pMonthY = p1Y + pYDelta;
1576 painter->drawLine( TQPoint( static_cast<int>( pYearX+pXD ),
1577 static_cast<int>( pYearY+pYD ) ),
1578 TQPoint( static_cast<int>( p2X + pXD ),
1579 static_cast<int>( p2Y + pYD ) ) );
1580 if( (pXDelta/2.0 < p2X - pYearX) || (pYDelta/2.0 < p2Y - pYearY) ){
1581 TQPen oldPen( painter->pen() );
1582 painter->setPen( TQPen( labelsColor ) );
1583 painter->drawText( static_cast<int>( pYearX+pXD-orgXD ),
1584 static_cast<int>( pYearY+pYD-orgYD ),
1585 static_cast<int>( fabs((0.0 == pXDelta) ? cv.pTextsW : (p2X - pYearX)) ),
1586 static_cast<int>( fabs((0.0 == pYDelta) ? cv.pTextsH : (p2Y - pYearY)) ),
1587 cv.textAlign | TQt::DontClip,
1588 TQString::number( dt.date().year() ) );
1589 painter->setPen( oldPen );
1591 if( !monthPaint && 10 < pXYDelta ){
1592 saveDrawLine( *painter,
1593 TQPoint( static_cast<int>( pYearX+pXDelta/2 ),
1594 static_cast<int>( pYearY+pYDelta/2 ) ),
1595 TQPoint( static_cast<int>( pYearX+pXDelta/2 + gridDX ),
1596 static_cast<int>( pYearY+pYDelta/2 + gridDY ) ),
1599 saveDrawLine( *painter,
1600 TQPoint( static_cast<int>( pYearX ),
1601 static_cast<int>( pYearY ) ),
1602 TQPoint( static_cast<int>( pYearX + gridDX ),
1603 static_cast<int>( pYearY + gridDY ) ),
1607 painter->drawLine( TQPoint( static_cast<int>( pYearX ),
1608 static_cast<int>( pYearY ) ),
1609 TQPoint( static_cast<int>( pYearX+pXD ),
1610 static_cast<int>( pYearY+pYD ) ) );
1613 painter->drawLine( TQPoint( static_cast<int>( p2X ),
1614 static_cast<int>( p2Y ) ),
1615 TQPoint( static_cast<int>( p2X+pXD ),
1616 static_cast<int>( p2Y+pYD ) ) );
1617 pYearX = p1X + pXDelta;
1618 pYearY = p1Y + pYDelta;
1622 if( &testDt != &newDt )
1627 if( !commonDtHeader.isEmpty() ){
1628 TQPen oldPen( painter->pen() );
1629 painter->setPen( TQPen( labelsColor ) );
1630 painter->drawText( static_cast<int>( x1 + pXD ), static_cast<int>( y1 + pYD ),
1632 painter->setPen( oldPen );
1635 int iLeaveOut = nLeaveOut;
1637 for ( TQStringList::Iterator labelIter = labelTexts->begin();
1638 labelIter != labelTexts->end();
1641 if( cv.isDateTime ){
1642 dt = TQDateTime::fromString( *labelIter,
1644 label = dt.toString( formatDT );
1649 if( iLeaveOut < nLeaveOut )
1657 bool showDelim = para.axisShowFractionalValuesDelimiters();
1659 if ( !label.isNull() || showDelim ){
1663 saveDrawLine( *painter,
1664 TQPoint( static_cast<int>( pGAX - pGXMicroAdjust ),
1665 static_cast<int>( pGAY - pGYMicroAdjust ) ),
1666 TQPoint( static_cast<int>( pGZX - pGXMicroAdjust ),
1667 static_cast<int>( pGZY - pGYMicroAdjust ) ),
1672 saveDrawLine( *painter,
1673 TQPoint( static_cast<int>( pGAX - pGXMicroAdjust ),
1674 static_cast<int>( pGAY - pGYMicroAdjust ) ),
1675 TQPoint( static_cast<int>( pGZX - pGXMicroAdjust ),
1676 static_cast<int>( pGZY - pGYMicroAdjust ) ),
1688 if ( !label.isNull() || showDelim )
1689 painter->drawLine( TQPoint( static_cast<int>( p1X ),
1690 static_cast<int>( p1Y ) ),
1691 TQPoint( static_cast<int>( p2X ),
1692 static_cast<int>( p2Y ) ) );
1696 TQPen oldPen( painter->pen() );
1697 painter->setPen( TQPen( labelsColor ) );
1700 && (TQt::AlignHCenter == (cv.textAlign & TQt::AlignHCenter)) ) {
1701 double w = fm.width( label ) + 4.0;
1702 double x0 = cv.pTextsX + cv.pTextsW / 2.0;
1704 painter->drawText( static_cast<int>( x0 - w / 2.0 ),
1705 static_cast<int>( cv.pTextsY ),
1706 static_cast<int>( w ),
1707 static_cast<int>( cv.pTextsH ),
1708 cv.textAlign, label );
1711 KDDrawText::drawRotatedText(
1714 painter->worldMatrix().map(
1715 TQPoint( static_cast<int>( cv.pTextsX ),
1716 static_cast<int>( cv.pTextsY ) ) ),
1722 screenOutput,screenOutput,0,
1726 painter->drawText( static_cast<int>( cv.pTextsX ),
1727 static_cast<int>( cv.pTextsY ),
1728 static_cast<int>( cv.pTextsW ),
1729 static_cast<int>( cv.pTextsH ),
1730 cv.textAlign | TQt::DontClip,
1742 painter->setPen( oldPen );
1747 if( cv.isDateTime ){
1748 if( labelTexts->begin() == labelIter ){
1750 pGAX - pGXMicroAdjust,
1751 pGAY - pGYMicroAdjust );
1756 pGAX - pGXMicroAdjust,
1757 pGAY - pGYMicroAdjust );
1764 p1X = x1 + iLabel * pXDelta;
1765 p1Y = y1 + iLabel * pYDelta;
1766 p2X = x2 + iLabel * pXDelta;
1767 p2Y = y2 + iLabel * pYDelta;
1768 cv.pTextsX = xT + iLabel * pXDelta;
1769 cv.pTextsY = yT + iLabel * pYDelta;
1771 pGAX = xGA + iLabel * pXDelta;
1772 pGAY = yGA + iLabel * pYDelta;
1773 pGZX = xGZ + iLabel * pXDelta;
1774 pGZY = yGZ + iLabel * pYDelta;
1786 if ( cv.bSteadyCalc &&
1794 if (cv.basicPos==KDChartAxisParams::AxisPosRight)
1795 x = static_cast<double>(_dataRect.right());
1797 x = static_cast<double>(_dataRect.left());
1800 x -= mult * pXDelta;
1801 y -= mult * pYDelta;
1802 axisZeroLineStartX = x;
1803 axisZeroLineStartY = y;
1808 painter->setClipping( oldClippingFlag );
1815 if ( cv.bSteadyCalc && !cv.isDateTime ) {
1816 ( ( KDChartAxisParams& ) para ).setAxisZeroLineStart( axisZeroLineStartX, axisZeroLineStartY );
1817 double axisZeroLineStart;
1818 int minCoord, maxCoord;
1819 double xFactor, yFactor;
1820 switch( cv.basicPos ){
1821 case KDChartAxisParams::AxisPosLeft:
1824 axisZeroLineStart = axisZeroLineStartY;
1825 minCoord = TQMIN( cv.orig.y(), cv.dest.y() );
1826 maxCoord = TQMAX( cv.orig.y(), cv.dest.y() );
1829 case KDChartAxisParams::AxisPosRight:
1832 axisZeroLineStart = axisZeroLineStartY;
1833 minCoord = TQMIN( cv.orig.y(), cv.dest.y() );
1834 maxCoord = TQMAX( cv.orig.y(), cv.dest.y() );
1836 case KDChartAxisParams::AxisPosTop:
1839 axisZeroLineStart = axisZeroLineStartX;
1840 minCoord = TQMIN( cv.orig.x(), cv.dest.x() );
1841 maxCoord = TQMAX( cv.orig.x(), cv.dest.x() );
1843 case KDChartAxisParams::AxisPosBottom:
1846 axisZeroLineStart = axisZeroLineStartX;
1847 minCoord = TQMIN( cv.orig.x(), cv.dest.x() );
1848 maxCoord = TQMAX( cv.orig.x(), cv.dest.x() );
1853 axisZeroLineStart = 0.0;
1857 if( axisZeroLineStart >= minCoord &&
1858 axisZeroLineStart <= maxCoord ){
1862 + xFactor * _dataRect.width() ),
1864 + yFactor * _dataRect.height() ) );
1866 saveDrawLine( *painter,
1910 internal__KDChart__CalcValues& cv = calcVal[iAxis];
1915 int x = cv.dest.x();
1916 if( 2.0 >= TQABS(cv.pLastX - x) )
1917 x = static_cast < int > ( cv.pLastX );
1918 int y = cv.dest.y();
1919 if( 2.0 >= TQABS(cv.pLastY - y) )
1920 y = static_cast < int > ( cv.pLastY );
1921 painter->drawLine( cv.orig, TQPoint(x,y) );
1929double fastPow10( int x )
1933 for( int i = 1; i <= x; ++i )
1936 for( int i = -1; i >= x; --i )
1941double fastPow10( double x )
1943 return pow(10.0, x);
1972 double averageValueP1000,
1975 KDChartAxisParams::AxisPos& basicPos,
1978 double& pXDeltaFactor,
1979 double& pYDeltaFactor,
1980 double& pXDelimDeltaFaktor,
1981 double& pYDelimDeltaFaktor,
1982 double& nSubDelimFactor,
1983 double& pDelimDelta,
1990 bool& isLogarithmic,
1995 KDChartAxisParams::ValueScale& dtDeltaScale,
1996 bool adjustTheValues,
1998 double trueDeltaPix )
2008 pXDeltaFactor = 0.0;
2009 pYDeltaFactor = 0.0;
2010 pXDelimDeltaFaktor = 0.0;
2011 pYDelimDeltaFaktor = 0.0;
2013 switch ( basicPos ) {
2014 case KDChartAxisParams::AxisPosBottom: {
2022 pYDelimDeltaFaktor = 1.0;
2023 pXDeltaFactor = bDecreasing ? -1.0 : 1.0;
2029 case KDChartAxisParams::AxisPosLeft: {
2037 pXDelimDeltaFaktor = -1.0;
2038 pYDeltaFactor = bDecreasing ? 1.0 : -1.0;
2041 case KDChartAxisParams::AxisPosTop: {
2049 pYDelimDeltaFaktor = -1.0;
2050 pXDeltaFactor = bDecreasing ? -1.0 : 1.0;
2053 case KDChartAxisParams::AxisPosRight: {
2061 pXDelimDeltaFaktor = 1.0;
2062 pYDeltaFactor = bDecreasing ? 1.0 : -1.0;
2067 tqDebug( "IMPLEMENTATION ERROR: KDChartAxesPainter::paintAxes() unhandled enum value." );
2073 uint dataset, dataset2, chart;
2074 if ( !params. axisDatasets( axisNumber, dataset, dataset2, chart ) ) {
2075 dataset = KDCHART_ALL_DATASETS;
2076 dataset2 = KDCHART_ALL_DATASETS;
2083 uint dataDataset, dataDataset2;
2085 KDChartParams::ExtraLinesAnchor,
2091 if( ( KDCHART_ALL_DATASETS != dataset
2092 && KDCHART_NO_DATASET != dataset )
2093 || ( KDCHART_ALL_DATASETS != dataDataset
2094 && KDCHART_NO_DATASET != dataDataset ) ){
2095 int ds = (KDCHART_ALL_DATASETS != dataset)
2098 int dds = (KDCHART_ALL_DATASETS != dataDataset)
2101 dataDataset = TQMAX( ds, dds );
2103 if( ( KDCHART_ALL_DATASETS != dataset2
2104 && KDCHART_NO_DATASET != dataset2 )
2105 || ( KDCHART_ALL_DATASETS != dataDataset2
2106 && KDCHART_NO_DATASET != dataDataset2 ) ){
2107 int ds2 = (KDCHART_ALL_DATASETS != dataset2)
2110 int dds2 = (KDCHART_ALL_DATASETS != dataDataset2)
2113 dataDataset2 = TQMIN( ds2, dds2 );
2118 tqDebug( "IMPLEMENTATION ERROR: findDatasets( DataEntry, ExtraLinesAnchor ) should *always* return true. (b)" );
2119 dataDataset = KDCHART_ALL_DATASETS;
2126 * averageValueP1000;
2130 nTxtHeight = info.pointSize();
2136 const int divPow10 = para.axisLabelsDivPow10();
2137 const TQString decimalPoint = para.axisLabelsDecimalPoint();
2138 const TQString thousandsPoint = para.axisLabelsThousandsPoint();
2139 const TQString prefix = para.axisLabelsPrefix();
2140 const TQString postfix = para.axisLabelsPostfix();
2141 const int totalLen = para.axisLabelsTotalLen();
2142 const TQChar padFill = para.axisLabelsPadFill();
2143 const bool blockAlign = para.axisLabelsBlockAlign();
2145 TQStringList labelTexts;
2148 switch ( para.axisLabelTextsFormDataRow() ) {
2149 case KDChartAxisParams::LabelsFromDataRowYes: {
2151 int trueBehindComma = -1;
2153 for ( uint iDataset = 0; iDataset < data. usedRows(); iDataset++ ) {
2154 if( data. cellCoord( iDataset, colNum, value, 1 ) ){
2155 if( TQVariant::String == value.type() )
2156 labelTexts.append( value.toString() );
2158 labelTexts.append( applyLabelsFormat( value.toDouble(),
2177 case KDChartAxisParams::LabelsFromDataRowGuess: {
2179 for ( uint iDataset = 0; iDataset < data. usedRows(); iDataset++ ) {
2180 if( data. cellCoord( iDataset, colNum, value, 1 ) ){
2181 if( TQVariant::String == value.type() ){
2182 const TQString sVal( value.toString() );
2183 if( !sVal.isEmpty() && !sVal.isNull() )
2184 labelTexts.append( sVal );
2194 case KDChartAxisParams::LabelsFromDataRowNo: {
2200 tqDebug( "KDChart: Unknown label texts source" );
2204 const bool dataCellsHaveSeveralCoordinates =
2205 (KDCHART_ALL_DATASETS == dataDataset)
2206 ? data.cellsHaveSeveralCoordinates()
2207 : data.cellsHaveSeveralCoordinates( dataDataset, dataDataset2 );
2215 para.axisLabelsDigitsBehindComma() );
2228 isLogarithmic = bSteadyCalc &&
2229 (KDChartParams::Line == params_chartType) &&
2230 (KDChartAxisParams::AxisCalcLogarithmic == para. axisCalcMode());
2236 const bool bVertAxis = (KDChartAxisParams::AxisPosLeft == basicPos) ||
2237 (KDChartAxisParams::AxisPosRight == basicPos);
2240 const int coordinate = bVertAxis ? 1 : 2;
2243 const TQVariant::Type valueType =
2244 (KDCHART_ALL_DATASETS == dataDataset)
2245 ? data.cellsValueType( coordinate )
2246 : data.cellsValueType( dataDataset, dataDataset2, coordinate );
2247 isDateTime = valueType == TQVariant::DateTime;
2248 bool bIsDouble = valueType == TQVariant::Double;
2253 if( autoDtLabels || bSteadyCalc )
2256 bool bStatistical = KDChartParams::HiLo == params_chartType
2257 || KDChartParams::BoxWhisker == params_chartType;
2259 if ( !bVertAxis && KDChartParams::BoxWhisker == params_chartType
2261 uint ds1 = (KDCHART_ALL_DATASETS == dataDataset)
2264 uint ds2 = (KDCHART_ALL_DATASETS == dataDataset)
2267 for (uint i = ds1; i <= ds2; ++i)
2269 TQObject::tr( "Series " ) + TQString::number( i + 1 ) );
2273 double nLow = 1.0 + bSteadyCalc;
2274 double nHigh = 10.0;
2275 double nDelta = 1.0;
2280 if ( ! isLogarithmic
2291 int trueBehindComma = -1;
2292 bool upwards = (nLow < nHigh);
2293 if( upwards != (0.0 < nDelta) )
2297 bool bShowVeryLastLabel = false;
2299 while( bShowVeryLastLabel || (upwards ? (nVal <= nHigh) : (nVal >= nHigh)) ){
2301 labelTexts.append( applyLabelsFormat( nVal,
2316 if( ! (upwards ? (nVal <= nHigh) : (nVal >= nHigh)) ){
2318 if( bShowVeryLastLabel )
2319 bShowVeryLastLabel = false;
2321 TQString sHigh( applyLabelsFormat( nHigh,
2334 TQString sValue( applyLabelsFormat( nVal,
2347 bShowVeryLastLabel = (sValue == sHigh);
2357 int nLabels = bSteadyCalc
2361 basicPos, orig, delimLen, nLabels,
2364 pTextsX, pTextsY, pTextsW, pTextsH,
2366 bool useShortLabels = false;
2374 const bool testStart = !( TQVariant::String == para. axisValueStart().type() );
2375 const bool testEnd = !( TQVariant::String == para. axisValueEnd().type() );
2376 TQString sStart = testStart
2379 TQString sEnd = testEnd
2384 for ( TQStringList::Iterator it = tmpList.begin();
2385 it != tmpList.end(); ++it, ++i ) {
2387 0 == TQString::compare( sStart, ( *it ).upper() ) ) {
2390 if ( 0 == TQString::compare( sEnd, ( *it ).upper() ) ) {
2399 && para.axisShortLabelsStringCount()
2403 font.setPixelSize( static_cast < int > ( nTxtHeight ) );
2404 painter->setFont( font );
2405 TQFontMetrics fm( painter->fontMetrics() );
2407 TQStringList::Iterator it = tmpList.begin();
2408 for ( int i = 0; i < nLabels; ++i ) {
2409 if ( it != tmpList.end() ) {
2410 if ( fm.width( *it ) > pTextsW ) {
2411 useShortLabels = true;
2418 if ( useShortLabels )
2428 modf( ddelta, &ddelta );
2429 bool positive = ( 0.0 <= ddelta );
2430 int delta = static_cast < int > ( fabs( ddelta ) );
2432 TQStringList::Iterator it = positive
2434 : tmpList.fromLast();
2436 for ( int i = 0; i < (int)tmpList.count(); ++i ) {
2442 for ( int i = tmpList.count() - 1; i >= 0; --i ) {
2449 int i2 = positive ? iStart : iEnd;
2450 for ( int iLabel = 0; iLabel < nLabels; ) {
2452 if ( it == tmpList.end() ) {
2453 it = tmpList.begin();
2457 if ( it == tmpList.begin() ) {
2459 i2 = tmpList.count();
2462 if ( ( positive && i2 >= iStart )
2463 || ( !positive && i2 <= iEnd ) ) {
2464 if ( meter >= delta ) {
2474 it = tmpList.begin();
2481 if ( i2 == iStart ) {
2483 i2 = tmpList.count();
2493 uint dset = ( dataset == KDCHART_ALL_DATASETS ) ? 0 : dataset;
2497 for ( uint col = 0; col < data. usedCols(); ++col ) {
2498 if( data. cellCoord( dset, col, value, coordinate ) ){
2499 if( TQVariant::String == value.type() ){
2500 const TQString sVal = value.toString();
2501 if( !sVal.isEmpty() && !sVal.isNull() ){
2502 labelTexts.append( sVal );
2530 if ( data. usedCols() && bSteadyCalc ) {
2534 double orgLow = 0.0;
2535 double orgHigh = 0.0;
2536 double nDelta = 0.0;
2540 enum { Normal, Stacked, Percent } mode;
2543 switch ( params_chartType ) {
2544 case KDChartParams::Bar:
2545 if ( KDChartParams::BarStacked
2548 else if ( KDChartParams::BarPercent
2554 case KDChartParams::Line:
2555 if ( KDChartParams::LineStacked
2558 else if ( KDChartParams::LinePercent
2564 case KDChartParams::Area:
2565 if ( KDChartParams::AreaStacked
2568 else if ( KDChartParams::AreaPercent
2574 case KDChartParams::HiLo:
2575 case KDChartParams::BoxWhisker:
2578 case KDChartParams::Polar:
2579 if ( KDChartParams::PolarStacked
2582 else if ( KDChartParams::PolarPercent
2590 tqDebug( "IMPLEMENTATION ERROR: Unknown params_chartType in calculateLabelTexts()" );
2600 bool bOrdFactorsOk = false;
2602 if( adjustTheValues ){
2603 nDelta = fabs( trueDelta );
2604 pDelimDelta = trueDeltaPix;
2607 double orgLow( nLow );
2608 modf( nLow / nDelta, &nLow );
2610 if ( nLow > orgLow )
2612 if ( 0.0 < nLow && 0.0 >= orgLow )
2615 double dx = fabs( pXDeltaFactor * pDelimDelta );
2616 double dy = fabs( pYDeltaFactor * pDelimDelta );
2626 } while( x < axisLength && y < axisLength );
2630 nDist = nHigh - nLow;
2631 bOrdFactorsOk = true;
2635 if( !bOrdFactorsOk ){
2636 const bool bAutoCalcStart =
2639 const bool bAutoCalcEnd =
2643 if( !bIsDouble && !isDateTime ){
2649 nSubDelimFactor = 0.5;
2651 bOrdFactorsOk = true;
2652 } else if( mode == Percent ){
2658 nSubDelimFactor = 0.25;
2659 bOrdFactorsOk = true;
2663 const bool bStackedMode = (mode == Stacked);
2664 if( bAutoCalcStart ){
2665 if ( dataDataset == KDCHART_ALL_DATASETS ) {
2668 ? TQMIN( data.minColSum(), 0.0 )
2669 : data.minValue( coordinate,
2674 dtLow = data.minDtValue( coordinate );
2679 ? TQMIN( data.minColSum( dataDataset, dataDataset2 ),
2681 : data.minInRows( dataDataset,dataDataset2,
2685 dtLow = data.minDtInRows( dataDataset,dataDataset2,
2701 if ( dataDataset == KDCHART_ALL_DATASETS ) {
2703 nHigh = bStackedMode
2704 ? TQMAX( data.maxColSum(), 0.0 )
2705 : data.maxValue( coordinate );
2707 dtHigh = data.maxDtValue( coordinate );
2711 nHigh = bStackedMode
2712 ? TQMAX( data.maxColSum( dataDataset, dataDataset2 ),
2714 : data.maxInRows( dataDataset,dataDataset2,
2717 dtHigh = data.maxDtInRows( dataDataset,dataDataset2,
2726 if( TQVariant::DateTime == para. axisValueEnd().type() )
2737 || ( ( 0.0 == nHigh || 0 == nHigh )
2738 && ( 0.0 == nLow || 0 == nLow ) ) ) {
2744 nSubDelimFactor = 0.5;
2745 bOrdFactorsOk = true;
2747 } else if( nLow == nHigh ){
2755 } else if( nHigh < nLow ){
2761 } else if( isDateTime ){
2762 bool toggleDts = dtLow > dtHigh;
2764 TQDateTime dt( dtLow );
2768 double secDist = dtLow.secsTo( dtHigh );
2769 secDist += (dtHigh.time().msec() - dtLow.time().msec()) / 1000.0;
2770 const double aDist = fabs( secDist );
2771 const double secMin = 60.0;
2772 const double secHour = 60.0 * secMin;
2773 const double secDay = 24.0 * secHour;
2782 const double secMonth = 30 * secDay;
2783 const double secYear = 12 * secMonth;
2784 if( 2.0*secMin > aDist )
2785 dtDeltaScale = KDChartAxisParams::ValueScaleSecond;
2786 else if( 2.0*secHour > aDist )
2787 dtDeltaScale = KDChartAxisParams::ValueScaleMinute;
2788 else if( 2.0*secDay > aDist )
2789 dtDeltaScale = KDChartAxisParams::ValueScaleHour;
2792 else if( 2.0*secMonth > aDist )
2793 dtDeltaScale = KDChartAxisParams::ValueScaleDay;
2796 else if( 2.0*secYear > aDist )
2797 dtDeltaScale = KDChartAxisParams::ValueScaleMonth;
2798 else if( 10.0*secYear > aDist )
2799 dtDeltaScale = KDChartAxisParams::ValueScaleQuarter;
2801 dtDeltaScale = KDChartAxisParams::ValueScaleYear;
2805 const int monthLow = dtLow.date().month();
2807 const int dayLow = dtLow.date().day();
2808 const int hourLow = dtLow.time().hour();
2809 const int minuteLow = dtLow.time().minute();
2810 const int secondLow = dtLow.time().second();
2813 const int monthHigh = dtHigh.date().month();
2815 const int hourHigh = dtHigh.time().hour();
2816 const int minuteHigh = dtHigh.time().minute();
2817 const int secondHigh = dtHigh.time().second();
2828 int minuteHighD = 0;
2829 int secondHighD = 0;
2830 bool gotoEndOfMonth = false;
2831 switch( dtDeltaScale ) {
2832 case KDChartAxisParams::ValueScaleSecond:
2835 secondLowD = secondLow % 5;
2836 if( secondHigh % 5 )
2837 secondHighD = 5 - secondHigh % 5;
2840 case KDChartAxisParams::ValueScaleMinute:
2842 secondLowD = secondLow;
2843 secondHighD = 59-secondHigh;
2845 case KDChartAxisParams::ValueScaleHour:
2847 minuteLowD = minuteLow;
2848 secondLowD = secondLow;
2849 minuteHighD = 59-minuteHigh;
2850 secondHighD = 59-secondHigh;
2852 case KDChartAxisParams::ValueScaleDay:
2855 minuteLowD = minuteLow;
2856 secondLowD = secondLow;
2857 hourHighD = 23-hourHigh;
2858 minuteHighD = 59-minuteHigh;
2859 secondHighD = 59-secondHigh;
2861 case KDChartAxisParams::ValueScaleWeek:
2873 case KDChartAxisParams::ValueScaleMonth:
2876 dayLowD = dayLow - 1;
2878 minuteLowD = minuteLow;
2879 secondLowD = secondLow;
2880 gotoEndOfMonth = true;
2882 case KDChartAxisParams::ValueScaleQuarter:
2884 monthLowD = ( monthLow - 1 ) % 3;
2887 minuteLowD = minuteLow;
2888 secondLowD = secondLow;
2889 if( ( monthHigh - 1 ) % 3 )
2890 monthHighD = 3 - ( monthHigh - 1 ) % 3;
2891 gotoEndOfMonth = true;
2893 case KDChartAxisParams::ValueScaleYear:
2895 monthLowD = monthLow;
2898 minuteLowD = minuteLow;
2899 secondLowD = secondLow;
2900 if( 12 > monthHigh )
2901 monthHighD = 12 - monthHigh;
2902 gotoEndOfMonth = true;
2908 dtLow = dtLow.addSecs( -1 * (secondLowD + 60*minuteLowD + 3600*hourLowD) );
2909 dtLow = dtLow.addDays( -1 * dayLowD );
2910 dtAddMonths( dtLow, -1 * monthLowD, dtLow );
2911 dtAddYears( dtLow, -1 * yearLowD, dtLow );
2912 dtHigh = dtHigh.addSecs( secondHighD + 60*minuteHighD + 3600* hourHighD );
2913 dtHigh = dtHigh.addDays( dayHighD );
2914 dtAddMonths( dtHigh, monthHighD, dtHigh );
2915 dtAddYears( dtHigh, yearHighD, dtHigh );
2916 if( gotoEndOfMonth ){
2917 dtHigh.setDate( TQDate( dtHigh.date().year(),
2918 dtHigh.date().month(),
2919 dtHigh.date().daysInMonth() ) );
2920 dtHigh.setTime( TQTime( 23, 59, 59 ) );
2923 TQDateTime dt( dtLow );
2931 nSubDelimFactor = 0.0;
2932 bOrdFactorsOk = true;
2936 if( !bOrdFactorsOk ) {
2939 nDist = nHigh - nLow;
2940 if( !isLogarithmic ){
2946 if( bAutoCalcStart ) {
2950 || maxEmpty > ( nLow / nHigh * 100.0 ) )
2952 else if( nDist / 100.0 < nLow )
2953 nLow -= nDist / 100.0;
2955 else if( nDist / 100.0 < fabs( nLow ) )
2956 nLow -= nDist / 100.0;
2957 nDist = nHigh - nLow;
2960 if( bAutoCalcEnd ) {
2964 || maxEmpty > ( nHigh / nLow * 100.0 ) )
2966 else if( nDist / 100.0 > nHigh )
2967 nHigh += nDist / 100.0;
2969 else if( nDist / 100.0 < fabs( nHigh ) )
2970 nHigh += nDist / 100.0;
2971 nDist = nHigh - nLow;
2978 if( isLogarithmic ){
2981 if( 0.0 == TQABS( nLow ) )
2985 nLow = log10( TQABS( nLow ) );
2990 nHigh = log10( TQABS( nHigh ) );
2994 double fractPart = modf( nLow, &intPart );
2996 if( 0.0 > nLow && 0.0 != fractPart )
2997 nLow = intPart - 1.0;
3000 fractPart = modf( nHigh, &intPart );
3001 if( 0.0 != fractPart )
3002 nHigh = intPart + 1.0;
3004 nDist = nHigh - nLow;
3006 nSubDelimFactor = 0.1;
3008 bOrdFactorsOk = true;
3013 if ( !bOrdFactorsOk ) {
3018 nDist = nHigh - nLow;
3024 nDist, nDivisor, nRound,
3025 nDelta, nSubDelimFactor,
3027 nLabels = params. roundVal( nDist / nDelta );
3048 nDist = nHigh - nLow;
3050 nLabels = params. roundVal( nDist / nDelta );
3071 double widthHeight = areaWidth / areaHeight;
3088 if ( widthHeight > 1.5 )
3089 orgHigh += nDelta * widthHeight;
3091 orgHigh += widthHeight * 0.5;
3098 bool bTryNext = false;
3103 nDist = nHigh - nLow;
3111 nDist, nDivisor, nRound,
3113 nSubDelimFactor, nLow, nHigh,
3115 nLabels = params. roundVal( nDist / nDelta );
3124 if( !bAutoCalcEnd && orgHigh > nLow + nLabels * nDelta ) {
3136 } while ( ( pass < 2 )
3137 || ( ( minLabels < nLabels )
3138 && ( areaHeight < ( nTxtHeight * 1.5 ) * nLabels ) ) );
3144 int trueBehindComma = -1;
3146 for ( uint i = 0; i < nLabels; ++i ) {
3147 if( isLogarithmic ) {
3148 labelTexts.append( applyLabelsFormat(
3149 fastPow10( static_cast < int > ( nVal ) ),
3163 labelTexts.append( applyLabelsFormat( nVal,
3184 nHigh = nVal - nDelta;
3190 bool goDown = dtLow > dtHigh;
3191 int mult = goDown ? -1 : 1;
3192 TQDateTime dt( dtLow );
3227 labelTexts.append( "x" );
3229 labelTexts.append( dt.toString( TQt::ISODate ) );
3230 bDone = (goDown ? (dt < dtLow ) : (dt > dtHigh));
3234 switch( dtDeltaScale ) {
3235 case KDChartAxisParams::ValueScaleSecond:
3236 dtAddSecs( dt, 1 * mult, dt );
3238 case KDChartAxisParams::ValueScaleMinute:
3239 dtAddSecs( dt, 60 * mult, dt );
3241 case KDChartAxisParams::ValueScaleHour:
3242 dtAddSecs( dt, 3600 * mult, dt );
3244 case KDChartAxisParams::ValueScaleDay:
3245 dtAddDays( dt, 1 * mult, dt );
3247 case KDChartAxisParams::ValueScaleWeek:
3248 dtAddDays( dt, 7 * mult, dt );
3250 case KDChartAxisParams::ValueScaleMonth:
3251 dtAddMonths( dt,1 * mult, dt );
3253 case KDChartAxisParams::ValueScaleQuarter:
3254 dtAddMonths( dt,3 * mult, dt );
3256 case KDChartAxisParams::ValueScaleYear:
3257 dtAddYears( dt, 1 * mult, dt );
3260 dtAddDays( dt, 1 * mult, dt );
3279 uint count = bStatistical
3283 double start( 1.0 + (bSteadyCalc ? 0.0 : static_cast < double >(data. colsScrolledBy())) );
3293 double delta( 1.0 );
3294 double finis( start + delta * ( count - 1 ) );
3295 const bool startIsDouble = TQVariant::Double == para. axisValueStart().type();
3296 const bool endIsDouble = TQVariant::Double == para. axisValueEnd().type();
3298 bool deltaIsAuto = true;
3301 deltaIsAuto = false;
3305 finis = start + delta * ( count - 1 );
3309 start = finis - delta * ( count - 1 );
3320 if ( startIsDouble ) {
3333 if ( deltaIsAuto ) {
3334 delta = ( finis - start ) / count;
3336 count = static_cast < uint > (
3337 ( finis - start ) / delta );
3350 finis = start + delta * ( count - 1 );
3353 TQString prefix( TQObject::tr( "Item " ) );
3357 if ( startIsDouble && endIsDouble ) {
3365 bool up = ( 0.0 < delta );
3369 double value = up ? s : f;
3371 while ( up ? ( value <= f ) : ( value >= s ) ) {
3373 value += delta * up ? 1.0 : -1.0;
3377 basicPos, orig, delimLen, nLabels,
3380 pTextsX, pTextsY, pTextsW, pTextsH,
3384 font.setPixelSize( static_cast < int > ( nTxtHeight ) );
3385 painter->setFont( font );
3386 TQFontMetrics fm( painter->fontMetrics() );
3388 if ( fm.width( prefix +
3389 TQString::number( -fabs( ( s + f ) / 2.0 + delta ),
3397 while ( up ? ( value <= f ) : ( value >= s ) ) {
3399 prefix + TQString::number( value, 'f', precis )
3401 value += delta * up ? 1.0 : -1.0;
3409 basicPos, orig, delimLen,
3413 pTextsX, pTextsY, pTextsW, pTextsH,
3417 font.setPixelSize( static_cast < int > ( nTxtHeight ) );
3418 painter->setFont( font );
3419 TQFontMetrics fm( painter->fontMetrics() );
3421 if ( fm.width( prefix + TQString::number( count - 1 ) )
3427 for ( uint i = 1; i <= count; ++i )
3429 prefix + TQString::number( i ) + postfix );
3437 uint nLabels = labelTexts.count()
3438 ? labelTexts.count()
3442 if( !adjustTheValues ){
3445 basicPos, orig, delimLen, nLabels,
3448 pTextsX, pTextsY, pTextsW, pTextsH,
3492 KDChartAxisParams::AxisPos basicPos,
3493 const TQPoint& orig,
3497 double& pDelimDelta,
3504 switch ( basicPos ) {
3505 case KDChartAxisParams::AxisPosBottom: {
3508 double divi = bTouchEdges
3509 ? ( 1 < nLabels ? nLabels - 1 : 1 )
3510 : ( nLabels ? nLabels : 10 );
3511 pDelimDelta = wid / divi;
3513 pTextsW = pDelimDelta - 4.0;
3514 pTextsX = orig.x() + 2.0
3521 textAlign = TQt::AlignHCenter | TQt::AlignTop;
3527 case KDChartAxisParams::AxisPosLeft: {
3529 pDelimDelta = hig / ( 1 < nLabels ? nLabels - 1 : 1 );
3533 pTextsY = orig.y() - nTxtHeight / 2;
3535 - delimLen * 1.33 - 2.0;
3536 pTextsH = nTxtHeight;
3537 textAlign = TQt::AlignRight | TQt::AlignVCenter;
3540 case KDChartAxisParams::AxisPosTop: {
3543 double divi = bTouchEdges
3544 ? ( 1 < nLabels ? nLabels - 1 : 1 )
3545 : ( nLabels ? nLabels : 10 );
3546 pDelimDelta = wid / divi;
3548 pTextsW = pDelimDelta - 4.0;
3549 pDelimDelta = wid / divi;
3551 pTextsX = orig.x() + 2.0
3557 textAlign = TQt::AlignHCenter | TQt::AlignBottom;
3560 case KDChartAxisParams::AxisPosRight: {
3562 pDelimDelta = hig / ( 1 < nLabels ? nLabels - 1 : 1 );
3566 pTextsY = orig.y() - nTxtHeight / 2;
3568 - delimLen * 1.33 - 2.0;
3569 pTextsH = nTxtHeight;
3570 textAlign = TQt::AlignLeft | TQt::AlignVCenter;
3574 tqDebug( "IMPLEMENTATION ERROR: KDChartAxesPainter::calculateBasicTextFactors() unhandled enum value." );
3597 const int behindComma,
3598 const double nDelta,
3599 int& trueBehindComma )
3601 const int nTrustedPrecision = 6;
3606 sVal.setNum( nVal, 'f', bUseAutoDigits ? nTrustedPrecision
3607 : TQMIN(behindComma, nTrustedPrecision) );
3610 if ( bUseAutoDigits ) {
3611 int comma = sVal.find( '.' );
3614 int i = sVal.length();
3616 && '0' == sVal[ i - 1 ] )
3619 if ( '.' == sVal[ i - 1 ] )
3620 sVal.truncate( i - 1 );
3622 if ( 0 > trueBehindComma ) {
3623 TQString sDelta = TQString::number( nDelta, 'f', nTrustedPrecision );
3624 int i = sDelta.length();
3626 && '0' == sDelta[ i - 1 ] )
3628 sDelta.truncate( i );
3629 if ( '.' == sDelta[ i - 1 ] )
3630 trueBehindComma = 0;
3632 int deltaComma = sDelta.find( '.' );
3633 if ( -1 < deltaComma )
3634 trueBehindComma = sDelta.length() - deltaComma - 1;
3636 trueBehindComma = 0;
3640 int nPos = comma + ( trueBehindComma ? trueBehindComma + 1 : 0 );
3641 sVal.truncate( nPos );
3651#if defined ( TQ_WS_WIN)
3652#define trunc(x) ((int)(x))
3661double trunc( double x)
3663 return x >= 0.0 ? floor(x) : -floor(-x);
3669TQString KDChartAxesPainter::applyLabelsFormat( const double nVal_,
3673 int& trueBehindComma,
3675 const TQString& decimalPoint,
3676 const TQString& thousandsPoint,
3677 const TQString& prefix,
3678 const TQString& postfix,
3680 const TQChar& padFill,
3683 double nVal = nVal_ / fastPow10( divPow10 );
3684 double nDelta = nDelta_;
3686 double valLog10 = 0.0;
3687 if( notation == KDChartEnums::NumberNotationScientific ||
3688 notation == KDChartEnums::NumberNotationScientificBig ){
3689 valLog10 = (nVal != 0.0) ? trunc( log10(TQABS(nVal)) ) : 0.0;
3691 nVal /= fastPow10( valLog10 );
3692 nDelta /= fastPow10( valLog10 );
3701 int posComma = sVal.find( '.' );
3702 if( 0 <= posComma ){
3703 sVal.replace( posComma, 1, decimalPoint);
3705 posComma = sVal.length();
3707 if( notation == KDChartEnums::NumberNotationScientific ||
3708 notation == KDChartEnums::NumberNotationScientificBig ){
3709 if( notation == KDChartEnums::NumberNotationScientific )
3713 sVal.append( TQString::number( valLog10, 'f', 0 ) );
3715 if( thousandsPoint.length() ){
3716 const int minLen = (0 < sVal.length() && '-' == sVal[0])
3720 while( minLen < n ){
3722 sVal.insert(n, thousandsPoint);
3726 sVal.append( postfix );
3727 int nFill = totalLen - (sVal.length() + prefix.length());
3731 sVal.prepend( prefix );
3732 for( int i=0; i < nFill; ++i)
3733 sVal.prepend( padFill );
3735 sVal.prepend( prefix );
3737 sVal.truncate( totalLen );
3743 if ( behindComma == 0 && TQString::number(nVal).find( '.') > 0 )
3760 double& nSubDelimFactor,
3763 bool findNextRound )
3765 if ( findNextRound ) {
3783 TQString sDistDigis2;
3784 sDistDigis2.setNum( nDist, 'f', 24);
3785 if ( 1.0 > nDist ) {
3786 sDistDigis2.remove( 0, 2 );
3788 while ( 0 < sDistDigis2.length()
3789 && '0' == sDistDigis2[ 0 ] ) {
3791 sDistDigis2.remove( 0, 1 );
3794 if ( 10.0 > nDist ) {
3797 sDistDigis2.remove( 1, 1 );
3799 if ( 100.0 > nDist )
3802 int comma = sDistDigis2.find( '.' );
3804 sDistDigis2.truncate( comma );
3805 nDivisor = fastPow10( ( int)sDistDigis2.length() - 2 );
3808 sDistDigis2.truncate( 2 );
3810 double nDistDigis2( sDistDigis2.toDouble( &bOk ) );
3813 if ( 75.0 <= nDistDigis2 )
3816 if ( 40.0 <= nDistDigis2 )
3819 if ( 20.0 <= nDistDigis2 )
3825 nDelta = nRound * nDivisor;
3829 nDelta = static_cast < int > ( nDelta ) < nDelta
3830 ? static_cast < int > ( nDelta ) + 1
3831 : static_cast < int > ( nDelta );
3833 bool bInvertedAxis = ( 0.0 > nDist );
3846 || !para.axisValueStartIsExact() ) {
3847 double orgLow( nLow );
3848 modf( nLow / nDelta, &nLow );
3850 if( bInvertedAxis ){
3851 if ( nLow < orgLow )
3853 if ( 0.0 > nLow && 0.0 <= orgLow )
3856 if ( nLow > orgLow )
3858 if ( 0.0 < nLow && 0.0 >= orgLow )
3863 double orgHigh( nHigh );
3864 modf( nHigh / nDelta, &nHigh );
3866 if( bInvertedAxis ){
3867 if ( nHigh > orgHigh )
3869 if ( 0.0 < nHigh && 0.0 >= orgHigh )
3872 if ( nHigh < orgHigh )
3874 if ( 0.0 > nHigh && 0.0 <= orgHigh )
3882 if ( 1.0 == nRound )
3883 nSubDelimFactor = 0.5;
3885 if ( 2.0 == nRound )
3886 nSubDelimFactor = 0.25;
3888 if ( 2.5 == nRound )
3889 nSubDelimFactor = 0.2;
3891 if ( 5.0 == nRound )
3892 nSubDelimFactor = 0.2;
3895 tqDebug( "IMPLEMENTATION ERROR: Unknown nRound in calculateOrdinateFactors()" );
3896 nSubDelimFactor = 1.0;
3899 nDist = nHigh - nLow;
3903void KDChartAxesPainter::saveDrawLine( TQPainter& painter,
3908 const TQPen oldPen( painter.pen() );
3909 bool bNice = ( pen.color() == oldPen.color() )
3910 && ( pen.width() == oldPen.width() )
3911 && ( pen.style() == oldPen.style() );
3913 painter.setPen( pen );
3914 painter.drawLine( pA, pZ );
3916 painter.setPen( oldPen );
3920void KDChartAxesPainter::dtAddSecs( const TQDateTime& org, const int secs, TQDateTime& dest )
3923 int s = org.time().second();
3924 int m = org.time().minute();
3925 int h = org.time().hour();
3928 int mins = (s + secs) / 60;
3932 s = (s + secs) % 60;
3933 int hours = (m + mins) / 60;
3937 m = (m + mins) % 60;
3938 days = (h + hours) / 24;
3942 h = (h + hours) % 24;
3947 dest.setTime( TQTime(h,m,s) );
3948 dest.setDate( org.date() );
3950 dtAddDays( dest, days, dest );
3955void KDChartAxesPainter::dtAddDays( const TQDateTime& org, const int days, TQDateTime& dest )
3958 int d = org.date().day();
3959 int m = org.date().month();
3960 int y = org.date().year();
3961 int dd = (-1 < days) ? 1 : -1;
3963 while( di != days ){
3969 d = TQDate( y,m,1 ).daysInMonth();
3977 } else if( TQDate( y,m,1 ).daysInMonth() < d ){
3988 dest = TQDateTime( TQDate( y,m,d ), org.time() );
3993void KDChartAxesPainter::dtAddMonths( const TQDateTime& org, const int months, TQDateTime& dest )
3996 int d = org.date().day();
3997 int m = org.date().month();
3998 int y = org.date().year();
3999 int md = (-1 < months) ? 1 : -1;
4001 while( mi != months ){
4013 dest = TQDateTime( TQDate( y,m,TQMIN( d, TQDate( y,m,1 ).daysInMonth() ) ),
4019void KDChartAxesPainter::dtAddYears( const TQDateTime& org, const int years, TQDateTime& dest )
4022 int d = org.date().day();
4023 int m = org.date().month();
4024 int y = org.date().year() + years;
4025 dest.setTime( org.time() );
4027 dest = TQDateTime( TQDate( y,m,TQMIN( d, TQDate( y,m,d ).daysInMonth() ) ),
4034void KDChartAxesPainter::calculateAbscissaInfos( const KDChartParams& params,
4039 const TQRect& dataRect,
4040 abscissaInfos& infos )
4043 && ( KDChartAxisParams::AxisTypeUnknown
4045 infos.abscissaPara = ¶ms. axisParams( KDChartAxisParams::AxisPosBottom );
4048 && ( KDChartAxisParams::AxisTypeUnknown
4050 infos.abscissaPara = ¶ms. axisParams( KDChartAxisParams::AxisPosBottom2 );
4053 && ( KDChartAxisParams::AxisTypeUnknown
4055 infos.abscissaPara = ¶ms. axisParams( KDChartAxisParams::AxisPosTop );
4058 && ( KDChartAxisParams::AxisTypeUnknown
4060 infos.abscissaPara = ¶ms. axisParams( KDChartAxisParams::AxisPosTop2 );
4063 infos.abscissaPara = ¶ms. axisParams( KDChartAxisParams::AxisPosBottom );
4065 if( infos.abscissaPara->axisLabelsTouchEdges() )
4066 infos.bCenterThePoints = false;
4069 infos.bAbscissaIsLogarithmic
4070 = KDChartAxisParams::AxisCalcLogarithmic == infos.abscissaPara->axisCalcMode();
4075 infos.numValues = 0;
4081 TQVariant::Type type2Ref = TQVariant::Invalid;
4082 infos.bCellsHaveSeveralCoordinates =
4083 data.cellsHaveSeveralCoordinates( datasetStart, datasetEnd,
4086 infos.numLabels = (infos.abscissaPara &&
4087 infos.abscissaPara->axisLabelTexts())
4088 ? infos.abscissaPara->axisLabelTexts()->count()
4090 if( 0 >= infos.numLabels )
4091 infos.numLabels = 1;
4093 infos.bAbscissaHasTrueAxisValues =
4094 infos.abscissaPara && (0.0 != infos.abscissaPara->trueAxisDelta());
4095 infos.abscissaStart = infos.bAbscissaHasTrueAxisValues
4096 ? infos.abscissaPara->trueAxisLow()
4098 infos.abscissaEnd = infos.bAbscissaHasTrueAxisValues
4099 ? infos.abscissaPara->trueAxisHigh()
4100 : 1.0 * (infos.numLabels - 1);
4101 infos.abscissaSpan = fabs( infos.abscissaEnd - infos.abscissaStart );
4102 infos.abscissaDelta = infos.bAbscissaHasTrueAxisValues
4103 ? infos.abscissaPara->trueAxisDelta()
4104 : ( ( 0.0 != infos.abscissaSpan )
4105 ? ( infos.abscissaSpan / infos.numLabels )
4106 : infos.abscissaSpan );
4112 infos.bAbscissaHasTrueAxisDtValues =
4113 (TQVariant::DateTime == type2Ref) &&
4114 infos.abscissaPara &&
4115 infos.abscissaPara->trueAxisDtLow().isValid();
4116 if( infos.bAbscissaHasTrueAxisDtValues ){
4117 infos.numLabels = 200;
4118 infos.bCenterThePoints = false;
4121 infos.dtLowPos = infos.bAbscissaHasTrueAxisDtValues
4122 ? infos.abscissaPara->axisDtLowPosX() - dataRect.x()
4124 infos.dtHighPos = infos.bAbscissaHasTrueAxisDtValues
4125 ? infos.abscissaPara->axisDtHighPosX() - dataRect.x()
4127 infos.abscissaDtStart = infos.bAbscissaHasTrueAxisDtValues
4128 ? infos.abscissaPara->trueAxisDtLow()
4130 infos.abscissaDtEnd = infos.bAbscissaHasTrueAxisDtValues
4131 ? infos.abscissaPara->trueAxisDtHigh()
4135 infos.bScaleLessThanDay = ( infos.bAbscissaHasTrueAxisDtValues
4136 ? infos.abscissaPara->trueAxisDtDeltaScale()
4137 : KDChartAxisParams::ValueScaleDay )
4138 < KDChartAxisParams::ValueScaleDay;
4139 if ( infos.abscissaDtStart.time() == infos.abscissaDtEnd.time() && infos.bScaleLessThanDay )
4140 infos.dtHighPos = logWidth;
4143 infos.abscissaDtStart.setTime(
4144 TQTime( infos.abscissaDtStart.time().hour(),
4145 infos.abscissaDtStart.time().minute(),
4146 infos.abscissaDtStart.time().second(),
4148 infos.abscissaDtEnd.setTime(
4149 TQTime( infos.abscissaDtEnd.time().hour(),
4150 infos.abscissaDtEnd.time().minute(),
4151 infos.abscissaDtEnd.time().second(),
4163 if( infos.bAbscissaHasTrueAxisDtValues ){
4164 if( infos.bScaleLessThanDay ){
4165 infos.abscissaDtSpan = infos.abscissaDtStart.secsTo( infos.abscissaDtEnd );
4176 infos.abscissaDtSpan = infos.abscissaDtStart.daysTo( infos.abscissaDtEnd );
4177 if( infos.abscissaDtStart.time().msec() || infos.abscissaDtEnd.time().msec() )
4178 infos.abscissaDtSpan +=
4179 ( infos.abscissaDtEnd.time().msec() -
4180 infos.abscissaDtStart.time().msec() ) / (86400.0 * 1000.0);
4181 if( infos.abscissaDtEnd.time().second() )
4182 infos.abscissaDtSpan += infos.abscissaDtEnd.time().second() / 86400.0;
4183 if( infos.abscissaDtEnd.time().minute() )
4184 infos.abscissaDtSpan += infos.abscissaDtEnd.time().minute() / 1440.0;
4185 if( infos.abscissaDtEnd.time().hour() )
4186 infos.abscissaDtSpan += infos.abscissaDtEnd.time().hour() / 24.0;
4189 infos.abscissaDtSpan = 10.0;
4190 if( 0 == infos.abscissaDtSpan || 0.0 == infos.abscissaDtSpan )
4191 infos.abscissaDtSpan = 1.0;
4193 infos.abscissaDtPixelsPerScaleUnit = (infos.dtHighPos - infos.dtLowPos)/ infos.abscissaDtSpan;
4195 if( infos.bAbscissaHasTrueAxisDtValues )
4196 infos.abscissaDelta = 20.0;
4199 = ( infos.abscissaPara && (0.0 != infos.abscissaPara->trueAxisDeltaPixels()) )
4200 ? infos.abscissaPara->trueAxisDeltaPixels()
4203 (1 > ((double)(infos.numLabels) - (infos.bCenterThePoints ? 0.0 : 1.0)))
4204 ? (( double)(infos.numLabels) - (infos.bCenterThePoints ? 0.0 : 1.0))
4207 infos.abscissaPixelsPerUnit = ( 0.0 != infos.abscissaDelta )
4208 ? ( infos.pointDist / infos.abscissaDelta )
4212 infos.abscissaZeroPos = infos.abscissaPara->axisZeroLineStartX() - dataRect.x();
4231bool KDChartAxesPainter::calculateAbscissaAxisValue( const TQVariant& value,
4236 if( ai.bCellsHaveSeveralCoordinates ) {
4237 if( TQVariant::Double == value.type() ) {
4238 double dVal = value.toDouble();
4239 if( ai.bAbscissaIsLogarithmic ){
4241 xValue = ai.abscissaPixelsPerUnit * log10( dVal );
4245 xValue = ai.abscissaPixelsPerUnit * dVal;
4247 xValue *= ai.bAbscissaDecreasing ? -1.0 : 1.0;
4248 xValue += ai.abscissaZeroPos;
4250 else if( ai.bAbscissaHasTrueAxisDtValues &&
4251 TQVariant::DateTime == value.type() ) {
4252 const TQDateTime dtVal = value.toDateTime();
4253 double dT = ( ai.bScaleLessThanDay )
4254 ? ai.abscissaDtStart.secsTo( dtVal )
4255 : ai.abscissaDtStart.daysTo( dtVal );
4278 xValue = ai.abscissaDtPixelsPerScaleUnit * dT;
4279 if( dtVal.time().msec() )
4280 xValue += (ai.abscissaDtPixelsPerScaleUnit * dtVal.time().msec())
4281 / ( ai.bScaleLessThanDay
4283 : (1000.0 * 86400.0) );
4285 if( !ai.bScaleLessThanDay ){
4286 if( dtVal.time().second() )
4287 xValue += (ai.abscissaDtPixelsPerScaleUnit * dtVal.time().second())
4289 if( dtVal.time().minute() )
4290 xValue += (ai.abscissaDtPixelsPerScaleUnit * dtVal.time().minute())
4292 if( dtVal.time().hour() )
4293 xValue += (ai.abscissaDtPixelsPerScaleUnit * dtVal.time().hour())
4296 xValue *= ai.bAbscissaDecreasing ? -1.0 : 1.0;
4297 xValue += ai.dtLowPos;
4304 xValue = ai.pointDist * ( double ) colNumber;
4335 bool bNormalMode = isNormalMode();
4337 uint chart = paint2nd ? 1 : 0;
4342 KDChartParams::AxesArray ordinateAxes;
4344 if( !params()->chartAxes( chart, axesCount, ordinateAxes ) ) {
4356 double logWidth = _dataRect.width();
4357 double areaWidthP1000 = logWidth / 1000.0;
4359 int nClipShiftUp = clipShiftUp(bNormalMode, areaWidthP1000);
4360 TQRect ourClipRect( _dataRect );
4361 if ( 0 < ourClipRect.top() ) {
4362 ourClipRect.setTop( ourClipRect.top() - nClipShiftUp );
4363 ourClipRect.setHeight( ourClipRect.height() + nClipShiftUp - 1 );
4365 ourClipRect.setHeight( ourClipRect.height() + nClipShiftUp / 2 - 1 );
4372 const TQWMatrix & world = painter->worldMatrix();
4373 ourClipRect = world.mapRect( ourClipRect );
4374 painter->setClipRect( ourClipRect );
4375 painter->translate( _dataRect.x(), _dataRect.y() );
4377 painter->setPen( params()->outlineDataColor() );
4380 uint chartDatasetStart, chartDatasetEnd;
4381 findChartDatasets( data, paint2nd, chart, chartDatasetStart, chartDatasetEnd );
4384 for( uint aI = 0; aI < axesCount; ++aI ) {
4386 uint axis = ordinateAxes.at( aI );
4390 uint datasetStart, datasetEnd;
4391 uint axisDatasetStart, axisDatasetEnd;
4393 if( params()->axisDatasets( axis,
4395 axisDatasetEnd, dummy )
4396 && ( KDCHART_ALL_DATASETS != axisDatasetStart ) ) {
4398 if( KDCHART_NO_DATASET == axisDatasetStart ){
4404 if( axisDatasetStart >= chartDatasetStart
4405 && axisDatasetStart <= chartDatasetEnd )
4406 datasetStart = TQMAX( axisDatasetStart, chartDatasetStart );
4407 else if( axisDatasetStart <= chartDatasetStart
4408 && axisDatasetEnd >= chartDatasetStart )
4409 datasetStart = chartDatasetStart;
4412 if( axisDatasetEnd >= chartDatasetStart
4413 && axisDatasetEnd <= chartDatasetEnd )
4414 datasetEnd = TQMIN( axisDatasetEnd, chartDatasetEnd );
4415 else if( axisDatasetEnd >= chartDatasetEnd
4416 && axisDatasetStart <= chartDatasetEnd )
4417 datasetEnd = chartDatasetEnd;
4421 datasetStart = chartDatasetStart;
4422 datasetEnd = chartDatasetEnd;
4441 double columnValueDistance = maxColumnValue - minColumnValue;
4445 specificPaintData( painter,
4458 columnValueDistance,
4464 painter->translate( - _dataRect.x(), - _dataRect.y() );
Provide access to the chart axis parameters.
#define KDCHART_AXIS_LABELS_AUTO_LIMIT Use this to specify that the axis label limits are to be calculated automatically.
#define KDCHART_AXIS_LABELS_AUTO_DELTA Use this to specify that the step-width from one label to the other shall be calculated automatically...
#define KDCHART_AXIS_GRID_AUTO_LINEWIDTH Use this to specify that the width of the axis grid lines shall be equal to the width of the axis lin...
#define KDCHART_AXIS_LABELS_AUTO_DATETIME_FORMAT Use this to specify that date/time format to be used for displaying the axis labels is to be determin...
#define KDCHART_AXIS_IGNORE_EMPTY_INNER_SPAN Use this to specify that the zero-line shall NOT be omitted in case all of the data are grouped far a...
#define KDCHART_AXIS_LABELS_AUTO_LEAVEOUT Use this to specify that an automatically computed amount of axis labels are to be skipped if there i...
#define KDCHART_AXIS_LABELS_AUTO_DIGITS Use this to specify that the number of digits to be shown on the axis labels behind the comma is to b...
Header for all common chart parameters.
#define KDCHART_CNT_ORDINATES Our charts may have up to 4 ordinate axes: 2 left ones and 2 right ones.
#define KDCHART_MAX_AXES Charts have up to 12 axes: up to two axes on both sides for X, Y and Z (if data is 3-dimensional).
static TQString truncateBehindComma(const double nVal, const int behindComma, const double nDelta, int &trueBehindComma) Takes double nVal and returns a TQString showing the amount of digits behind the comma that was speci...
virtual ~KDChartAxesPainter() Destructor.
static void calculateBasicTextFactors(double nTxtHeight, const KDChartAxisParams ¶, double averageValueP1000, KDChartAxisParams::AxisPos basicPos, const TQPoint &orig, double delimLen, uint nLabels, double &pDelimDelta, double &pTextsX, double &pTextsY, double &pTextsW, double &pTextsH, int &textAlign) Calculates some label text factors needed by function calculateLabelTexts()
static void calculateLabelTexts(TQPainter *painter, const KDChartTableDataBase &data, const KDChartParams ¶ms, uint axisNumber, double averageValueP1000, double delimLen, KDChartAxisParams::AxisPos &basicPos, TQPoint &orig, TQPoint &dest, double &pXDeltaFactor, double &pYDeltaFactor, double &pXDelimDeltaFaktor, double &pYDelimDeltaFaktor, double &nSubDelimFactor, double &pDelimDelta, double &nTxtHeight, double &pTextsX, double &pTextsY, double &pTextsW, double &pTextsH, int &textAlign, bool &isLogarithmic, bool &isDateTime, bool &autoDtLabels, TQDateTime &dtLow, TQDateTime &dtHigh, KDChartAxisParams::ValueScale &dtDeltaScale, bool adjustTheValues=false, double trueDelta=0.0, double trueDeltaPix=0.0) Calculates the actual label texts for one axis.
virtual void paintData(TQPainter *painter, KDChartTableDataBase *data, bool paint2nd, KDChartDataRegionList *regions) Paints the actual data area and registers the region for the data points if regions is not 0.
virtual void paintAxes(TQPainter *painter, KDChartTableDataBase *data) Paints the actual axes areas.
KDChartAxesPainter(KDChartParams *params) Constructor.
static void calculateOrdinateFactors(const KDChartAxisParams ¶, bool bLogarithmic, double &nDist, double &nDivisor, double &nRound, double &nDelta, double &nSubDelimFactor, double &nLow, double &nHigh, bool findNextRound=false) Calculates the factors to be used for calculating ordinate labels texts.
access the chart axis parameters.
TQColor axisLabelsColor() const Returns the axis labels colour.
TQStringList axisShortLabelsStringList() const Returns a TQStringList containing the label texts to be used in case the axis area size is too small ...
TQColor axisGridColor() const Returns the axis grid color.
TQt::PenStyle axisGridStyle() const Returns the axis grid line pattern.
double trueAxisHigh() const Returns the true end value of the ordinate axis labels as is was calculated and set by setTrueAxisLow...
int axisTrueLineWidth() const Returns the axis true line width, as calculated and drawn.
bool axisValuesDecreasing() const Returns whether axis values should be printed in reverted order: starting with the highest label and ...
double trueAxisLow() const Returns the true start value of the ordinate axis labels as is was calculated and set by setTrueAxisL...
TQRect axisTrueAreaRect() const Returns the true axis area rectangle as calculated and drawn.
int axisLabelsRotation() const Returns by how many degrees the axis labels will be rotated.
double trueAxisDeltaPixels() const Returns the true delimiter delta pixel value of the axis labels as is was calculated and set by setTr...
static AxisPos basicAxisPos(uint pos) enum KDChartAxisParams::AxisPos { AxisPosSTART = 0,
TQt::PenStyle axisGridSubStyle() const Returns the axis grid line pattern for the thin lines showing the sub-delimiter values.
uint isometricReferenceAxis() const Returns which axis this axis shall be isometric with, this will be either the axis position - see KDC...
int axisGridLineWidth() const Returns the width of the axis grid lines.
TQFont axisLabelsFont() const Returns the axis labels font.
bool axisShowSubDelimiters() const Returns whether the axis sub-delimiters will be drawn.
TQVariant axisValueStart() const Returns the lower limit for the axis labels: the start value.
int axisMaxEmptyInnerSpan() const Returns the percentage of the y-axis range that may to contain NO data entries, if - and only if - ax...
double axisValueDelta() const Returns the DELTA value for the axis labels: the distance between two labels.
int axisLabelsFontRelSize() const Returns the axis labels relative font size.
TQString axisLabelsDateTimeFormat() const Returns the format to be used for displaying abscissa axis TQDateTime item labels.
bool axisLabelsFontUseRelSize() const Returns whether the fix axis font size is used.
AxisType axisType() const
int labelTextsDataRow() const Returns the number of the data row that contains (or might contain, resp.) the texts to be taken for ...
double axisZeroLineStartX() const Returns the not-rounded x-position where drawing of this axis zero line started.
uint axisLabelStringCount() const Returns the number of strings stored as label texts, the texts can be retrieved by calling axisLabelS...
bool axisShowGrid() const Returns whether a grid should be drawn at the chart data area.
int axisGridSubLineWidth() const Returns the axis grid sub line width.
int axisDigitsBehindComma() const Returns the number of digits to be printed behind the comma on the axis labels.
bool axisSteadyValueCalc() const Returns whether label values shall be calculataed based upon the associated dataset values (normally ...
int axisLineWidth() const Returns the axis line width.
bool axisLabelsDontShrinkFont() const Specifies whether the axis labels' font size may be shrinked to avoid overwriting neighboring areas.
bool axisVisible() const Returns weither the axis will be drawn or not.
double axisZeroLineStartY() const Returns the not-rounded y-position where drawing of this axis zero line started.
TQStringList axisLabelStringList() const Returns a TQStringList containing the label texts to be used.
AxisCalcMode axisCalcMode() const Returns the axis calculation mode configured in this params object.
TQColor axisLineColor() const Returns the axis line colour.
bool axisLabelsDontAutoRotate() const Returns whether the axis labels may not be rotated to avoid overwriting neighboring areas.
TQColor axisGridSubColor() const Returns the axis grid sub color.
double trueAxisDelta() const Returns the true delta value of the ordinate axis labels as is was calculated and set by setTrueAxisL...
int axisValueLeaveOut() const Returns how many axis labels are to be skipped if there is not enough space for displaying all of the...
TQVariant axisValueEnd() const Returns the upper limit for the axis labels: the end value.
bool axisLabelsVisible() const Returns whether the axis labels should be drawn.
TQColor axisZeroLineColor() const Returns the colour used for the zero-value line that is drawn if zero is not at the lower edge of the...
bool axisLineVisible() const Returns whether the axis line should be drawn.
bool axisLabelsTouchEdges() const Returns whether the axis labels start and end at the edges of the charts instead being positioned in ...
The collection class used by KD Chart to store data region information.
NumberNotation Number notation specifies the general way, how a number is to be shown.
An abstract base class that defines an interface for classes that implement chart drawing.
virtual void paint(TQPainter *painter, KDChartTableDataBase *data, bool paintFirst, bool paintLast, KDChartDataRegionList *regions=0, const TQRect *rect=0, bool mustCalculateGeometry=true) Paints the chart for which this chart painter is configured on a TQPainter.
Bundles the display parameters of a chart.
ChartType chartType() const Returns the chart type configured in this params object.
static int roundVal(double d) Returns the parameter d rounded to the nearest integer.
AreaChartSubType areaChartSubType() const Returns the area chart subtype.
int numValues() const Returns how many of the values should be shown.
LineChartSubType lineChartSubType() const Returns the line chart subtype.
ChartType additionalChartType() const Returns the additional chart type configured in this params object.
bool optimizeOutputForScreen() const Returns whether drawing is optimized for (low resolution) screen output (this is the default) or whet...
PolarChartSubType polarChartSubType() const Returns the polar chart subtype.
const KDChartAxisParams & axisParams(uint n) const Returns the parameters that are currently defined for axis n.
bool threeDBars() const Returns whether the engine should draw any bars in 3D.
bool axisDatasets(uint n, uint &dataset, uint &dataset2, uint &chart) const Returns which data are to be represented by a given axis.
BarChartSubType barChartSubType() const Returns the bar chart subtype.
bool findDatasets(SourceMode mode1, SourceMode mode2, uint &dataset, uint &dataset2, uint chart=0) const Retrieves the dataset number or a range of datasets being used with one of two given SourceModes for ...
KD Chart's build-in table data for an easy way of storing data values.
virtual uint usedCols() const Returns the number of cols in the table that actually contain data.
virtual bool cellCoord(uint _row, uint _col, TQVariant &_value, int coordinate=1) const =0 Returns one of the coordinate data value(s) stored in a cell.
virtual uint colsScrolledBy() const Returns the number of cols the table has been scrolled by.
virtual uint usedRows() const Returns the number of rows in the table that actually contain data.
|