How create graphs(pie and bar graphs) in j2me

hi friends,
how to create graphs in j2me?
plz help me.
regards,
Shruthi R S

Hi Shruti,
I have developed the same application in j2me. I worked on graphs related to stocks. So i think my code can work for u too.
Here is the code for displaying bars:
package project;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
class BarCanvas extends Canvas {
     public static boolean indicator=true;
     public static int lenght=120;
     int pad=2;
     Font font;
     private int fh;
     String xName = "";
     String yName = "VALUE";
     private int xmargen=15;
     private int ymargen=15;
     private int initialx=0;
     private int initialy=0;
     int scale = 15;
     private int bw=0;
     int index=0;
     int scaleincr;
     int padincr;
     int pady=0;
     String s1;
     //int bars[]={20,30,40,40,50,20,70,80,90};
     int bars[]={20,30,40,50,300};
     int k=bars.length;
     int barinc=scale+bw+pad;
          BarCanvas(String s1){
               this.s1=s1;
               font = Font.getFont(Font.FACE_SYSTEM,
               Font.STYLE_PLAIN, Font.SIZE_SMALL);
               fh = font.getHeight();
               if(s1.equals("Tic"))
                    padincr=2;
                    bw=3;
                    scaleincr=3;
               if(s1.equals("1 minute"))
                    padincr=2;
                    bw=3;
                    scaleincr=3;
               if(s1.equals("5 minutes"))
                    padincr=2;
                    bw=3;
                    scaleincr=15;
               if(s1.equals("15 minutes"))
                    padincr=10;
                    bw=5;
                    scaleincr=15;
               if(s1.equals("Hourly"))
                    padincr=10;
                    bw=5;
                    scaleincr=1;
               if(s1.equals("Daily"))
                    padincr=10;
                    bw=5;
                    scaleincr=1;
               if(s1.equals("Weekly"))
                    padincr=10;
                    bw=5;
                    scaleincr=1;
               }//linecanvas
public void paint(Graphics g) {
                    int width = getWidth();
               int height = getHeight();
               int titleHeight;
               g.setFont(font);
               int titlex1 = font.stringWidth("TIME");
               int titlex = (width-titlex1)/2;
               g.setColor(0,0,0);
               g.fillRect(0, 0, width, height);
               //set text on scales
                    setScaleName( xName, yName, titlex, height, width, g);
               // x axis
                    drawXasxis( g, width, height,xmargen,ymargen);
                         //y axis
                         drawYasxis( g, xmargen, height,ymargen);
                    //horizontal scale
                         drawXhorizontalScales( g, width, height, scale,xmargen,ymargen);
                         //vertical scale
                         drawYVerticalScales(g, width,height,scale,xmargen,ymargen);
                         //draw x scale no.
                         setXScallNo( g, width, height, scale);
//                         draw y scale no.
                         setYScallNo( g, width, height, scale);
                         //draw line.
                         drawBar(g,height);
public void setXScallNo(Graphics g,int width,int height,int scale){
     String s=initialx+"";
     int increment =scaleincr;
     for(int i= xmargen;i<width;i+=scale){
          //G.drawLine(i, height-10, i, height-10);
          g.drawString(s,i,height-2,Graphics.BOTTOM|Graphics.HCENTER);
          s=(initialx+increment)+"";
          increment+=scaleincr;
     return;
public void setYScallNo(Graphics g,int width,int height,int scale){
     String s=initialy+"";
     int increment =scale;
     for(int i= height-ymargen;i>0;i-=scale){
          //G.drawLine(i, height-10, i, height-10);
          g.drawString(s,0,i,Graphics.TOP|Graphics.LEFT);
          s=(initialy+increment)+"";
          increment+=scale;
     return;
public void setScaleName(String xName,String yName,int titlex,int height,int width,Graphics g){
     g.setColor(250,250,250);
     g.drawString("X-scale=10",width-70,3,Graphics.TOP|Graphics.RIGHT);
     g.drawString("Y-scale=10",width-10,3,Graphics.TOP|Graphics.RIGHT);
     g.drawString(xName,width/2,(height-fh),Graphics.TOP|Graphics.LEFT);
     int i=0;
     for(int j=0;j<yName.length();j++){
          String s=yName.charAt(j)+"";
     g.drawString(s,1,(height/2)+i,Graphics.TOP|Graphics.LEFT);
     i=i+10;
     return;
public void drawXasxis(Graphics g,int width,int height,int xmargen,int ymargen){
     g.setColor(0x6FFFFF);
g.drawLine(xmargen, height-ymargen, width , height-ymargen);
return;
public void drawYasxis(Graphics g,int xmargen,int height,int ymargen){
     g.setColor(0x6FFFFF);
     g.drawLine(xmargen,height-ymargen,xmargen,0);
     return;
public void drawXhorizontalScales(Graphics g,int width,int height,int scale,int xmargen,int ymargen){
     g.setColor(0x6FFFFF);
     int j=0;
     while(j<5){
     for(int i= xmargen;i<width;i+=scale)
          g.drawLine(i, height-(ymargen+j), i, height-ymargen);
     j++;
     return;
public void drawYVerticalScales(Graphics g,int width,int height,int scale,int xmargen,int ymargen){
     g.setColor(0x6FFFFF);
     int j=0;
     while(j<5){
     for(int i=height-ymargen;i>0;i-=scale){
          g.drawLine(xmargen+j,i,xmargen+j,i);
     j++;
     return;
public void drawBar(Graphics g,int height){
     int j=1;
     for(int i=index;i<bars.length;i++,j++)
          //g.drawRect(scale+bw*j+pad*j,(height-15)-bars,bw,bars[i]);
          g.drawRect(scale+bw*j+padincr*j,(height-ymargen)-bars[i]-pady,bw,bars[i]);
g.fillRect(scale+bw*j+padincr*j,(height-ymargen)-bars[i]-pady,bw,bars[i]);
public void setData(int length)
public int getData(){
     return 0;
public void keyPressed(int keyCode) {
if ((keyCode==KEY_NUM4))
     initialx=initialx+scaleincr;
          if(s1.equals("5 minutes"))
               if(index==0)
               index=index+3;
               else
               index=index+4;     
          else if(s1.equals("15 minutes"))
               if(index==0)
               index=index+1;
               else
               index=index+1;
          else
               index=index+scaleincr;
          repaint();
          System.out.println(scaleincr);
if ((keyCode==KEY_NUM6))
     if(initialx>0)
          initialx=initialx-scaleincr;
          if(s1.equals("5 minutes"))
               if(index==3)
               index=index-3;
               else
               index=index-4;     
          else if(s1.equals("15 minutes"))
               if(index==1)
               index=index-1;
               else
               index=index-1;
          else
               index=index-scaleincr;
     //index=index-scaleincr;
     repaint();
if ((keyCode==KEY_NUM2))
     if(initialy>0)
     pady=pady+15;
     initialy=initialy-scale;
     repaint();
if ((keyCode==KEY_NUM8))
     pady=pady-15;
     initialy=initialy+scale;
     repaint();
protected void keyReleased(int keyCode)
protected void keyRepeated(int keyCode)
Similarly u can do for lines and candle sticks too.
If u need any help give any mail id to post jad or jar files.
Regards ,
Deepika

Similar Messages

  • How create new database and table in java db and how get java db backup

    hi master
    sir i use stuido creator
    sir please give me idea how i create new database
    and how create new table and view in this new database
    and how get this database backup
    how i give this databae backup to isp for deployment
    please give me idea with step
    thank
    aamir

    Create your own Value Object (Data Transfer Object) in Java with a structure similar to this and map the fields returned from the database to the fields of that object (preferably using SEtT methods).
    Hope this helps.

  • How to developed QR and bar code reader app with Win8 tablet?

    I want to know the best approach of developing QR and bar code reader app with Win8 tablet? 
    Please suggest any third party or native c# which could be help for me.
    shishir

    Hello,
    This forum is for discussions and questions regarding profiles and Microsoft's recognition system on the MSDN and TechNet sites. It is not for products/technologies.
    As it's off-topic here, I am moving the question to the
    Where is the forum for... forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • How to plot line and bar chart in one graph

    i have one graph, but in this graph i want to plot line or bar chart using radio button selection.
    can i do that...

    You must have 2 data arrays or plots to get this. Make sure your plot legend is visible. Drag the plot legend vertical borders to view both plots. Select one of the plot to be bar plot (See the attachment)
    Attachments:
    BarPlots.PNG ‏14 KB

  • How create zoom in and zoom out buttons in a JfreeChart

    hi,
    i want implements a "zoom in" and "zoom out" functionalitys form my Jfreechart. in a popupmenu this function there is, but i want create two buttons.
    I don't know how implement this.
    Can you help me???
    Tanx
    P.S. Sorry for my english :D

    If you right click on any of the JFreeChart standard examples you will see buttons that allow you to zoom in and zoom out. Just follow the code that the examples use. This feature can be enabled/disabled using the parameters in the chart construction. Check the Javadoc.

  • Create graph based on dynamic table data

    Hi experts ;
    i have JDeve Version 11.1.2.2.0 , i'm create dynamic table based on dynamic SQL query this query return by function in database by based on passing parameter .
    My question :-
    1- How create graph based on dynamic table and contral it at run time ?
    Thanks & Best Regards

    Hi Mostafa,
    You can retrieve the data from your sql query in a backing bean and pass it on to Graph using the setTabularData method.
    Here is the javadoc for the setTabulardata method:
    http://docs.oracle.com/cd/E16162_01/apirefs.1112/e17492/oracle/dss/dataView/CommonDataview.html#setTabularData%28java.util.List%29
    Hope this helps
    Katia

  • How to create a pie graph in 10g or 9i forms using beans??

    Hi..
    Please can anyone show me how to use pie graphs in oracle 10g or 9i forms using bean?
    i also want to know how to put data in pie graph.. as u know in column graph for example we have an x-axis and y-axis,and in pie there is no x-axis and y-axis.. so how i can put the same data in pie graph.. and also i may need more than one value for the x-axis or the y-axis to use in pie graph so how can i do it??
    i use set_custom_property to call properties in beans.
    I would so thankful for how can answer me.. please its urgent
    Thanks.

    there are some other posts to this topic - How to create a pie graph in 10g or 9i forms using beans?? and so on.
    use the search function of this forum. this may the fastest way for your urgent question

  • How to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area

    how to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area
    ananya

    Hey Ananya,
    I believe what you want to do is possible, but it will not be
    easy.  If you want to add a scroll bar that will scroll the graph
    back and forth but keep the axis set, you would want to add a
    horizontal or vertical scrollbar.  Then you would create an event
    handler for the scroll event.  You would have to manually plot
    different data within this scroll event.  Unfortunately, there is
    not really a built in way to do this with the Measurement Studio plot
    control.
    Thanks,
    Pat P.
    Software Engineer
    National Instruments

  • Creating Graphs and Bar Charts

    Hi members
    I have been looking high and low to find my answer but to no avail.
    I currently run SAP AR Age debt reports once I extract this data I create graphs in excel.
    I am looking for Sap transaction where I can create a graphs and link them to T-Codes such as AGE DEBT report.
    Please help

    Hi,
    first of all you can create z tcodes only in that is in se93.so create a report either using FM or oops and link it too the tcode.
    other FMs
    GRAPH_MATRIX                   Calling up SAP Business Graphics (2D, 3D and 4D)
    GRAPH_MATRIX_2D                Calling up the 2D graphics (user-friendly version)
    GRAPH_MATRIX_3D                Structure of 3D graphics (user-friendly version)
    GRAPH_MATRIX_4D                Calling up a 3D graphic (4th dimension stacked representation).
    u can follow
    Graphs in ABAP
    hope it helps..

  • How to create Pen-up and Pen-down option in X-Y graph ?

    Hi,
    I would like to create a basic digital version of XY plotter. I sorted out everything (scales, offsets, ranges, printing) except for Pen-up and Pen-down option. This application will be use to take multiple plots one after another. I need to print them on the same sheet. Basically when I run the test I plot one "line", then I take pen up, move it (with offset), put the pen down and draw another "line". Up to probably 6-8 "lines". My problem is that when I put the pen up and then down it connects old "line" withe the one that I just started to draw. (I assume that use of shift registers and a buffer needs to be involved??)
    I'm new to Labview and I would appreciate any help.
    Thx.
    Solved!
    Go to Solution.

    Hello again.
    Thx for all the replays. It works great.
    I would like to add another function to the plotter. The guy who is using it wants to write on the plot - I mean he draws a line and then he needs to mark it as A, then he draws another line and he wans to mark it as B, C and D. Then also he is reading some values from digital displays and he wants to be able to write it down on the plot while the plotter is running (then he prints it out).
    I think the only way to do that would be to use cursor name. Set as many cursors as I want (for now I would need 8), place them in the corner (for a start, so I wouldnt see them on the printput, only the name) and drag their name to wherever I want. 
    I wanted to do that but...I have a bit of a problem. When I'm setting property nodes for cursors (name visible, cursor visible, allow dragging, cursor name, cursor position) I'm only able to do that for one cursor. How can I create another one and set properties of that one?  Also is there a possibility of having a transparent cursor and a colored cursor name??
    frannerr

  • Excel & ActiveX: Insert arbitrary columns from 2D array and create graph problems

    Hi there,
    I want to insert data from either a 1D or 2D array from LabView into Excel and create graphs.
    I used the information from the following example:
    http://www.ni.com/example/28934/en/
    and was able to create a new Excel file (I'm using Excel 2010), writing data from an 1D array to a column in excel by creating a while loop and using the first element of the array to write it to a specific cell. I use the counter of the loop to write to the next cell when the loop starts over and always delete the first value, which I write to the cell, from the array until it is empty.
    Now I also would like to write a 2D array - so the first column in Excel should be the first column from the array and so. Here I cannot use the loop counter directly as Excel only counts 1,2,... for the rows, but uses A,B,... to count columns. Also I do not know in advance how many columns my 2D array will contain, so creating a lookup table like (A means 1, B means 2,...) is not really an option (except there really is no other way). Is there a possibilty to convert numbers into letters or some way to 'explain' to the program that column 2 in the array means column B in Excel for example, or is there a way to insert new columns?
    I figured out how to add new Worksheets and as I also need to create a certain number of Worksheets and I know that on standard 3 sheets are present when creating the file, I use the 'add' methode to create every new worksheets before worksheet 3 - I could use the same methode to create new columns in Excel, but so far I didn't find a methode to do so. Or is there a way to enter the whole 2D array at once?
    Then I'd like to create a graph (in case of the 1D arrays a bar plot, when using 2D arrays a 3D plot) to view the data. I found this example:
    http://www.ni.com/newsletter/51339/en/
    -> as I do not have the toolkit I'd like to do it using ActiveX directly, so I tried to do things like shown under the headline 'DIY ActiveX/.NET'
    I tried to load the snippet to a new Excel file but got the error message 'microsoft.office.interop.excel.dll not found' and hence the code is not working. That confuses me a little as I would guess when this dll is not present I cannot access Excel from LabView at all, though my understanding of what I'm really doing so far is quiet limited. ;-)
    Also - as far as I understand from the snippet - when creating a new chart object I should be able the create methodes for it, however when I do a right click on the chart object of an ActiveX Worksheet symbol there are none listed.
    To explain my problems better I added a snippet showing my two problems: The inner of the two while loops shows how I import a 1D array. In the outer loop I seperate the columns. I know that currently this is not working as all data end up in column A of the Excel sheet - so I would need to convert the number of the outer counter to A, B,... or find a different solution.
    Moreover on the snippet I placed an ActiveX Worksheet Property with the Chart Object - as I can see the difference to the Chart Object in the example code from the last link above is the color. However I'm not sure what that means and how to change/ solve this.
    And just to make sure - I know this way the VI does not run as the Chart Object is placed completely wrong - I just did it, so it is included in the snippet.
    I'd be thankful for any suggestions,
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    ExcelAreaScan.png ‏60 KB

    Hello everyone and thanks for the answers.
    I only have the LabView Student Edition available here - is the toolkit included in it too. How can I check if it is installed/ available and in case it is installed - where can I find it?
    Today I had time to take a look at the example
    Create via ActiveX Labview a XY Scatter plot graph on an excel sheet
    It almost does what I want in terms of creating a graph. The only problem I could not fix, is that in this example a sheet is created where only the graph is present. i'd like to add the graph to a previously created worksheet. Today I tried get this working but it seems I stilll don't really understand what I'm doing, I'll post a snippet of my code as soon as I can access the PC with LabView on it again.
    I also took a look at the other example for inserting 2D attays - it seems to be what I need, I just had no time so far to test it, I'll post an update when I could test it.
    Thanks for the help so far!

  • Remove shades behind lines and bars in Graphs

    Hello there, new here on the forum.
    I'm using obiee 11.
    Is there a way to remove the grey shades behind lines and bars in graphs?
    Both curious to know wether that's possible in one graph or make it standard for all graphs.
    Thanx!

    Try this
    Removing drop-shadow effect on graphs
    By default, whenever a chart is created, there is a drop-shadow effect on it. This property makes it difficult to read some of the
    charts. In order to turn it off this property, edit the file dvt-graph-skin.xml from the following location on your
    installation.
    \InstallHome\Oracle_BI1\bifoundation\web\msgdb\s_blafp\viewui\chart
    Edit the <Graph> tag, add the attribute visualEffects="NONE". (Do not remove the rest of the contents in the file). After
    editing, the contents should look like this.
    <Graph visualEffects="NONE">
    <SliceLabel>
    <!-- decimalDigitUsed is false here so that non-percentage pie slices do not pick up this value
    The DVTChartProcessor sets decimalDigitUsed to true if this is a percentage pie slice -->
    <ViewFormat decimalDigit="2" decimalDigitUsed="false"/>
    </SliceLabel>
    </Graph>
    Save the file.
    Richard Chan
    Rittman Mead Oceania

  • How to create graphs on JSP page in JDeveloper 10.1.3

    Hi all,
    Is there an easy way to create graph objects with JDeveloper 10.1.3? I have taken a look to some tutorials, but it looks like they all use the "drag/drop graph from the data control palette" method.
    E.g. I got example 88 to work from http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html, but I have no idea how to get the BIGraphDef1.xml object and how to link it to a set of data.
    Are there some tutorials to show how graphs can be used in JDev 10.1.3?

    Frank,
    This is what I did to implement the graphic manual, but I think, I forgot something...
    1. create a new application with projects DataModel and UserInterface
    2. in the DataModel I created a similar master/detail view as the one of Steve, this is named:
    TestModuleDataControl
    \--DepView
    __\--Deptno
    __\--Dname
    __\--Loc
    __\--EmpView1
    ____\--Sal
    3. I created a new jspx page and added a graph tag:
    <f:verbatim>
    <graph:Graph data="${bindings.DepartmentsEmployeesInDepartmentGraph}"
    imageHeight="200" imageWidth="400"/>
    </f:verbatim>
    4. in the page definitions I added
    <graph id="DepartmentsEmployeesInDepartmentGraph"
    IterBinding="EmployeesInDepartmentIterator"
    ControlClass="oracle.dss.graph.Graph"
    SeriesLabel="Ename"
    GraphPropertiesFileName="userinterface.BIGrap1hDef1"
    SeriesType="SINGLE_SERIES">
    <AttrNames>
    <Item Value="Sal"/>
    </AttrNames>
    </graph>
    5. I added also the iterator:
    <iterator id="EmployeesInDepartmentIterator" Binds="EmpView1" RangeSize="10"
    DataControl="TestModuleDataControl"/>
    6. I copy/pasted the BIGraphDef1.xml from Steve's project into 'Application Sources'\userinterface.
    7. in the web.xml file in WEB-INF I added:
    <servlet>
    <servlet-name>GraphGeneratorServlet</servlet-name>
    <servlet-class>oracle.jbo.html.jsp.graph.GraphGeneratorServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>GraphGeneratorServlet</servlet-name>
    <url-pattern>/GraphGeneratorServlet</url-pattern>
    </servlet-mapping>
    8. when I run the page, I can't see the graph and there are also no errors. I think I mis a global setting somewhere...
    Is there anything I forgot to do?
    note: if I add a new jsp page into steve's application, I do can see the graph if I perform the steps mentioned above...
    I just found out that, If I create the graph on a page which is in the root directory, then it works. If I put it in a subdirectory, it doesn't:
    - create graph as mentioned above on a page: web content/myGraph.jspx --> works
    - create graph as mentioned above on a page: web content/app/myGraph.jspx --> doesn't work...
    Does somebody know where to put a setting/parameter to get the Graph visible in the subdirectory app?

  • "How to create graphs in Reports"

    Hi All,
    Please anybody help me how to create graphs in the BEx Analyzer and whenever the reports will be refreshed the graphs should also be refreshed with the updated data.
    Help much appreciated.
    I will assign points.
    Thanks and Regards,
    Sunil Morwal.

    Hi Sunil,
    You can get charts in Bex Analyzer. After you execute the report, from the Tools menu > Insert Chart. You can position and edit the chart as desired and save this as a workbook.
    Hope this helps...
    Regards.

  • How to create graph through form9i

    dear,
    I mant to know how to create graph in form 9i.Right now i have no idea about graphs use in form9i.
    please reply me as soon as possible.
    my mail id is [email protected]
    If you have any answer related to this problem please mail me in my mail id that i have given .
    with regards
    monika gupta

    Hi Monika,
    http://www.oracle.com/technology/products/reports/htdocs/faq/faq_migration.htm
    http://www.oracle.com/technology/products/reports/10gr2/Reports_guide_to_changed_functionality.pdf
    http://download.oracle.com/docs/html/A90900_01/rwtutorial_graph.htm#1005697
    How do I migrate my charts from Oracle Graphics to the new graph format in Oracle Reports 10g?
    Since release 9i, Oracle Reports uses Business Intelligence Beans (BI Beans) to create and display graphs in reports. There is no direct migration path from Oracle Graphics to the BI Beans graphing functionality. As such, the user will need to rewrite all of their graphs using the new Graph Wizard within the Oracle Reports Builder 10g. Oracle Reports 10g supports over 50 graph types, including 3D graphs. However, keep in mind that it does not support some special types, such as Gantt charts.
    It seems direct graph 6i migration is not possible from reports10g.
    It is asking to use the chart wizard again with your query.
    Please follow the above two link it may helps u a lot.

Maybe you are looking for

  • Boot Camp Update Server

    I asked this question beforem but didn't receive an answer. Anyway I am still tring and get the same message. I have been trying to install windows 7 on my macbook pro. I have a clean install of mavericks on it. When I try to use bootcamp it gives me

  • Can my TV play my iPod?

    Hello! I am not technical in ANY way...so I am relying on this community to help me out. I have a Panasonic Viera from 2007 (TV Monitor). The model number is TH-50PX75U. How can I plug in my iPod and listen to music through our home theatre system? T

  • How to read content between xml tags?

    is there any way to read the content between xml tag

  • MacBook Pro (Retina, 13-inch, Early 2015) can display 4096 x 2160 at 60Hz using DP1.2??????

    MacBook Pro (Retina, 13-inch, Early 2015) can display 4096 x 2160 at 60Hz using DP1.2??????

  • Find SP used for dequeing

    Hi All, I am using ORACLE 10g. i am using AQ/Deque in my application. I want to know the list of procedures that are listening to a queue. sample script for registering such one procedure is: BEGIN dbms_aq.register ( sys.aq$_reg_info_list( sys.aq$_re