JChart Sample

This sample is located in \Samples\ActiveX\JChart.

Important   To use this sample, it is recommended that you have Microsoft® Visual Basic® version 5.0 or higher installed.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This sample JavaBean displays a customizable chart. You can edit the chart in Microsoft® Visual Basic® by selecting the chart type (bar chart, column chart, line graph, pie chart), specifying the various titles that display in the chart, and entering the data rows and columns. This JavaBean has its own customizer that is not currently supported by Visual Basic.

You must have Visual Basic and Microsoft® Internet Explorer 4.0 or later installed to use this sample.

Using the Sample

To use the sample

To view the chart, click the Start button below the applet window.

To edit the JavaBean in Visual Basic

  1. Register the bean by running Register.bat in the \Samples\ActiveX\JChart directory.

  2. Start Visual Basic.

  3. Place the JChart component in a form.

  4. Edit the chart as desired. For example:
    1. Set the rowCount and columnCount to some positive number.

    2. Set both the row and the column to 1, and then enter something in the data field.

    3. Add data to other rows and columns and observe the bar charts that appear.

    4. Set the chart type to 3 to display a pie chart.

Key Project Files

JChart.java

This file creates the JChart class and implements the Serializable interface. The code defines methods (writeObject and readObject) for custom serialization of JChart so that it can be written to and read from the hard disk. The code also provides methods to set and get the properties of the chart (such as the chart type, chart size, colors, fonts, and so on) and to draw the chart based on those property values.

JChartBeanInfo.java

This file specifies an icon for the JavaBean and creates the BeanDescriptor object that specifies the customizer for the JavaBean.

JChartCustomizer.java

This file defines the customizer for the JChart class; the code creates a tab viewer with panels for the titles and format customizers, creates the titles and format customizers, and registers listeners for changes to the JavaBean.

JChartFormatCustomizer.java

This file defines editors for changing the format of the chart.

JChartTitlesCustomizer.java

This file defines editors for changing the titles displayed in the chart.

Technologies Demonstrated

ActiveX/Beans

© 1999 Microsoft Corporation. All rights reserved. Terms of use.