Project

General

Profile

Actions

Bug #279

closed

examples/charts does not work [origin/v3.0

Added by blink eye about 14 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
01/25/2010
Due date:
% Done:

0%

Estimated time:

Description

The examples build and starts fine - but

  • Category chart
  • Scatter Plott (time series)
  • Scatter Plott (sine function)

don't display the actual graph content. The

  • table above the Category Chart
  • Pie Chart

work.

I converted the examples/charts directory to the origin/v2 state with some necessary minor changes and got it to work again. The following is the v3-ified v2 examples/charts state:

diff --git a/examples/charts/ChartConfig.C b/examples/charts/ChartConfig.C
index 6d2e010..fcb426d 100644                                             
--- a/examples/charts/ChartConfig.C                                       
+++ b/examples/charts/ChartConfig.C                                       
@@ -31,7 +31,7 @@ using namespace Wt::Chart;                              

 namespace {                                                              
   void addHeader(WTable *t, const char *value) {                         
-    t->elementAt(0, t->columnCount())->addWidget(new WText(value));      
+    t->elementAt(0, t->columnCount())->addWidget(new WText(value));      
   }                                                                      

   void addEntry(WAbstractItemModel *model, const char *value) {          
@@ -39,6 +39,14 @@ namespace {                                            
     model->setData(model->rowCount()-1, 0, boost::any(std::string(value)));
   }                                                                        

+  int seriesIndexOf(WCartesianChart* chart, int modelColumn) {             
+    for (unsigned i = 0; i < chart->series().size(); ++i)                  
+      if (chart->series()[i].modelColumn() == modelColumn)                 
+       return i;                                                           
+                                                                           
+    return -1;                                                             
+  }                                                                        
+                                                                           
   bool getDouble(WLineEdit *edit, double& value) {                         
     try {                                                                  
       value = boost::lexical_cast<double>(edit->text().toUTF8());          
@@ -47,14 +55,6 @@ namespace {                                              
       return false;                                                        
     }                                                                      
   }                                                                        
-                                                                           
-  int seriesIndexOf(WCartesianChart* chart, int modelColumn) {             
-    for (unsigned i = 0; i < chart->series().size(); ++i)                  
-      if (chart->series()[i].modelColumn() == modelColumn)                 
-       return i;                                                           
-                                                                           
-    return -1;                                                             
-  }                                                                        
 }                                                                          

 ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent) 
@@ -62,8 +62,6 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
     chart_(chart),                                                                         
     fill_(MinimumValueFill)                                                                
 {                                                                                          
-  chart->initLayout();                                                                     
-                                                                                           
   PanelList *list = new PanelList(this);                                                   

   WIntValidator *sizeValidator = new WIntValidator(200, 2000, this);                       
@@ -82,7 +80,7 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
   addEntry(orientation, "Horizontal");                                                     

   WTable *chartConfig = new WTable();                                                      
-  chartConfig->setMargin(WLength::Auto, Left | Right);                                     
+  chartConfig->setMargin(WLength(), Left | Right);                                         

   int row = 0;                                                                             
   chartConfig->elementAt(row, 0)->addWidget(new WText("Title:"));                          
@@ -120,8 +118,8 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
   }                                                                                          

   WPanel *p = list->addWidget("Chart properties", chartConfig);                              
-  p->setMargin(WLength::Auto, Left | Right);                                                 
-  p->resize(750, WLength::Auto);                                                             
+  p->setMargin(WLength(), Left | Right);                                                     
+  p->resize(750, WLength());                                                                 
   p->setMargin(20, Top | Bottom);                                                            

   if (chart_->isLegendEnabled())                                                             
@@ -159,7 +157,7 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
   addEntry(labels, "X: Y");                                                                  

   WTable *seriesConfig = new WTable();                                                       
-  seriesConfig->setMargin(WLength::Auto, Left | Right);                                      
+  seriesConfig->setMargin(WLength(), Left | Right);                                          

   ::addHeader(seriesConfig, "Name");                                                         
   ::addHeader(seriesConfig, "Enabled");                                                      
@@ -228,8 +226,8 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)

   p = list->addWidget("Series properties", seriesConfig);                                    
   p->expand();                                                                               
-  p->setMargin(WLength::Auto, Left | Right);                                                 
-  p->resize(750, WLength::Auto);                                                             
+  p->setMargin(WLength(), Left | Right);                                                     
+  p->resize(750, WLength());                                                                 
   p->setMargin(20, Top | Bottom);                                                            

   // ---- Axis properties ----                                                               
@@ -245,7 +243,7 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
   addEntry(xScales, "Date scale");                                                           

   WTable *axisConfig = new WTable();                                                         
-  axisConfig->setMargin(WLength::Auto, Left | Right);                                        
+  axisConfig->setMargin(WLength(), Left | Right);                                            

   ::addHeader(axisConfig, "Axis");                                                           
   ::addHeader(axisConfig, "Visible");                                                        
@@ -285,7 +283,9 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
     }                                                                                        
     connectSignals(sc.scaleEdit);                                                            

-    bool autoValues = axis.autoLimits() == (MinimumValue | MaximumValue);                    
+    bool autoValues                                                                          
+      =    axis.minimum() == WAxis::AUTO_MINIMUM                                             
+        && axis.maximum() == WAxis::AUTO_MAXIMUM;                                            

     sc.minimumEdit = new WLineEdit(axisConfig->elementAt(j, 4));                             
     sc.minimumEdit->setText(boost::lexical_cast<std::string>(axis.minimum()));               
@@ -321,8 +321,8 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
   }                                                                                          

   p = list->addWidget("Axis properties", axisConfig);                                        
-  p->setMargin(WLength::Auto, Left | Right);                                                 
-  p->resize(750, WLength::Auto);                                                             
+  p->setMargin(WLength(), Left | Right);                                                     
+  p->resize(750, WLength());                                                                 
   p->setMargin(20, Top | Bottom);                                                            

   /*                                                                                         
@@ -333,7 +333,7 @@ ChartConfig::ChartConfig(WCartesianChart *chart, WContainerWidget *parent)
     WPushButton *b = new WPushButton(this);                                                  
     b->setText("Update chart");                                                              
     b->setInline(false); // so we can add margin to center horizontally                      
-    b->setMargin(WLength::Auto, Left | Right);                                               
+    b->setMargin(WLength(), Left | Right);                                                   
     b->clicked().connect(SLOT(this, ChartConfig::update));                                   
   }                                                                                          
 }                                                                                            
@@ -451,7 +451,7 @@ void ChartConfig::update()                                                
     }                                                                                        

     if (sc.autoEdit->isChecked())                                                            
-      axis.setAutoLimits(MinimumValue | MaximumValue);                                       
+      axis.setRange(WAxis::AUTO_MINIMUM, WAxis::AUTO_MAXIMUM);                               
     else {                                                                                   
       if (validate(sc.minimumEdit) && validate(sc.maximumEdit)) {                            
        double min, max;                                                                      
@@ -462,11 +462,14 @@ void ChartConfig::update()                                              
          if (min <= 0)                                                                       
            min = 0.0001;                                                                     

+       max = std::max(min, max);                                                             
+                                                                                             
        axis.setRange(min, max);                                                              
       }                                                                                      

     }                                                                                        

+                                                                                             
     if (validate(sc.labelAngleEdit)) {                                                       
       double angle;                                                                          
       getDouble(sc.labelAngleEdit, angle);                                                   
diff --git a/examples/charts/ChartsApplication.C b/examples/charts/ChartsApplication.C        
index 3f46f73..79930aa 100644                                                                 
--- a/examples/charts/ChartsApplication.C                                                     
+++ b/examples/charts/ChartsApplication.C                                                     
@@ -18,7 +18,6 @@ public:                                                                     
   messageResourceBundle().use("charts");                                                     

   root()->setPadding(10);                                                                    
-  root()->resize(WLength::Auto, WLength::Auto);                                              

   new ChartsExample(root());                                                                 

diff --git a/examples/charts/ChartsExample.C b/examples/charts/ChartsExample.C                
index 3328a34..cf19014 100644                                                                 
--- a/examples/charts/ChartsExample.C                                                         
+++ b/examples/charts/ChartsExample.C                                                         
@@ -81,7 +81,7 @@ CategoryExample::CategoryExample(Wt::WContainerWidget *parent):             
     WContainerWidget *w = new WContainerWidget(this);                                        
     Ext::TableView *table = new Ext::TableView(w);                                           
     table->setMargin(10, Top | Bottom);                                                      
-    table->setMargin(WLength::Auto, Left | Right);                                           
+    table->setMargin(WLength(), Left | Right);                                               
     table->resize(500, 175);                                                                 
     table->setModel(model);                                                                  
     table->setAutoExpandColumn(0);                                                           
@@ -118,8 +118,8 @@ CategoryExample::CategoryExample(Wt::WContainerWidget *parent):           

   chart->resize(800, 400); // WPaintedWidget must be given explicit size                     

-  chart->setMargin(10, Top | Bottom);            // add margin vertically                    
-  chart->setMargin(WLength::Auto, Left | Right); // center horizontally                      
+  chart->setMargin(10, Top | Bottom);        // add margin vertically                        
+  chart->setMargin(WLength(), Left | Right); // center horizontally                          

   new ChartConfig(chart, this);                                                              
 }                                                                                            
@@ -168,8 +168,8 @@ TimeSeriesExample::TimeSeriesExample(Wt::WContainerWidget *parent):       

   chart->resize(800, 400); // WPaintedWidget must be given explicit size                     

-  chart->setMargin(10, Top | Bottom);            // add margin vertically                    
-  chart->setMargin(WLength::Auto, Left | Right); // center horizontally                      
+  chart->setMargin(10, Top | Bottom);        // add margin vertically                        
+  chart->setMargin(WLength(), Left | Right); // center horizontally                          

   new ChartConfig(chart, this);
 }
@@ -179,7 +179,7 @@ ScatterPlotExample::ScatterPlotExample(WContainerWidget *parent):
 {
   new WText(WString::tr("scatter plot 2"), this);

-  WStandardItemModel *model = new WStandardItemModel(40, 2, this);
+  WStandardItemModel *model = new WStandardItemModel(100, 2, this);
   model->setHeaderData(0, boost::any(WString("X")));
   model->setHeaderData(1, boost::any(WString("Y = sin(X)")));

@@ -214,8 +214,8 @@ ScatterPlotExample::ScatterPlotExample(WContainerWidget *parent):

   chart->resize(800, 300); // WPaintedWidget must be given explicit size

-  chart->setMargin(10, Top | Bottom);            // add margin vertically
-  chart->setMargin(WLength::Auto, Left | Right); // center horizontally
+  chart->setMargin(10, Top | Bottom);        // add margin vertically
+  chart->setMargin(WLength(), Left | Right); // center horizontally

   ChartConfig *config = new ChartConfig(chart, this);
   config->setValueFill(ZeroValueFill);
@@ -239,7 +239,7 @@ PieExample::PieExample(WContainerWidget *parent):
     WContainerWidget *w = new WContainerWidget(this);
     Ext::TableView *table = new Ext::TableView(w);
     table->setMargin(10, Top | Bottom);
-    table->setMargin(WLength::Auto, Left | Right);
+    table->setMargin(WLength(), Left | Right);
     table->resize(300, 175);
     table->setModel(model);
     table->setAutoExpandColumn(0);
@@ -269,7 +269,7 @@ PieExample::PieExample(WContainerWidget *parent):

   chart->resize(800, 300); // WPaintedWidget must be given explicit size

-  chart->setMargin(10, Top | Bottom);            // add margin vertically
-  chart->setMargin(WLength::Auto, Left | Right); // center horizontally
+  chart->setMargin(10, Top | Bottom);        // add margin vertically
+  chart->setMargin(WLength(), Left | Right); // center horizontally
 }

diff --git a/examples/charts/CsvUtil.C b/examples/charts/CsvUtil.C
index d922093..98eabb8 100644
--- a/examples/charts/CsvUtil.C
+++ b/examples/charts/CsvUtil.C
@@ -1,9 +1,3 @@
-/*
- * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
- *
- * See the LICENSE file for terms of use.
- */
-
 #include <boost/tokenizer.hpp>
 #include <boost/lexical_cast.hpp>

diff --git a/examples/charts/charts.xml b/examples/charts/charts.xml
index 24de8bf..ca70a6f 100644
--- a/examples/charts/charts.xml
+++ b/examples/charts/charts.xml
@@ -60,9 +60,9 @@
   A cartesian chart provides automatic configuration of the axes, and
   support for a second Y axis. In addition, you may use a simple
   built-in legend, or extend the class to provide a specialized
-  legend. <!-- In the example below, we use a manual Y axis configuration,
+  legend. In the example below, we use a manual Y axis configuration,
   with a break as would be commonly used when your data has a few
-  outliers.-->
+  outliers.
 </p>

 <p class="p">
Actions #1

Updated by blink eye about 14 years ago

It turns out this gets only the Scatter Plot (time series) working.

  • Category Chart
  • Scatter Plot (sine function)

still don't work

Actions #2

Updated by Koen Deforche about 14 years ago

Hey,

Any reason why you are not using the 'master' branch ?

Regards,

koen

Actions #3

Updated by Koen Deforche about 14 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche
Actions #4

Updated by Koen Deforche over 13 years ago

  • Status changed from Feedback to Closed

Closed after lack of feedback.

Actions

Also available in: Atom PDF