Bug 148038

Summary: set the fontsize of an axis label through Javascript
Product: [Applications] kst Reporter: Andrew Walker <arwalker>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: 1.4.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Andrew Walker 2007-07-19 22:55:51 UTC
Version:           1.4.0 (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources
OS:                Linux

Is there a possibility to set the fontsize of an axis label through Javascript? Looking through the docs, it seems that the only thing I can do is set the text itself,

var p0 = Kst.windows[0].plots[0];
p0.xAxis.label = "Time (s)";

But then the label is (almost) unreadable...

Would something along the lines of the following be possible?

var lab0 = new Label(Kst.windows[0].plots[0].xAxis);
lab0.setFontSize(6);

Kind regards,

Wim
Comment 1 Andrew Walker 2007-07-25 21:57:51 UTC
SVN commit 692540 by arwalker:

CCBUG:148038 SILENT make label objects accessible via javaScript

 M  +3 -0      Makefile.am  
 M  +27 -1     bind_axis.cpp  
 M  +8 -0      bind_axis.h  
 A             bind_axislabel.cpp   [License: GPL (v2+)]
 A             bind_axislabel.h   [License: GPL (v2+)]
 A             bind_axisticklabel.cpp   [License: GPL (v2+)]
 A             bind_axisticklabel.h   [License: GPL (v2+)]
 M  +15 -1     bind_plot.cpp  
 M  +5 -0      bind_plot.h  
 A             bind_plotlabel.cpp   [License: GPL (v2+)]
 A             bind_plotlabel.h   [License: GPL (v2+)]


--- branches/work/kst/1.5/kst/src/extensions/js/Makefile.am #692539:692540
@@ -84,6 +84,9 @@
 			    bind_size.cpp \
 			    bind_box.cpp \
 			    bind_label.cpp \
+			    bind_axisticklabel.cpp \
+			    bind_axislabel.cpp \
+			    bind_plotlabel.cpp \
 			    bind_legend.cpp \
 			    bind_ellipse.cpp \
 			    bind_picture.cpp \
--- branches/work/kst/1.5/kst/src/extensions/js/bind_axis.cpp #692539:692540
@@ -16,6 +16,8 @@
  ***************************************************************************/
 
 #include "bind_axis.h"
+#include "bind_axislabel.h"
+#include "bind_axisticklabel.h"
 #include "bind_timeinterpretation.h"
 
 #include <kst.h>
@@ -82,6 +84,8 @@
   { "label", &KstBindAxis::setLabel, &KstBindAxis::label },
   { "type", 0L, &KstBindAxis::type },
   { "interpretation", 0L, &KstBindAxis::interpretation },
+  { "title", 0L, &KstBindAxis::title },
+  { "tickLabel", 0L, &KstBindAxis::tickLabel },
   { 0L, 0L, 0L }
 };
 
@@ -135,7 +139,7 @@
       return (this->*axisProperties[i].get)(exec);
     }
   }
-  
+
   return KstBinding::get(exec, propertyName);
 }
 
@@ -173,6 +177,28 @@
 }
 
 
+KJS::Value KstBindAxis::title(KJS::ExecState *exec) const {
+  if (!_d) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+    exec->setException(eobj);
+    return KJS::Undefined();
+  }
+  KstReadLocker rl(_d);
+  return KJS::Object(new KstBindAxisLabel(exec, _d, _xAxis));
+}
+
+
+KJS::Value KstBindAxis::tickLabel(KJS::ExecState *exec) const {
+  if (!_d) {
+    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
+    exec->setException(eobj);
+    return KJS::Undefined();
+  }
+  KstReadLocker rl(_d);
+  return KJS::Object(new KstBindAxisTickLabel(exec, _d, _xAxis));
+}
+
+
 KJS::Value KstBindAxis::label(KJS::ExecState *exec) const {
   if (!_d) {
     KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
--- branches/work/kst/1.5/kst/src/extensions/js/bind_axis.h #692539:692540
@@ -173,6 +173,14 @@
                     displayed.
      */
     KJS::Value interpretation(KJS::ExecState *exec) const;
+    /* @property AxisLabel label
+       @description The label for this axis.
+    */
+    KJS::Value title(KJS::ExecState *exec) const;
+    /* @property AxisTickLabel label
+       @description The tick label for this axis.
+    */
+    KJS::Value tickLabel(KJS::ExecState *exec) const;
 
   protected:
     friend class KstBindTimeInterpretation;
--- branches/work/kst/1.5/kst/src/extensions/js/bind_plot.cpp #692539:692540
@@ -16,9 +16,12 @@
  ***************************************************************************/
 
 #include "bind_plot.h"
+#include "bind_plotlabel.h"
 #include "bind_axis.h"
 #include "bind_curvecollection.h"
+#include "bind_label.h"
 #include "bind_legend.h"
+#include "bind_axislabel.h"
 
 #include <kst2dplot.h>
 #include <kstplotlabel.h>
@@ -117,6 +120,7 @@
   { "topLabel", &KstBindPlot::setTopLabel, &KstBindPlot::topLabel },
   { "xAxis", 0L, &KstBindPlot::xAxis },
   { "yAxis", 0L, &KstBindPlot::yAxis },
+  { "title", 0L, &KstBindPlot::title },
   { "tied", &KstBindPlot::setTied, &KstBindPlot::tied },
   { 0L, 0L, 0L }
 };
@@ -277,7 +281,6 @@
 
 
 KJS::Value KstBindPlot::xAxis(KJS::ExecState *exec) const {
-  Q_UNUSED(exec)
   Kst2DPlotPtr d = makePlot(_d);
   if (d) {
     KstReadLocker rl(d);
@@ -298,6 +301,17 @@
 }
 
 
+KJS::Value KstBindPlot::title(KJS::ExecState *exec) const {
+  Q_UNUSED(exec)
+  Kst2DPlotPtr d = makePlot(_d);
+  if (d) {
+    KstReadLocker rl(d);
+    return KJS::Object(new KstBindPlotLabel(exec, d));
+  }
+  return KJS::Object();
+}
+
+
 KJS::Value KstBindPlot::createLegend(KJS::ExecState *exec, const KJS::List& args) {
   Kst2DPlotPtr d = makePlot(_d);
   if (!d) {
--- branches/work/kst/1.5/kst/src/extensions/js/bind_plot.h #692539:692540
@@ -83,6 +83,11 @@
        @description The Y-axis for this plot.
     */
     KJS::Value yAxis(KJS::ExecState *exec) const;
+    /* @property PlotLabel title
+       @readonly
+       @description The title for this plot.
+    */
+    KJS::Value title(KJS::ExecState *exec) const;
     /* @property boolean tied
        @description True if the plot zoom state is tied.
     */
Comment 2 Andrew Walker 2007-07-25 22:01:55 UTC
It should now be possible to do the following:

Kst.windows[0].plots[0].xAxis.title.text = "Time (s)"
Kst.windows[0].plots[0].xAxis.title.fontSize = 12

Kst.windows[0].plots[0].xAxis.label = "Time (s)" is still supported.