Label on Bar Graph

Dear Champs ,
I am using one Function Module that is GRAPH_MATRIX_3D.
In this i am getting the data correct and object is working fine.
I want to label the graph by putting the value on the tower like ( 300 kg, 400 kg ).
Please help me out .
I will be highly thankful to you.
Thanks and Regards
Vivek Srivastava

Hi,
May be this sample code can help you:-
REPORT Z_3DGRAPH.
*structure declaration for performance measurement
TYPES: BEGIN OF ty_performance,
company(15) TYPE c,
q1 TYPE i,
q2 TYPE i,
q3 type i,
q4 type i,
END OF ty_performance.
*structure declaration for options table
types : BEGIN OF ty_opttable,
options(30) TYPE c,
END OF ty_opttable.
*Internal table and work area declarations
DATA: it_performance TYPE STANDARD TABLE OF ty_performance,
wa_performance TYPE ty_performance.
DATA : it_opttable type standard table of ty_opttable,
wa_opttable type ty_opttable.
*initialization event
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*clearing the work areas
CLEAR WA_PERFORMANCE.
CLEAR wa_opttable.
*appending values into the performance internal table
wa_performance-company = 'Company A'.
wa_performance-q1 = 78.
wa_performance-q2 = 68.
wa_performance-q3 = 79.
wa_performance-q4 = 80.
append wa_performance to it_performance.
wa_performance-company = 'Company B'.
wa_performance-q1 = 48.
wa_performance-q2 = 68.
wa_performance-q3 = 69.
wa_performance-q4 = 70.
append wa_performance to it_performance.
wa_performance-company = 'Company C'.
wa_performance-q1 = 78.
wa_performance-q2 = 48.
wa_performance-q3 = 79.
wa_performance-q4 = 85.
append wa_performance to it_performance.
*appending values into the options internal table
wa_opttable-options = 'P3TYPE = TO'.
APPEND wa_opttable TO it_opttable.
wa_opttable-options = 'P2TYPE = VB'.
APPEND wa_opttable TO it_opttable.
wa_opttable-options = 'TISIZE = 1'.
APPEND wa_opttable TO it_opttable.
*calling the graph function module
CALL FUNCTION 'GRAPH_MATRIX_3D'
EXPORTING
col1 = 'Quarter 1'
col2 = 'Quarter 2'
col3 = 'Quarter 3'
col4 = 'Quarter 4'
dim1 = 'In Percentage%'
set_focus = 'X'
titl = 'Company Performances'
TABLES
data = it_performance
opts = it_opttable
EXCEPTIONS
others = 1.
Manas M.

Similar Messages

  • Adding data labels to column graph

    I work in the financial industry and I have to add data labels to all bars that appear in my ten year performance graphs (see http://fundinvestor.calamos.com/ClosedEndFunds/CEFund.aspx?name=CHI under the "Performance" tab as an example). Is there a script that can do this? I saw there's this technique that Adobe offers for column totals: http://livedocs.adobe.com/en_US/Illustrator/13.0/help.html?content=WS714a382cdf7d304e7e07d 0100196cbc5f-619e.html but that's not working. What am I doing wrong? Adding data labels to bars is ridiculously simple in Excel, why can't I find the way to do it easily in Illustrator?

    http://help.adobe.com/en_US/Illustrator/14.0/WS714a382cdf7d304e7e07d0100196cbc5f-619ea.htm l
    That should do the trick.
    Mylenium

  • Using stored parameter from data control class with stacked bar-graph

    Hi folks,
    I'm relatively new to ADF & EJB so I want to apologise in advance if this question seems rudimentary to many of you.
    Edit:  I should have mentioned that I'm using JDeveloper 11.1.1.5
    I'm having a hard time determining how to retrieve the value from a variable to be assigned to a property of the bar graph I'm trying to display on my JSF page.
    I have tried to briefly summarise the logic below for reference.
    I have a data control class (ActivityChart) that includes a method "getActivityDetail" returns a List of custom Objects (ActivityDTO) that are the underlying data for my bar graph.
    public class ActivityChart {
        private Double axisScale;
        public ActivityChart() {
            super();
            axisScale = 0.0;
        public List<ActivityDTO> getActivityDetail(List<String> businessUnits) {
            List<ActivityDTO> returnNewList = new ArrayList<ActivityDTO>();
            List<TransactionDTO> dataList = new ArrayList<TransactionDTO>();
            TransactionSessionBean transBean = lookupTransactionSessionBean();
            if (businessUnits != null && !businessUnits.isEmpty()){
                dataList = transBean.getActivityData(SystemUtil.getCurrentUser(), businessUnits);           
                returnNewList = processTransactions(dataList);
                axisScale = calcAxisScale(returnNewList);
            return returnNewList;
    ...The TransactionDTO object is basically a mirror of the entity object to store the fields from the queried db transactions.
    The ActivityDTO object contains a String value (x-axis label) and 3 Double values for the values required for the bar graph.
    What I'm trying to do is dynamically set the scale for the 2 y-axes (I'm using a dual-axis stacked bar graph) because the auto calculated values are not aligned.
    Right now I've got the two relevant elements of the bar graph hard-coded with a specific axis value:
    <dvt:y1Axis axisMaxAutoScaled="false" axisMaxValue="100.0"/>
    <dvt:y2Axis axisMaxAutoScaled="false" axisMaxValue="100.0"/>.
    The value I want to use for the Y-axis is calculated and stored in the "axisScale" variable in the above class.
    Really at a loss of how to move forward from here.
    Would very much appreciate any guidance/direction offered.
    Thanks,
    Karim
    Edited by: 973742 on Nov 28, 2012 8:12 AM

    Looks like I may have found the answer!
    I had to set up the variable in the bindings for the page and then reference the variable from the binding and add the property inputValue.
    ie. value="#{bindings.axisScale.inputValue}"

  • Bar graph error

    I made a program that shows bar graphs, well it's suppose to. Its not working, the compiler says something about the for statements needing ';'s...
    help please!
    import java.awt.*;
    import java.applet.*;
    import java.awt.event*;
    public class Bars extends Applet implements ActionListener
         int offset = 75; //displace graph vert and horiz from origin
         int height = 150, width = 240;
         int vert_div = height/5; //vert_Div = 5
         int horiz_div = width/data.length; //horiz_div = 4 (4 entries)
         Label prompt = new Label ("Enter a value for the bar graph.");
         final static String data_label[] = {"T1","T2","T3","T4"};
         TextField input = new TextField(3);
         static int data[] = new int[4];
         int numb_entries = 1;
         public void init()
              add(prompt);
              add(input);
              resize(400,275);
              input.addActionListener(this);
         public void actionPerformed( ActionEvent e )
              int numb = new Integer(input.getText()).intValue();
              if(numb_entries<5)
                   data[numb_entries-1] = numb;
                   numb_entries++;
                   input.selectAll(); // places cursor in text box after first entry
                   if(numb_entries == 5)
                        input.removeActionListener(this);
                        remove(input); // deletes component from window
                        remove(prompt); // remove() is opposite of add()                    
         public void paint(Graphics g)
              if(numb_entries==5)
                   g.drawString("value 1 = "+data[0]+", value 2 = "+data[1] +
                                  ", value 3 = "+data[2]+", value 4 = "+data[3],70,30);
                   g.setColor(Color.black);
                   g.drawLine(offset+width,offset,offset+width,offset+height); //y-axis
                   for (int i=0;i<=5;i++) //y tick marks
                        g.drawString(String.valueOf(i*20),offset+width+10,
                                        offset+height-(i*vert_div));
                        g.drawLine(offset,offset+height-(i*vert_div),offset+width+5,
                                     offset+height-(i*vert_div)); //draws horiz gridlines
                   g.drawLine(offset,offset+height,offset+width,offset+height);//x-axis
                   for (int i=0;i<data.length;i++)
                        g.drawString(data_label,
                             offset+horiz_div*i+horiz_div/2,offset+height+20);
                        g.drawLine(offset+horiz_div*i+horiz_div/2,offset+height,
                             offset+horiz_div*i+horiz_div/2,offset+height+20); //x-ticks
                   g.setColor(Color.red);
                   for (int i=0,i<data.length;i++)
                        int bar_height = data[i]*height/100;
                        g.fillRect(offset+horiz_div*i+horiz_div/4,
                             offset+height-bar_height,horiz_div/2,bar_height);
                   resize(400,275); //paint bars and data values

    change
    import java.awt.event*;with
    import java.awt.event.*;

  • Stacked bar graph requirement in OBIEE 11g

    Hi,
    I have stacked bar graph. I want to display units on the middle of each stack. I can display units, but by default these units are displayed on top of each stack. I checked properties of data markers, but I did not get any option to display data in the middle of stack.
    I am using OBIEE 11g.
    Is there any way to accomplish this?
    Thanks.

    We recently logged an Enhancement Request for the same with Oracle: Bug 15928667 : ENH DISPLAY DATA LABELS IN STACKED BAR CHART WITHIN THE BAR GRAPH ITSELF
    There is no way out-of-box to do this as of right now.
    Please assign points if helpful/correct.

  • Can't show data labels in pie graphs as decimal number if the crosstab data

    I want to show my data labels in diagrams, as percent values, with three decimals.
    It occurs (in version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26)) it is only possible if the data format of the crosstab data also shows data with decimals. If the data are in integer format, the graphs data labels can only be shown in integer as well.
    Does anyone know how to fix the problem?
    In version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.48.18) we can have a crosstab showing integers and a pie graph showing labels of pie slices where the labels are in percent with three decimals. It seems it does not work in the newer version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26)
    Thanks in advance

    It seems I have another similar problem in version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26):
    I have a Bar (Percent) graph based on a crosstab where the data is formatted as number with two decimals.
    The labels in the graph shows as number (0,76 instead of 76% and 0,13 instead of 13%). I want them to be shown in percent format.
    The Data Label format is set to “Number” with two decimals. I can change the Data Labels to Percent with two decimals and then it shows the data labels in the graph exactly as I want it. But after I have saved the workbook and then opened it again the changes has been “revoked” and is once again set to number with two decimals instead of percent.
    thanks (again) in advance

  • Problem with Bar Graph

    Hi Experts,
    i am using obiee 11g and i build a report using bar graph view.
    here problem is in horizontal axis some of my values are missing alternative values are only showing in.
    Bars are showing but labels for that corresponding bars are not displaying .
    pls help me

    Increase the width of the graph something 1000 or so.

  • Stacked + adjacent bar graph

    Can Discoverer do something like this:
    http://i18.tinypic.com/6fi179s.png
    where stacked bars are "grouped" adjacent to one another?
    Thanks,
    John

    We recently logged an Enhancement Request for the same with Oracle: Bug 15928667 : ENH DISPLAY DATA LABELS IN STACKED BAR CHART WITHIN THE BAR GRAPH ITSELF
    There is no way out-of-box to do this as of right now.
    Please assign points if helpful/correct.

  • ELOCATION_MERCATOR.WORLD_MAP errors for pie/bar graph theme below zoom 5

    Hi,
    I am trying to create a map using ADF DVT map component in my jspx page. I am using 'elocation_mercator.world_map'. I am creating a pie graph theme over the base world map. For some reason whenever I zoom below 5, i get following javascript error
    [MVThemeBasedFOIControl.foiLoaded] MAPVIEWER-05523: Cannot process response from MapViewer server. (<?xml version="1.0" encoding="UTF-8" ?> <oms_error> MAPVIEWER-06009: Error processing an FOI request.
    Root cause:FOIServlet:null</oms_error>)
    The Pie graphs displays fine at or above zoom level 5. I tried the same thing using my local map viewer instance which has mvdemo.demo_map as the base map. The pie graph displays fine at all zoom levels using my local map. Can anybody tell me what may be the problem when I use the elocator world_map. I can't even look at the logs as it's a hosted service.

    Here are the steps to reproduce the problem
    1) Create a jspx page.
    2) From the component palette on the right hand side, select ADF Data Visualizations and then click on Map in the Geographical Map section. This will open an ADF Map configuration window.
    3) Create a new Map Configuration by providing an id and a URL connection. If you have not created a URL Connection to elocation service, create a new connection to "http://elocation.oracle.com/mapviewer" and select that connection.
    4) You will see data source as ELOCATION_MERCATOR and Base map as WORLD_MAP selected. Enter startingY="38.648911" startingX="-98.349609" , select mapZoom="5" and Click on OK.
    5) Now create an entity object and a view object based on the STATES table in the MVDEMO database and add it to an application module.
    6) Refresh the application module data control. You should a new StatesView1 data control.
    7) Drop it on the map and select Bar graph theme. This will open a Bar Graph theme configuration window for the Map.
    8) In the Name select MAP_STATES_ABBRV. In the location column select STATE_ABRV.
    9) In the Data Location Select Location as StateAbrv and Location Label as State.
    10) Enter Series Attribute as Totpop and Label as Total Population. Enter series attribute as Female and Label as Female Population. Click OK.
    11) Now Run this page.
    12) The page runs fine displaying the Bar chart. Now zoom out. You will get error
    '[MVThemeBasedFOIControl.foiLoaded] MAPVIEWER-05523: Cannot process response from MapViewer server. (<?xml version="1.0" encoding="UTF-8" ?> <oms_error> MAPVIEWER-06009: Error processing an FOI request.
    Root cause:FOIServlet:null</oms_error>)'
    When you say that we should use elocation for map tiles not for FOI rendering, does that mean that I should not use the themes provided by elocation. When I enter the base URL to a mapviewer instance in my map client, the base map and the themes are displayed from the database used by the mapviewer instance. So, how can I use my own mapviewer for FOI rendering? Can you please explain a little more. Thanks.

  • A bar graph problem

    hi all,
    sorry if my question is not clear, try my best to describe.
    i currently creating a bar graph applet, where this applet take different "group" of data / value, e.g. (68, 268,2680, 28 and 8). and here the maximum value is 2680, other group may NOT so. so for being the bar graph display, i have an applet that has a "fixed" maximum width of 700, i need my bar graph to have only 10 columns and also i need to minus out 10 from each column for other purposes, so i take (700 / 10) - 10 = 60, but here come the real problem, if i take 268 * 60 = 16080, that is incorrect! That is i know that i had to divide the 700 with 1000, because (700 / 1000) - (10 / 1000) = 0.69, then 268 * 0.69 = 184.92, that seem OK! but, but it still ran out of the expected result, the bar width will be much more shorter than expected (only those higher data value), why? my code will be as follow:
       if (highestWidth >= 1001)
          maxDetector = 10000;
       else if (highestWidth >= 101)
           maxDetector = 1000;
       else if (highestWidth >= 11)
           maxDetector = 100;
       else
           maxDetector = 10;
       maxSingleWidth = (axisPanel.getWidth() / maxDetector) - (10 / (maxDetector / 10));so, at for loop:
    for (i=0; i <= 9; i++){
       barPanel.setBounds(x, y, (dataValue * maxSingleWidth), height);
    any help will be very very much appreciated!!!

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    public class BarGraph
        public BarGraph()
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new BarGraphPanel());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        public static void main(String[] args)
            new BarGraph();
    class BarGraphPanel extends JPanel
        int[] data;
        int maxValue;
        Font font;
        NumberFormat nf;
        final int PAD = 40;
        public BarGraphPanel()
            data = new int[] { 75, 12, 23, 44, 98, 32, 53, 6 };
            font = new Font("lucida sans demibold", Font.PLAIN, 15);  // j2se 1.3+
            nf = NumberFormat.getNumberInstance();
            nf.setMaximumFractionDigits(1);
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            double w = getWidth();
            double h = getHeight();
            // ordinate
            g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD));
            // ordinate labels
            String[] labels = getLabels();
            float labelScale = (float)(h - 2*PAD)/(labels.length - 1);
            g2.setFont(font);
            FontRenderContext frc = g2.getFontRenderContext();
            for(int j = 0; j < labels.length; j++)
                float width = (float)font.getStringBounds(labels[j], frc).getWidth();
                float height = font.getLineMetrics(labels[j], frc).getAscent();
                float x = (PAD - width)/2;
                float y = (float)(PAD + j*labelScale + height/2);
                g2.drawString(labels[j], x, y);
            // abcissa
            g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD));
            // plot data
            g2.setPaint(Color.red);
            double xInc = (w - 2*PAD) / data.length;
            double yScale = getValueScale(h);
            double x1, y1, x2, y2;
            for(int j = 0; j < data.length; j++)
                x1 = PAD + j * xInc;
                y1 = h - PAD;
                x2 = x1 + xInc;
                y2 = y1 - data[j] * yScale;
                g2.draw(new Line2D.Double(x1, y1, x1, y2));    // left vertical
                g2.draw(new Line2D.Double(x1, y2, x2, y2));    // top of bar
                g2.draw(new Line2D.Double(x2, y2, x2, y1));    // right vertical
        private double getValueScale(double h)
            int max = getMaxValue();
            return (h - 2*PAD) / max;
        private int getMaxValue()
            int max = Integer.MIN_VALUE;
            for(int j = 0; j < data.length; j++)
                if(data[j] > max)
                    max = data[j];
            return max;
        private String[] getLabels()
            int max = getMaxValue();
            double inc = max/3d;
            double next = max;
            String[] s = new String[4];
            for(int j = 0; j < 4; j++)
                s[j] = nf.format(next - j * inc);
            return s;
    }

  • Using bar graph

    Hello,
    Using obiee 11g,
    I have a bar graph where i have put default height and weight.
    Now the problem is i have my x axis based on a prompt because of which i can have my width bit dynamic.
    My x axis is username
    Whenever it takes more values i have seen that the some of the names are missing.
    graph will be drawn but no names for some bars.
    When i inc the width it becomes visible.
    Is there a solution other then inc the width of the graph because everytime i cannot change the wdth of the graph and also i cannot predict how many users will be?
    Thanks

    Hello,
    Thanks for the reply.
    Then ill inc the width of the graph if there is no other solution.
    One more thing wanted to know related to stacked bar graph the numbers on the graphs comes as overridden when i show them always i.e. Data labels,
    if the stacked bar one above another is too close.
    Is this way 11g behaves or is there any workaround.
    Thanks

  • Legends on any bar graph

    Hi
    Please guide/ suggest how to get legends permanently displayed on the any bar graphs in the SOD Analytics dashboard. As of now the legends are visible only when the curser is on that bar.
    regards
    NSC

    It's not clear if you are referring to Values or Legend, so I'll address both. You can find the options mentioned below in the chart Edit View (same applies for Pivot Table charts).
    By default, the value of a bar will appear when you roll your mouse over it. If you want the value to appear permanently, then click the "Chart Properties" (pointy finger icon) and choose "Show Data Labels: Always".
    Some chart types will not, by default, show a legend (indicating what each color stands for). To show a legend, you click on "Additional Charting Options" (arrow pointing right icon), choose the "Legend" tab and select the location for the legend to appear.

  • To draw  bar graph

    hi i am doing a portal there i want show the selected row in a bar graph format. is there any format or third party tool so that i can icorporate for drawing graph. nor should i alter my servlets code for it.

    hello vijay,
    i got one code from google about the drawing of the graph. after seeing that code , i think it will not take the data automatically it should manually.
    // BarChart.java
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * Generic bar chart class with full selection set support.
    * @author Melinda Green
    public class BarChart extends JPanel {
    * implemented by data objects to be charted.
    public interface BarValue {
    /** specifies the hight (data value) of this bar. */
    public float getBarValue();
    /** optional summary text suitable for tool-tip or other display.*/
    public String getInfoText();
    public final static int
    SORT_NONE = 0,
    SORT_ASCENDING = 1,
    SORT_DESCENDING = 2;
    public final static int
    LINEAR_SCALE = 0,
    LOG_SCALE = 1;
    private static final int
    CHART_LEFT_PAD = 50,
    CHART_RIGHT_PAD = 25,
    CHART_TOP_PAD = 50,
    CHART_BOTTOM_PAD = 50,
    CHART_MIN_DIM = 80,
    MAX_TIC_LABELS = 10, // greatest number of axis tic labels
    TIC_LENGTH = 6, // length of axis tic marks
    MIN_BOX_WIDTH_FOR_SEPERATOR = 8; // looks crummy if too small
    private final static String NO_VALUES_MSG = "No Bar Values Set";
    private static final Color NORMAL_COLOR = Color.blue.darker();
    private static final Color HIGHLIGHT_COLOR = Color.yellow;
    private String xAxisLabel, yAxisLabel;
    private int xScaleType, yScaleType; // log or linear
    private SelectionSet selections;
    private BarValue barValues[] = null;
    private float highVal;
    private int anchorSelectionIndex = 0; // base index for range selections
    private final Rectangle tmpRect = new Rectangle(); // scratch space
    * constructs a BarChart panel.
    * @param xAxisLabel - String to draw on x axis - optional.
    * @param yAxisLabel - String to draw on y axis - optional.
    * @param logScale determines whether to draw x axis on log or linear scale.
    * @param sel is an optional SelectionSet. the bar chart class always
    * maintains a SelectionSet object which it updates on UI selections.
    * callers may call getSelectionSet to monitor BarChart selections and
    * to make selection changes which the BarChart will respond to. if
    * a non-null SelectionSet parameter is provided here, the BarChart will
    * listen to and modify the given one instead.
    public BarChart(String xAxisLabel, String yAxisLabel,
    int xAxisScaleType, int yAxisScaleType, SelectionSet sel)
    this.xAxisLabel = xAxisLabel;
    this.yAxisLabel = yAxisLabel;
    this.selections = sel == null ? new SelectionSet(BarValue.class) : sel;
    setScaleType(Axis.X_AXIS, xAxisScaleType);
    setScaleType(Axis.Y_AXIS, yAxisScaleType);
    setMinimumSize(new Dimension(
    CHART_MIN_DIM + CHART_LEFT_PAD + CHART_RIGHT_PAD,
    CHART_MIN_DIM + CHART_TOP_PAD + CHART_BOTTOM_PAD));
    addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent me) {           
    int b = barAt(me.getPoint().x, me.getPoint().y);
    if(b < 0) {
    if(!me.isControlDown())
    selections.clear(BarChart.this);
    repaint();
    return;
    BarValue selectedBar = barValues;
    selections.beginEditing(BarChart.this, false);
    if(me.isShiftDown())
    selectRange(b, anchorSelectionIndex);
    else if(me.isControlDown())
    selections.toggle(selectedBar, BarChart.this);
    else
    selections.setElements(selectedBar, BarChart.this);
    if(!me.isShiftDown())
    anchorSelectionIndex = b;
    selections.endEditing(BarChart.this);
    repaint();
    addMouseMotionListener(new MouseMotionAdapter() {
    public void mouseDragged(MouseEvent me) {
    selectRange(barAt(me.getPoint().x), anchorSelectionIndex);
    repaint();
    } // end constructor
    public void setBarValues(BarValue barValues[], final int sortType) {
    this.barValues = new BarValue[barValues.length];
    System.arraycopy(barValues, 0, this.barValues, 0, barValues.length);
    highVal = Float.MIN_VALUE;
    for(int i=0; i<barValues.length; i++)
    highVal = Math.max(highVal, barValues.getBarValue());
    if (sortType != SORT_NONE) {
    Arrays.sort(this.barValues, new Comparator() {
    public int compare(Object a, Object b) {
    float val1 = ((BarValue)a).getBarValue();
    float val2 = ((BarValue)b).getBarValue();
    if (sortType == SORT_ASCENDING) {
    float tmp = val1;
    val1 = val2;
    val2 = tmp;
    return val2 - val1 > 0 ? 1 : val2 == val1 ? 0 : -1; // NOTE: reverse numeric order
    repaint();
    } // end setBarValues
    public void setScaleType(int axis, int type) {
    if( ! (type == LOG_SCALE || type == LINEAR_SCALE))
    throw new IllegalArgumentException("BarChart.setScaleType: bad scale type " + type);
    if(axis == Axis.X_AXIS)
    xScaleType = type;
    else
    yScaleType = type;
    repaint();
    * returns the selection set object being used.
    * this is either the one provided to the constuctor,
    * generated internally otherwise.
    public SelectionSet getSelectionSet() {
    return selections;
    private void selectRange(int b1, int b2) {
    if(b1 < 0 || b2 < 0)
    return;
    selections.clear(BarChart.this);
    int range_start = Math.min(b1, b2);
    int range_end = Math.max(b1, b2);
    for(int i=range_start; i<=range_end; i++)
    selections.addElement(barValues[i], BarChart.this);
    private void computeBar(int barID, Rectangle rect) {
    int chart_width = getWidth() - (CHART_LEFT_PAD+CHART_RIGHT_PAD);
    int chart_height = getHeight() - (CHART_TOP_PAD+CHART_BOTTOM_PAD);
    int chart_right = CHART_LEFT_PAD + chart_width;
    int chart_bottom = CHART_TOP_PAD + chart_height;
    rect.height = Math.round(barValues[barID].getBarValue() / highVal * chart_height);
    rect.y = CHART_TOP_PAD + (chart_height - rect.height);
    if (xScaleType==LINEAR_SCALE) {
    rect.width = Math.round(chart_width / (float)barValues.length);
    rect.x = CHART_LEFT_PAD + barID * rect.width;
    else {
    rect.x = 0;
    if (barID > 0)
    rect.x = Axis.plotValue(barID,
    .5f, barValues.length, // value range
    CHART_LEFT_PAD, getWidth()-CHART_RIGHT_PAD, // screen range
    true, getHeight());
    int next = Axis.plotValue(barID+1,
    .5f, barValues.length, // value range
    CHART_LEFT_PAD, getWidth()-CHART_RIGHT_PAD, // screen range
    true, getHeight());
    rect.width = next - rect.x;
    rect.x += CHART_LEFT_PAD;
    public void paint(Graphics g) {
    super.paint(g);
    Point center = new Point(getWidth()/2, getHeight()/2);
    if(g instanceof Graphics2D)
    center.x -= stringWidth(NO_VALUES_MSG, g) / 2;
    if (barValues == null || barValues.length == 0) {
    g.drawString(NO_VALUES_MSG, center.x, center.y);
    return;
    // draw the data boxes
    int lastxend = 0;
    int chart_width = getWidth() - (CHART_LEFT_PAD+CHART_RIGHT_PAD);
    boolean drawBoxSeperators = chart_width / (float)barValues.length > MIN_BOX_WIDTH_FOR_SEPERATOR;
    for(int i=0; i<barValues.length; i++) {
    g.setColor(selections.contains(barValues[i]) ? HIGHLIGHT_COLOR : NORMAL_COLOR);
    computeBar(i, tmpRect);
    if(i == 0)
    lastxend = tmpRect.x + tmpRect.width;
    else {
    if (tmpRect.x > lastxend) {
    int diff = tmpRect.x - lastxend;
    tmpRect.x = lastxend;
    tmpRect.width += diff;
    lastxend = tmpRect.x+tmpRect.width;
    //System.out.println(tmpRect.x + "," + tmpRect.y + " w=" + tmpRect.width + " h=" + tmpRect.height + " lastxend=" + lastxend);
    g.fillRect(tmpRect.x, tmpRect.y, tmpRect.width, tmpRect.height);
    g.setColor(Color.gray);
    if(drawBoxSeperators && i > 0) // draw a line between each box pair
    g.drawLine(tmpRect.x, tmpRect.y, tmpRect.x, tmpRect.y+tmpRect.height);
    // draw the axes
    g.setColor(Color.black);
    Axis.drawAxis(Axis.X_AXIS, MAX_TIC_LABELS, TIC_LENGTH,
    .5f, barValues.length, // value range
    CHART_LEFT_PAD, getWidth()-CHART_RIGHT_PAD, // screen range
    CHART_BOTTOM_PAD, xScaleType==LOG_SCALE, getHeight(), g);
    Axis.drawAxis(Axis.Y_AXIS, MAX_TIC_LABELS, TIC_LENGTH,
    0, highVal, // value range
    CHART_BOTTOM_PAD, getHeight()-CHART_TOP_PAD, // screen range
    CHART_LEFT_PAD, yScaleType==LOG_SCALE, getHeight(), g);
    Font bold = g.getFont().deriveFont(Font.BOLD);
    g.setFont(bold);
    if (xAxisLabel != null) {
    g.drawString(xAxisLabel, getWidth()-stringWidth(xAxisLabel, g)-20, getHeight()-10);
    if (yAxisLabel != null) {
    g.drawString(yAxisLabel, CHART_LEFT_PAD-40, 25);
    } // end paint
    private int barAt(int x, int y) {
    if(barValues == null)
    return -1;
    for(int i=0; i<barValues.length; i++) {
    computeBar(i, tmpRect);
    if(rectContainsPoint(tmpRect, x, y))
    return i;
    return -1;
    private static boolean rectContainsPoint(Rectangle rect, int x, int y) {
    return
    rect.x <= x && x <= rect.x+rect.width &&
    rect.y <= y && y <= rect.y+rect.height;
    private int barAt(int x) {
    if(barValues == null)
    return -1;
    for(int i=0; i<barValues.length; i++) {
    computeBar(i, tmpRect);
    if(tmpRect.x <= x && x <= tmpRect.x+tmpRect.width)
    return i;
    return -1;
    public static int stringWidth(String str, Graphics g) {
    if(g instanceof Graphics2D)
    return (int)(g.getFont().getStringBounds(str, ((Graphics2D)g).getFontRenderContext()).getWidth()+.5);
    else
    return g.getFontMetrics().stringWidth(str);
    private static class TestDatum implements BarChart.BarValue {
    private int id;
    private int dataValue;
    public TestDatum(int id, int value) {
    this.id = id;
    this.dataValue = value;
    public int getID() { return id; }
    public int getDataValue() { return dataValue; }
    public float getBarValue() { return getDataValue(); }
    public String getInfoText() { return "id # " + id + ", " + dataValue + " value"; }
    * example data. unsorted but will have BarChart perform the sorting.
    private final static TestDatum testSamples[] = new TestDatum[] {
    new TestDatum(12, 2020),
    new TestDatum(88, 2300),
    new TestDatum(43, 3001),
    new TestDatum(81, 2405),
    new TestDatum(10, 2069),
    new TestDatum( 2, 2054),
    new TestDatum(74, 2339),
    new TestDatum(56, 2020),
    new TestDatum(57, 2021),
    new TestDatum(58, 2023),
    new TestDatum(59, 2022),
    new TestDatum( 4, 4700),
    new TestDatum(98, 3100),
    new TestDatum(90, 3454),
    new TestDatum(33, 2560),
    new TestDatum(99, 2299),
    new TestDatum(78, 2020),
    new TestDatum(65, 2020),
    public static void main(String args[]) {
    SelectionSet selections = new SelectionSet(TestDatum.class);
    selections.addSelectionSetListener(new SelectionSetListener() {
    public void selectionSetChanged(SelectionSet set, Object source) {
    System.out.println("main: " + set.getNumElements() + " selected ");
    BarChart chart = new BarChart("Number of Samples", "Data Value",
    BarChart.LOG_SCALE, BarChart.LINEAR_SCALE, selections);
    chart.setBarValues(testSamples, BarChart.SORT_DESCENDING);
    JFrame frame = new JFrame("Bar Chart Test");
    frame.getContentPane().add(chart);
    frame.setSize(new Dimension(500, 500));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    } // end class BarChart

  • Help Needed : Changing the Color of Bar Graph Dynamically

    Hi..
    Is der any body to help me out...?
    My Question is :- How to change the color of Bar graph Dynamically..
    For example (Assume when one of the Bar Graph crosses certain limit of Y axis value mentioned, the graph must be changed into RED color)
    Thanks in Advance
    Edited by: user12873839 on Mar 30, 2010 10:03 PM

    Manoj,
    You have to create the entire chart manually. follow the below steps. You can refer to the anychart website for more help on different tags and features.
    1. Enter the following code in the html header of the page
    <script src="#WORKSPACE_IMAGES#AnyChart.js"  type="text/javascript" > </script>2. Create an ON Demand Application process by going to the Home>Application Builder>Application #>Shared Components>Application Processes
    3. Click On Create
    4. Enter the name as DYNAMIC_BAR_GRAPH_CHART
    5. Select the processing point as On Demand
    6. Click on Nxt
    7. Enter the following code in the processing text
    DECLARE
    BEGIN
    OWA_UTIL.mime_header ('text/xml', FALSE);
    OWA_UTIL.http_header_close;
    HTP.p ('<?xml version = "1.0" encoding="utf-8" standalone = "yes"?>');
    HTP.p ('<anychart>');
         HTP.p ('<settings>');
              HTP.p ('<animation enabled="True"/>');
         HTP.p ('</settings>');
      HTP.p ('<charts>');
       HTP.p ('<chart plot_type="CategorizedVertical">');
         HTP.p ('<data_plot_settings default_series_type="Bar">');
              HTP.p ('<bar_series>');
                        HTP.p ('<tooltip_settings enabled="True">');
                        HTP.p ('<position valign="Top" halign="Right"/>');
                        HTP.p ('<format> Name: {%Name}');
                        HTP.p ( 'Value : ${%YValue}{numDecimals:0}');
                        HTP.p ('</format>');
                        HTP.p ('<font bold="false"/>'); 
                        HTP.p ('<background>');
                        HTP.p ('<corners type="Rounded" all="3"/>');
                        HTP.p ('<border type="Solid" color="DarkColor(%Color)" thickness="2"/>');
                        HTP.p ('</background>');
                   HTP.p ('</tooltip_settings>');
              HTP.p ('</bar_series>');
         HTP.p ('</data_plot_settings>');
         HTP.p ('<data>');
              HTP.p ('<series name="series 1">');
               FOR cThis IN (select table2.name, table2.value
                                  from table1,table2,table3
                                  where table1.T1ID = table3.T3ID
                                  and table2.T3ID = table3.T3ID
                                  and table3.C_ID=1
                                  and table3.A_ID=1
                        ORDER BY table2.name )
              LOOP
                   IF cThis.value > 90 THEN
                        HTP.p ('<point name="' || cThis.name || '" y="'|| cThis.value || '" color="red"/>');
                    ELSE
                        HTP.p ('<point name="' || cThis.name || '" y="'|| cThis.value || '" />');
                   END IF;
              END LOOP;
              HTP.p ('</series>');
         HTP.p ('</data>');
         HTP.p ('<chart_settings>');
              HTP.p ('<title>');
                   HTP.p ('<text>Chart Title</text>');
              HTP.p ('</title>');
              HTP.p ('<axes>');
                   HTP.p ('<y_axis>');
                        HTP.p ('<title>');
                             HTP.p ('<text>Value</text> ');
                        HTP.p ('</title>');
                        HTP.p ('<labels>');
                             HTP.p ('<format>${%Value}{numDecimals:0}</format>');
                        HTP.p ('</labels>');
                   HTP.p ('<axis_markers>');
                   HTP.p ('</axis_markers>');
                   HTP.p ('</y_axis>');
                   HTP.p ('<x_axis position="Normal" align="inside">');
                   HTP.p ('<labels display_mode="Rotated" rotation="90" align="inside" />');
                   HTP.p ('<title>');
                        HTP.p ('<text>Name</text> ');
                   HTP.p ('</title>');
                   HTP.p ('</x_axis>');
              HTP.p (' </axes>');
         HTP.p ('</chart_settings>');
        HTP.p ('</chart>');
      HTP.p ('</charts>');
    HTP.p ('</anychart>');
    htmldb_application.g_unrecoverable_error := true;
    END;8. Click on Create Process
    Now we will create a html region to display the graph.
    9. Create a new region of type HTML on the same page and select the region template as no template.
    10. Enter the following code in the region source
    &lt;div id="DynamicaBarGraph"></div>
    &lt;script type="text/javascript" language="javascript">
    function DynamicaBarGraph()
    var DynamicaBarGraph = new AnyChart('/i/flashchart/swf/AnyChart.swf');
    //    DynamicaBarGraph.width = "400";
    //    DynamicaBarGraph.height = "400";
    DynamicaBarGraph.addEventListener('pointClick', onDynamicaBarGraphClick);
        var DynamicaBarGraphData = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=DYNAMIC_BAR_GRAPH_CHART',0);
        gReturn = DynamicaBarGraphData.get();
        DynamicaBarGraph.setData(gReturn);
        DynamicaBarGraph.write("DynamicaBarGraph");
    function onDynamicaBarGraphClick(e)
    // Read point name
         name=e.data.Name;
    // Read point value
         value=e.data.YValue;
    // You can add onclick even here using the values name and value
    DynamicaBarGraph();
    </script> Hope it helps. Thanks.
    Regards,
    Manish

  • Data display on Bar graphs - Needs help

    Hi,
    I am facing a problem with discoverer's bar graphs.
    There is a 2D Bar Graph, which is required to display the respective strength for all the classes on the axis(e.g regionwise sales for North, West, East, South). In Oracle discoverer the sales is shown only when the mouse is pointed over the respective bar but that too at the bottom. The fixed values of the sales is not being displayed above each bar permanently.
    But the client requirement is to display the strength for each class above each bar numerically so that a print out can be taken along with values.
    Please suggest how can this be done.
    Goga

    On the Plot Area tab, check the "Show Data Labels for bars". To the right of that, clicking the "Options" button will let you place the labels above or in the bars.
    Also, check that the graph background color is not the same as the font color.

Maybe you are looking for

  • Connect my laptop to my tv for display

    i cannot connect to my tv with my hdmi cord that i have already used for my xbox so i know the cord works but im just trying to watch movies on my tv coming from my laptop ive used the support assisstant and also did research on google to fix the iss

  • Problem in creating Excel file

    Dear all, i have occured aproblem while creating an Excel file while using JSP. in my jsp file i have given the two codes of line: <% response.setContentType("application/vnd.ms-excel"); response.addHeader("Content-Disposition", "attachment"); %> whi

  • How to incorporate live tiles into a Project Siena app (kinda)

    Hi guys, I have been playing around with getting some live tiles into my project siena app (Astronomy Action Centre), and at last I have managed it. What I did was as follows Publish your app as normal and import it into Visual Studio When you have i

  • "The upload has failed. There was a problem running a virus scan for the file."  any ideas???

    "The upload has failed. There was a problem running a virus scan for the file. " This is the message i get when tryng to update any ideas?

  • Page down - how can I test it?

    My page has been taken down due to bandwidth excess, but I'd like to test run it so that it`s ready for uploading when the time comes. I want to ccheck that the links work, etc. Sort of like an offline version of it, but just like it would work when