Xforms-charts

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Xforms-charts

Smruti Naik
Hello ,
 
I WANT to configure charts through xforms .  My requirement is like , Java Processors output data will be the input of
Charts , means what java Processor will return the data ,using that data i have to generate Charts ,
 
Following is the code. Can you Please tell me where i am going wrong ?
 
Forecast.java
 
 

contentHandler.startDocument();
   contentHandler.startElement("", "Process", "Process",  NO_ATTRIBUTES);
    contentHandler.characters(spid.toCharArray(), 0, spid.length());
   contentHandler.endElement("", "Process", "Process");

    contentHandler.startElement("", "team", "team",  NO_ATTRIBUTES);
    contentHandler.characters(tid.toCharArray(), 0, tid.length());
   contentHandler.endElement("", "team", "team");

   contentHandler.startElement("", "AttributeV", "AttributeV",  NO_ATTRIBUTES);
    contentHandler.characters(attributeval.toCharArray(), 0, attributeval.length());
   contentHandler.endElement ("", "AttributeV", "AttributeV");
        contentHandler.startElement("", "properties", "properties",  NO_ATTRIBUTES);
  
  
  if(algo.equals("1"))
  {
   System.out.println("Simple Expo Algorithm");
    forValSExp=SeVal+1;
   // String name = "namepppp";
    ForfinalVal.add(forValSExp);
    /*String value = Double.toString(forValSExp);
            if(value != null)
                outputProperty(contentHandler, name, value);
          System.out.println(forValSExp);*/
      
  for(int sei=0;sei<ForfinalVal.size();sei++)
   {
   String name="";
   if(sei==0)
    {
    name = arrstrP[0];
    }
    else
     {
     name="+"+sei;
    }
//   Double val=ForfinalVal.get(sei).toString();
   String value = ForfinalVal.get(sei).toString();
            if(value != null)
                outputProperty(contentHandler, name, value);
   DocWrite(contentHandler,name,value);
   }

   

  }
  else if(algo.equals("2"))
  {
   System.out.println("Holts Algorithm");
   for(int f=1;f<=fval ;f++)
   {
    Double forValH1=HTi*(f);
    Double forVal=forValH1+HTi;
    ForfinalVal.add(forVal);    
   System.out.println("Forecast value "+f+" is "+forVal);
   
           }
   for(int hi=0;hi<ForfinalVal.size();hi++)
   {
//    for(int bi=0;bi< arrstrP.length;bi++)
//    {
 String name1="";
    if(hi==0)
    {
    name1 =arrstrP[0];
    }
    else
    {
     name1="+"+(hi);
    }

    
//   Double val1=Math.abs(ForfinalVal.get(hi));
    String value1 = ForfinalVal.get(hi).toString();
            if(value1 != null)
                outputProperty(contentHandler, name1, value1);
   DocWrite(contentHandler,name1,value1);
    }
//   }
  }
  else if(algo.equals("3"))
  {
   System.out.println("Winters Algorithm");
    for(int f1=1;f1<=fval ;f1++)
   {
    Double forValW1=f1*WTi;
    Double forValW2=WLi+forValW1;
    Double forValW=forValW2*WSi;
    ForfinalVal.add(forValW);
    System.out.println("Forecast value "+f1+ " is "+forValW);

   }
   for(int wi=0;wi<ForfinalVal.size();wi++)
   {
    String name2="";
    if(wi==0)
    {
     name2=arrstrP[0];
    }
    else
    {
     name2 = "+"+wi;
    }
   //Double val2=Math.abs(ForfinalVal.get(wi));
    String value2 =ForfinalVal.get(wi).toString();
            if(value2 != null)
                outputProperty(contentHandler, name2, value2);
   DocWrite(contentHandler,name2,value2);
   }

   }

   contentHandler.endElement("", "properties", "properties");
        contentHandler.endDocument();
     System.out.println(holt);

   

       
 }

  private static void outputProperty(ContentHandler contentHandler, String name, String value) throws SAXException {
        contentHandler.startElement("", "property", "property", NO_ATTRIBUTES);
        contentHandler.startElement("", "name", "name", NO_ATTRIBUTES);
        contentHandler.characters(name.toCharArray(), 0, name.length());
        contentHandler.endElement("", "name", "name");
        contentHandler.startElement("", "value", "value",NO_ATTRIBUTES);
        contentHandler.characters(value.toCharArray(), 0, value.length());
        contentHandler.endElement ("", "value", "value");
        contentHandler.endElement("", "property", "property");
    }
  private static void DocWrite(ContentHandler contentHandler, String category, String values) throws SAXException {
        contentHandler.startElement("", "form", "form", NO_ATTRIBUTES);
   contentHandler.startElement("", "data", "data", NO_ATTRIBUTES);
    contentHandler.startElement ("", "entries", "entries", NO_ATTRIBUTES);
   contentHandler.startElement("", "entry", "entry", NO_ATTRIBUTES);
        contentHandler.startElement("", "category", "category", NO_ATTRIBUTES);
        contentHandler.characters(category.toCharArray(), 0, category.length());
        contentHandler.endElement("", "category", "category");
        contentHandler.startElement("", "values", "values",NO_ATTRIBUTES);
        contentHandler.characters(values.toCharArray(), 0, values.length());
        contentHandler.endElement("", "values", "values");
     contentHandler.endElement("", "entry", "entry");
        contentHandler.endElement("", "entries", "entries");
     contentHandler.endElement("", "data", "data");
        contentHandler.endElement("", "form", "form");
    }

ChartConfig.xml

 <chart>
        <map>forecast</map>
        <background-color>#EFF6EF</background-color>
        <title-color>#281154</title-color>
        <type>vertical-bar</type>
  <!-- <type>pie</type> -->
        <title>Forecast</title>
        <category-title><!-- SUPERVISOR  --></category-title>
        <category-margin>0.6</category-margin>
        <serie-title>xxx</serie-title>
        <tick-unit>2.0</tick-unit>
        <bar-margin>0.1</bar-margin>
        <category-label-angle>0</category-label-angle>

        <value title="xxx"
            categories="/maintag/properties/form/data/entries/entry/category"
            series="/maintag/properties/form/data/entries/entry/values"
            color="#ff0033"/>

  
      <!--  <value title="June"
            categories="/form/data/entries/entry/category"
            series="/form/data/entries/entry/value2"
            color="#00ff00"/> -->

        <legend visible="true" position="south"/>

        <x-size>400</x-size>
        <y-size>275</y-size>
    </chart>

model.xpl

 <p:processor name="oxf:java">
        <p:input name="config">
            <config sourcepath="." class="Forecast1"/>
        </p:input>
 <p:input name="data" href="#data"/>
 <p:output name="data" id="chart-data"/>
    </p:processor>

     <p:processor name="oxf:chart">
        <p:input name="config">
            <config/>
        </p:input>
        <p:input name="data" href="#chart-data"/>
        <p:input name="chart" href="chart-config.xml"/>
        <p:output name="data" ref="data" />
    </p:processor>
</p:config>

 

 
 
 


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms-charts

Erik Bruchez
Administrator
Hi,

Did you figure this out? Is this still a problem?

If so, can you please attach the files to your response, or, even
better, send a zip file of a small app that can simply be unzipped under
resources/apps to reproduce the problem?

Thanks,

-Erik

Smruti Naik wrote:

> Hello ,
>  
> I WANT to configure charts through xforms .  My requirement is like ,
> Java Processors output data will be the input of
> Charts , means what java Processor will return the data ,using that data
> i have to generate Charts ,
>  
> Following is the code. Can you Please tell me where i am going wrong ?
>  
> Forecast.java
>  
>  
>
> contentHandler.startDocument();
>    contentHandler.startElement("", "Process", "Process",  NO_ATTRIBUTES);
>     contentHandler.characters(spid.toCharArray(), 0, spid.length());
>    contentHandler.endElement("", "Process", "Process");
>
>     contentHandler.startElement("", "team", "team",  NO_ATTRIBUTES);
>     contentHandler.characters(tid.toCharArray(), 0, tid.length());
>    contentHandler.endElement("", "team", "team");
>
>    contentHandler.startElement("", "AttributeV", "AttributeV",  
> NO_ATTRIBUTES);
>     contentHandler.characters(attributeval.toCharArray(), 0,
> attributeval.length());
>    contentHandler.endElement ("", "AttributeV", "AttributeV");
>         contentHandler.startElement("", "properties", "properties",  
> NO_ATTRIBUTES);
>  
>  
>   if(algo.equals("1"))
>   {
>    System.out.println("Simple Expo Algorithm");
>     forValSExp=SeVal+1;
>    // String name = "namepppp";
>     ForfinalVal.add(forValSExp);
>     /*String value = Double.toString(forValSExp);
>             if(value != null)
>                 outputProperty(contentHandler, name, value);
>           System.out.println(forValSExp);*/
>      
>   for(int sei=0;sei<ForfinalVal.size();sei++)
>    {
>    String name="";
>    if(sei==0)
>     {
>     name = arrstrP[0];
>     }
>     else
>      {
>      name="+"+sei;
>     }
> //   Double val=ForfinalVal.get(sei).toString();
>    String value = ForfinalVal.get(sei).toString();
>             if(value != null)
>                 outputProperty(contentHandler, name, value);
>    DocWrite(contentHandler,name,value);
>    }
>
>    
>
>   }
>   else if(algo.equals("2"))
>   {
>    System.out.println("Holts Algorithm");
>    for(int f=1;f<=fval ;f++)
>    {
>     Double forValH1=HTi*(f);
>     Double forVal=forValH1+HTi;
>     ForfinalVal.add(forVal);    
>    System.out.println("Forecast value "+f+" is "+forVal);
>    
>            }
>    for(int hi=0;hi<ForfinalVal.size();hi++)
>    {
> //    for(int bi=0;bi< arrstrP.length;bi++)
> //    {
>  String name1="";
>     if(hi==0)
>     {
>     name1 =arrstrP[0];
>     }
>     else
>     {
>      name1="+"+(hi);
>     }
>
>    
> //   Double val1=Math.abs(ForfinalVal.get(hi));
>     String value1 = ForfinalVal.get(hi).toString();
>             if(value1 != null)
>                 outputProperty(contentHandler, name1, value1);
>    DocWrite(contentHandler,name1,value1);
>     }
> //   }
>   }
>   else if(algo.equals("3"))
>   {
>    System.out.println("Winters Algorithm");
>     for(int f1=1;f1<=fval ;f1++)
>    {
>     Double forValW1=f1*WTi;
>     Double forValW2=WLi+forValW1;
>     Double forValW=forValW2*WSi;
>     ForfinalVal.add(forValW);
>     System.out.println("Forecast value "+f1+ " is "+forValW);
>
>    }
>    for(int wi=0;wi<ForfinalVal.size();wi++)
>    {
>     String name2="";
>     if(wi==0)
>     {
>      name2=arrstrP[0];
>     }
>     else
>     {
>      name2 = "+"+wi;
>     }
>    //Double val2=Math.abs(ForfinalVal.get(wi));
>     String value2 =ForfinalVal.get(wi).toString();
>             if(value2 != null)
>                 outputProperty(contentHandler, name2, value2);
>    DocWrite(contentHandler,name2,value2);
>    }
>
>    }
>
>    contentHandler.endElement("", "properties", "properties");
>         contentHandler.endDocument();
>      System.out.println(holt);
>
>    
>
>        
>  }
>
>   private static void outputProperty(ContentHandler contentHandler,
> String name, String value) throws SAXException {
>         contentHandler.startElement("", "property", "property",
> NO_ATTRIBUTES);
>         contentHandler.startElement("", "name", "name", NO_ATTRIBUTES);
>         contentHandler.characters(name.toCharArray(), 0, name.length());
>         contentHandler.endElement("", "name", "name");
>         contentHandler.startElement("", "value", "value",NO_ATTRIBUTES);
>         contentHandler.characters(value.toCharArray(), 0, value.length());
>         contentHandler.endElement ("", "value", "value");
>         contentHandler.endElement("", "property", "property");
>     }
>   private static void DocWrite(ContentHandler contentHandler, String
> category, String values) throws SAXException {
>         contentHandler.startElement("", "form", "form", NO_ATTRIBUTES);
>    contentHandler.startElement("", "data", "data", NO_ATTRIBUTES);
>     contentHandler.startElement ("", "entries", "entries", NO_ATTRIBUTES);
>    contentHandler.startElement("", "entry", "entry", NO_ATTRIBUTES);
>         contentHandler.startElement("", "category", "category",
> NO_ATTRIBUTES);
>         contentHandler.characters(category.toCharArray(), 0,
> category.length());
>         contentHandler.endElement("", "category", "category");
>         contentHandler.startElement("", "values", "values",NO_ATTRIBUTES);
>         contentHandler.characters(values.toCharArray(), 0, values.length());
>         contentHandler.endElement("", "values", "values");
>      contentHandler.endElement("", "entry", "entry");
>         contentHandler.endElement("", "entries", "entries");
>      contentHandler.endElement("", "data", "data");
>         contentHandler.endElement("", "form", "form");
>     }
>
> ChartConfig.xml
>
>  <chart>
>         <map>forecast</map>
>         <background-color>#EFF6EF</background-color>
>         <title-color>#281154</title-color>
>         <type>vertical-bar</type>
>   <!-- <type>pie</type> -->
>         <title>Forecast</title>
>         <category-title><!-- SUPERVISOR  --></category-title>
>         <category-margin>0.6</category-margin>
>         <serie-title>xxx</serie-title>
>         <tick-unit>2.0</tick-unit>
>         <bar-margin>0.1</bar-margin>
>         <category-label-angle>0</category-label-angle>
>
>         <value title="xxx"
>            
> categories="/maintag/properties/form/data/entries/entry/category"
>             series="/maintag/properties/form/data/entries/entry/values"
>             color="#ff0033"/>
>
>  
>       <!--  <value title="June"
>             categories="/form/data/entries/entry/category"
>             series="/form/data/entries/entry/value2"
>             color="#00ff00"/> -->
>
>         <legend visible="true" position="south"/>
>
>         <x-size>400</x-size>
>         <y-size>275</y-size>
>     </chart>
>
> model.xpl
>
>  <p:processor name="oxf:java">
>         <p:input name="config">
>             <config sourcepath="." class="Forecast1"/>
>         </p:input>
>  <p:input name="data" href="#data"/>
>  <p:output name="data" id="chart-data"/>
>     </p:processor>
>
>      <p:processor name="oxf:chart">
>         <p:input name="config">
>             <config/>
>         </p:input>
>         <p:input name="data" href="#chart-data"/>
>         <p:input name="chart" href="chart-config.xml"/>
>         <p:output name="data" ref="data" />
>     </p:processor>
> </p:config>
>
>  
>
>  
>  
>  
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws