[Kst] [Bug 91681] improve legend and x axis label for multiple x vectors in one plot

Andrew Walker arwalker at sumusltd.com
Wed Oct 27 20:03:25 CEST 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
        
http://bugs.kde.org/show_bug.cgi?id=91681        
arwalker sumusltd com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From arwalker sumusltd com  2004-10-27 20:03 -------
CVS commit by arwalker: 

Display the various default labels (x, y and top) ensuring that each unique name is included once and only once.

CCMAIL: 91681-done bugs kde org


  M +43 -23    kst2dplot.cpp   1.294


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.293:1.294
 @ -2366,6 +2366,7  @ static void EscapeSpecialChars(QString& 
 
 void Kst2DPlot::GenerateDefaultLabels() {
-  int n_curves, i_curve, n_images;
-  QString xlabel, ylabel, toplabel;
+  QStringList xlabels, ylabels, toplabels;
+  QString label, xlabel, ylabel, toplabel;
+  int n_curves, i_curve, n_images, i_count;
 
   n_curves = Curves.count();
 @ -2373,29 +2374,47  @ void Kst2DPlot::GenerateDefaultLabels() 
 
   if (n_curves > 0) {
-    if (n_curves == 1) {
-      xlabel = Curves[0]->xLabel();
-      ylabel = Curves[0]->yLabel();
-      toplabel = Curves[0]->topLabel();
-    } else {
-      xlabel = Curves[0]->xLabel();
-      ylabel = QString::null;
-      toplabel = QString::null;
+    for( i_curve = 0; i_curve < n_curves; i_curve++) {
+      if (xlabels.findIndex(Curves[i_curve]->xLabel()) == -1) {
+        xlabels.append(Curves[i_curve]->xLabel());
+      }
+      if (ylabels.findIndex(Curves[i_curve]->yLabel()) == -1) {
+        ylabels.append(Curves[i_curve]->yLabel());
+      }
+      if (toplabels.findIndex(Curves[i_curve]->topLabel()) == -1) {
+        toplabels.append(Curves[i_curve]->topLabel());
+      }
+    }
 
-      ylabel = Curves[0]->yLabel();
-      toplabel = Curves[0]->topLabel();
-      for (i_curve = 1; i_curve < n_curves - 1; i_curve++) {
-        ylabel += QString(", ") + Curves[i_curve]->yLabel();
-        if (toplabel != Curves[i_curve]->topLabel()) {
-          toplabel += QString(", ") + Curves[i_curve]->topLabel();
+    i_count = xlabels.count();
+    for (i_curve = 0; i_curve < i_count; i_curve++) {
+      xlabel += xlabels[i_curve];
+      if (i_curve < i_count-2) {
+        xlabel += QString(", ");
+      } else if (i_curve == i_count-2) {
+        xlabel += i18n(" and ");
         }
       }
 
-      ylabel = i18n("%1 and %2").arg(ylabel).arg(Curves[n_curves - 1]->yLabel());
-      if (toplabel != Curves[i_curve]->topLabel() &&
-          !Curves[i_curve]->topLabel().isEmpty()) {
-        toplabel = i18n("%1 and %2").arg(toplabel).arg(Curves[n_curves - 1]->topLabel());
+    i_count = ylabels.count();
+    for (i_curve = 0; i_curve < i_count; i_curve++) {
+      ylabel += ylabels[i_curve];
+      if (i_curve < i_count-2) {
+        ylabel += QString(", ");
+      } else if (i_curve == i_count-2) {
+        ylabel += i18n(" and ");
       }
     }
+
+    i_count = toplabels.count();
+    for (i_curve = 0; i_curve < i_count; i_curve++) {
+      toplabel += toplabels[i_curve];
+      if (i_curve < i_count-2) {
+        toplabel += QString(", ");
+      } else if (i_curve == i_count-2) {
+        toplabel += i18n(" and ");
+      }
   }
+  }  
+
   //
   // labels for images



More information about the Kst mailing list