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

List:       koffice
Subject:    Bug fixe patch of KChart (graph and editor)
From:       Toshitaka Fujioka <toshitaka () kde ! gr ! jp>
Date:       2001-03-18 9:05:31
[Download RAW message or body]

Hello,

The patch which I attached lets you just display a graph when you decreased
row or column with "KChart Data Editor". (CVS of 16/03)
Of course program work fine when I let row or column increase.

For example, form this data
 http://www.kde.gr.jp/~toshitaka/Kde/KOffice/KChart/kchart1.jpg

,I make a graph of "Rows=3, Cols=4".

Before a patch apply:
 http://www.kde.gr.jp/~toshitaka/Kde/KOffice/KChart/kchart2.jpg

After a patch apply:
 http://www.kde.gr.jp/~toshitaka/Kde/KOffice/KChart/kchart3.jpg


Please review.
["koffice-kchart-RowsCols-20010318.diff" (text/x-c++)]

diff -ur koffice.orig/kchart/kchartDataEditor.cc koffice/kchart/kchartDataEditor.cc
--- koffice.orig/kchart/kchartDataEditor.cc	Sun Mar 18 17:15:20 2001
+++ koffice/kchart/kchartDataEditor.cc	Sun Mar 18 17:22:16 2001
@@ -16,11 +16,21 @@
 }
 
 void kchartDataEditor::setData(KoChart::Data* dat) {
+  int rowsCount, colsCount;
+  if ( dat->usedRows() == 0 && dat->usedCols() == 0) { // Data from KSpread
+    rowsCount = dat->rows();
+    colsCount = dat->cols();
+  }
+  else {
+    rowsCount = dat->usedRows();
+    colsCount = dat->usedCols();
+  }
+
   _widget->setUsedRows( dat->usedRows() );
   _widget->setUsedCols( dat->usedCols() );
 
-  for (unsigned int row = 0;row != dat->rows();row++)
-    for (unsigned int col = 0; col !=dat->cols(); col++) {
+  for (unsigned int row = 0;row != rowsCount;row++)
+    for (unsigned int col = 0; col != colsCount; col++) {
       kdDebug(35001) << "Set dialog cell for " << row << "," << col << endl;
       KoChart::Value t = dat->cell(row,col);
       // fill it in from the part
@@ -49,13 +59,13 @@
   dat->setUsedRows( _widget->usedRows() );
   dat->setUsedCols( _widget->usedCols() );
 
-    for (int row = 0;row < _widget->rows();row++) {
-      for (int col = 0;col < _widget->cols();col++) {
+    for (int row = 0;row < _widget->usedRows();row++) {
+      for (int col = 0;col < _widget->usedCols();col++) {
         // m_pData->setYValue( row, col, _widget->getCell(row,col) );
         KoChart::Value t;
         double val =  _widget->getCell(row,col);
-        if( ( row >= _widget->rows() )  ||
-            ( col >= _widget->cols() ) )
+        if( ( row >= _widget->usedRows() )  ||
+            ( col >= _widget->usedCols() ) )
         { /*t.exists = false; */ }
         else
             t = QVariant( val );
diff -ur koffice.orig/kchart/kchartEngine.cc koffice/kchart/kchartEngine.cc
--- koffice.orig/kchart/kchartEngine.cc	Sun Mar 18 17:15:20 2001
+++ koffice/kchart/kchartEngine.cc	Sun Mar 18 17:25:19 2001
@@ -41,7 +41,10 @@
 
   // For now, we are assuming that the data is in columns with no labels at all
   // Ergo, num_sets is the number of rows
-  num_sets = data->rows();
+  if ( data->usedRows() == 0 )   // Data from KSpread
+    num_sets = data->rows();
+  else
+    num_sets = data->usedRows();
 
   // No data sets left -> bail out
   if( num_sets < 1 ) {
@@ -52,9 +55,12 @@
   //num_hlc_sets = params->has_hlc_sets() ? num_sets : 0;
   //you are 2 curves
   num_hlc_sets = params->has_hlc_sets() ? 1 : 0;
-  // And num_points is the number of columns
 
-  num_points = data->cols(); //data->usedCols();
+  // And num_points is the number of columns
+  if ( data->usedCols() == 0 ) // Data from KSpread
+    num_points = data->cols();
+  else
+    num_points = data->usedCols();
 
   /* idiot checks */
   if( imagewidth <= 0 || imageheight <=0 || !p  )


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

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