Home Overview Examples Support Download Purchase

Frequently Asked Questions

Last updated: 24 Feb 2002


The Odesys Charts Frequently Asked Questions are divided into the following categories:

Getting Started:

  1. What is Odesys Charts?
  2. What is the difference between the Server and the Client Editions of Odesys Charts 2.0?
  3. When to use Odesys Charts 2.0 Client Edition(CE)?
  4. When to use Odesys Charts 2.0 Server Edition(SE)?

Installation/Configuration:

  1. What are the system requirements?
  2. How do I install Odesys Charts CE?
  3. How do I install Odesys Charts SE?

More About Odesys Charts:

  1. "Series and Categories" in Odesys BarChart. What are they?

Examples:

  1. How do I draw a Bar chart in a Frame and run it as a stand-alone application?
  2. How can I modify the Y-Axis so that the values which appear there do not show any decimal precision?
  3. How can I display a line graph that has a line that goes only partway across the axis?
  4. Is it possible to display a Y axis label rotated (so that the text is sideways, going up and down the Y axis)?

Getting Started

  1. What is Odesys Charts?

    Odesys Charts 2.0 is a set of chart components, applets and utility classes that allow various charts to be shown in web pages as applets or images, or used directly in the GUI of Java applets and applications.
    Odesys Charts 2.0 is packeged in two editions Client Edition (CE) and Server Edition (SE).

  2. What is the difference between the Server and the Client Editions of Odesys Charts 2.0?

    Odesys Charts 2.0 Client Edition is a set of Applets that run on the client browser while Odesys Charts 2.0 Server Edition is a set of components that generate jpeg images on the server. The Client Edition is compiled using JDK 1.0.2 to ensure maximum compatibility while the Server Edition uses Java 2 features to improve the quality of the images. Both editions contain the full set of chart Components.

  3. When to use Odesys Charts 2.0 Client Edition(CE)?

    Odesys Charts 2.0 Client Edition is a better choice when no Java code can be run on the web server. Another reason to use CE is to provide high level of interaction between the user and the chart. The chart Applets are easy to customize and can actively interact with the user without having to access the web server.

  4. When to use Odesys Charts 2.0 Client Edition(SE)?

    Odesys Charts 2.0 Server Edition is a better choice when no Java code can be run on the web browser. This allows better compatibility. Another strong reason is when generating printable web content. The images usualy print better than the Applets and more consistenly among the diferent web browsers.


Installation/Configuration

  1. What are the system requirements?

    Odesys Charts 2.0 CE requires the client browsers to be Java enabled. It is build using JDK 1.0.2 and therefore should theoretically work on any JDK 1.0.2 compliant browser.
    Odesys Charts 2.0 SE is built using JDK 1.2 and uses the package com.sun.image.codec.jpeg, which is not part of the Java 2 Platform, but is provided with Sun's Java 2 SDK. Therefore Odesys Charts 2.0 SE requres Sun's Java 2 Runtime Environment. Odesys Charts 2.0 SE will most likely be used by either Servlet or JSP so it requires a Servlet/JSP enabled web server.

  2. How do I install Odesys Charts CE?

    Odesys Charts 2.0 CE is a set of Java applets packaged in the charts20ce.jar file and its instalation is no diferent that the instalation of any other applet. The jar file has to be placed in a shared location on your web server so the web browsers can load the jar when a chart applet is used in a web page. See the examples for how to place the chart applets in web pages.

  3. How do I install Odesys Charts SE?

    Odesys Charts 2.0 SE contains the charts20se.jar file that contains classes and packages needed to generate chart images. It will most likely be used by either Servlet or JSP. The jar file has to be in the classpath when the particular Servlet or JSP is executed. All used packages should be imported by the Servlet/JSP. See the server-side examples for more details. The easiest way to run the Odesys Charts 2.0.1 SE examples locally with Tomcat 3.X is to add the following context definition to the server.xml file. It assumes that Odesys Charts 2.0.1 SE files are placed in the c:/charts20se directory. If you choose to use another directory you have to modify the docBase attribute to point to the correct location.

    <Context path="/charts20se" 
             docBase="c:/charts20se/webapp" 
             crossContext="true"
             debug="0" 
             reloadable="true" 
             trusted="false"> 
    </Context>
        

More About Odesys Charts

  1. "Series and Categories" in Odesys BarChart. What are they?

    The data for the bar chart is organized in data series and data categories. All bars that belong to the same data series usually have the same color, which is the one set for the series. The label of the data series shows up in the legend. Every category has one bar from each data series. Only one label is shown for every category on the categories axis. You can still set a label for each individual bar and it will show up at the top of that bar. You can specify a color for each bar that will override the color of the data series that it belongs to. You can use setBarGap() and setCategoryGap() to specify how close the bars are to each other and how close the categories are to each other. BarChartView.setMode() determines whether to draw a stacked or a regular bar chart. Please look at the BarChartView in the API documentation for other properties of the Bar chart. It is usually easier to create the categories first and then to create and initialize the data series. Click here for an example


Examples

  1. How do I draw a Bar chart in a Frame and run it as a stand-alone application?

    import java.awt.*;
    import java.util.*;
    import com.odesys.chart.*;
    import com.odesys.chart.barchart.*;

    /**
    * Bar Chart Component in a Frame example.
    */
    public class BarChartExample extends Frame
    {
    public BarChartExample()
    {
      super("Bar Chart Example");
      resize(400, 300);
      setResizable(false);
    }

    /**
      * Closes the Frame on Event.WINDOW_DESTROY
      */
    public boolean handleEvent(Event e)
    {
      if(e.id == Event.WINDOW_DESTROY)
       System.exit(1);
      return super.handleEvent(e);
    }

    public static void main(String[] args)
    {
      // Create a Bar Chart
      BarChart chart = new BarChart();
      DefaultBarChartModel model = (DefaultBarChartModel)chart.getModel();
      setModelData(model);

      // Create a Frame and place the Bar Chart in it
      Frame frame = new BarChartExample();
      frame.setLayout(new BorderLayout());
      frame.add("Center", chart);
      frame.setFont(new Font("Helvetica", Font.PLAIN, 8));
      frame.show();
    }

    /**
      * Sets the bar data in the DefaultBarChartModel passed as parameter
      */
    public static void setModelData(DefaultBarChartModel model)
    {
      // Create the categories
      Series category = model.addCategory();
      category.setLabel("Sun");
      category = model.addCategory();
      category.setLabel("Mon");
      category = model.addCategory();
      category.setLabel("Tue");
      category = model.addCategory();
      category.setLabel("Wed");
      category = model.addCategory();
      category.setLabel("Thu");
      category = model.addCategory();
      category.setLabel("Fri");
      category = model.addCategory();
      category.setLabel("Sat");

      // Create a data series
      Series series = model.addSeries();
      series.setLabel("Series 1");
      Enumeration e = series.elements();

      // Set the Bar data for each category in the data series
      BarData barData = (BarData)e.nextElement();
      barData.setValue(3.2f);
      barData.setLabel("3.2");

      barData = (BarData)e.nextElement();
      barData.setValue(8.1f);
      barData.setLabel("8.1");

      barData = (BarData)e.nextElement();
      barData.setValue(12.5f);
      barData.setLabel("12.5");

      barData = (BarData)e.nextElement();
      barData.setValue(22.0f);
      barData.setLabel("22.0");

      barData = (BarData)e.nextElement();
      barData.setValue(33.0f);
      barData.setLabel("33.0");

      barData = (BarData)e.nextElement();
      barData.setValue(26.8f);
      barData.setLabel("26.8");

      barData = (BarData)e.nextElement();
      barData.setValue(31.0f);
      barData.setLabel("31.0");
    }
    }
  2. How can I modify the Y-Axis so that the values which appear there do not show any decimal precision?

    Here is the code for a JSP that generates LineChart jpeg:

    <%@ page import = "
    java.io.*,
    java.awt.*,
    com.odesys.chart.*,
    com.odesys.chart.image.*,
    com.odesys.chart.linechart.*"
    contentType="image/jpeg"%><%
    // Create and initialize a LineChartImage instance
    LineChartImage chart = new LineChartImage();
    chart.setSize(400, 300);
    chart.setBackground(Color.white);
    chart.setFont(new Font("Helvetica", Font.ITALIC, 12));
    chart.setLegendVisible(true);
    chart.setQuality(0.9f);
    chart.setDrawVertLines(true);
    chart.getAxisX().setName("x");
    chart.getAxisY().setName("y");
    // Set the data into the model
    DefaultLineChartModel model = (DefaultLineChartModel)chart.getModel();
    model.setUpdateLocked(true);
    PointData data;
    DefaultLine line = (DefaultLine)model.addSeries();
    line.setStyle(Line.NONE);
    line.setLabel("Series Name");
    for(float x = 0.0f; x <= 10.0f; x += 0.5f)
    {
     data = (PointData)line.addElement();
     data.setX(x);
     data.setY(x*x);
    }
    // Unlock the update to allow the chart to recalculate its internal state
    // to make sure the axis marks have correct values.
    model.setUpdateLocked(false);
    // Get the Axis object that represents the Y-axis
    Axis axisY = chart.getAxisY();
    // Make sure the axis marks are not recalculated automatically anymore
    axisY.setMarksAuto(false);
    // Create a new array of AxisMark objects with the same values as the current one, 
    // but with labels that are formated according to your preferences.
    AxisMark[] oldMarks = axisY.getMarks();
    AxisMark[] newMarks = new AxisMark[oldMarks.length];
    for(int i = 0; i < oldMarks.length; i++)
    {
     int value = (int)oldMarks[i].getValue(); // use an integer to avoid the decimal precision.
     newMarks[i] = new AxisMark(oldMarks[i].getValue(), String.valueOf(value));
    }
    // Set the new marks to the Y-axis
    axisY.setMarks(newMarks);
    // Write the image into a byte array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    chart.write(baos);
    // Write the image back to the client
    response.setContentLength(baos.size());
    OutputStream os = response.getOutputStream();
    baos.writeTo(os);
    %>
  3. How can I display a line graph that has a line that goes only partway across the axis?

    By default the axes adjust automatically to the range of the data that is shown. There is a way to explicitly specify the range of the axes of the LineChart though.

    // Create and initialize a LineChartImage instance
    LineChartImage chart = new LineChartImage();
    chart.getAxisX().setMax(10.0f);
    // ... the rest of the initialization ...

    Even if the line goes only from 0 to 3 the axis will still go to 10. The min value of the axis will still be calculated automatically unles it is set explicitly.

  4. Is it possible to display a Y axis label rotated (so that the text is sideways, going up and down the Y axis)?

    Unfortunately, labels cannot be rotated. The reason is that it would have been difficult to rotate the text under JDK 1.0, which we wanted to comply with in order to support all browsers on the market.

Copyright © 2001 Odesys, LLC. All rights reserved.