[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdeedu/kalzium/src
From:       Pino Toscano <toscano.pino () tiscali ! it>
Date:       2005-10-29 22:14:51
Message-ID: 1130624091.764015.28956.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 475634 by pino:

a pair of fixes directly from trunk:
- insert a padding in the graph, so the border points won't be hidden by the
  axis themselves
- fetch the right labels (ie element names) for the plotted points


 M  +6 -3      elementdataviewer.cpp  


--- branches/KDE/3.5/kdeedu/kalzium/src/elementdataviewer.cpp #475633:475634
@@ -108,7 +108,7 @@
 	double minY = yData->value(f);
 	double maxY = yData->value(f);
 
-	for ( int _currentVal = f; _currentVal < t; _currentVal++ )
+	for ( int _currentVal = f; _currentVal <= t; _currentVal++ )
 	{
 		double v = yData->value( _currentVal );
 		
@@ -118,7 +118,10 @@
 			maxY = v;
 	}
 	
-	m_pPlotWidget->setLimits( (double)f, (double)t, minY, maxY );
+	// try to put a small padding to make the points on the axis visible
+	double dx = ( t - f + 1 ) / 25 + 1.0;
+	double dy = ( maxY - minY ) / 10.0;
+	m_pPlotWidget->setLimits( f - dx, t + dx, minY - dy, maxY + dy );
 }
 
 void ElementDataViewer::paintEvent(QPaintEvent*)
@@ -318,7 +321,7 @@
 
 			if (showNames)
 			{
-				dataPointLabel[number] = new KPlotObject( *(names.at(i)), "Red", KPlotObject::LABEL );
+				dataPointLabel[number] = new KPlotObject( *(names.at(i-1)), "Red", KPlotObject::LABEL );
 				dataPointLabel[number]->addPoint( new DPoint( (double)i , yData->value( i ) ) );
 				m_pPlotWidget->addObject( dataPointLabel[number] );
 			}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic