10.6. API Only Features

While EspressChart API can reproduce all the functionality of Chart Designer, the API also has additional functionalities. These additional features will be described below. Please note that some of the features are for stand-alone charts only.

[Note]Note

Note that in the snippets of code provided, chart is an object of type QbChart.

10.6.1. Visual

The features, shown below, deal with the presentation of the chart and its components. Each feature below changes the chart, in some manner, visually. These changes are also carried forth when exported to a static image.

10.6.1.1. Canvas/Plot

The following features describe the various visual changes that can be made to the chart plot and/or canvas using the API. Note that the features below deal with general changes to the chart plot and/or canvas. Any component specific change is described in its own section.

10.6.1.1.1. Customizable Message for No-Data-In-Plot

EspressChart allows the message, which gets displayed when there is no data or not enough data to be plotted, to be changed. This can be done by getting a handle to the INoDataToPlotMessage and specifying the new message.

INoDataToPlotMessage noData = chart.gethNoDataToPlotMessage();
noData.setMessage("Not enough data to plot chart");

Please refer to the online API documentation for more information (quadbase.util.INoDataToPlotMessage).

10.6.1.1.2. Set Chart to Fit Canvas

EspressChart allows charts to be resized and fit into the canvas correctly, taking into account all the text and labels associated with the chart. To correctly fit a chart onto its canvas, use the method setFitOnCanvas(boolean b) in the ICanvas interface.

ICanvas canvas = chart.gethCanvas();
canvas.setFitOnCanvas(true);

Please refer to the online API documentation for more information (quadbase.util.ICanvas).

10.6.1.1.3. Set Chart Invisible

A chart can be made invisible so that only the plot data in table form is shown. This is accomplished by getting a handle to the ICanvas interface and using the setChartVisible method.

ICanvas canvas = chart.gethCanvas();
canvas.setChartVisible(false);

Please refer to the online API documentation for more information (quadbase.util.ICanvas).

10.6.1.1.4. Applying Different Graphics Rendering

EspressChart allows you to apply different rendering techniques (such as anti-aliasing) to the chart. This allows you to draw the chart to your specifications.

To utilize this feature in the API, call the setRenderingHint method in QbChart and pass in the hint key and hint value parameters.

chart.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);

You can also specify the horizontal text to be anti-aliased only.

chart.forceApplyAntiAliasToHorizontalText(true);

Please refer to the online API documentation for more information (quadbase.ChartAPI.QbChart).

This functionality is only available for stand-alone charts.

10.6.1.1.5. Chart Plot Position

EspressChart allows the chart position to be placed down to -0.5 (x and y position relative to the canvas). This allows the chart to be placed right along the edge of the canvas.

To utilize this feature using the API, get a handle to IPlot and use the setPosition method.

IPlot chartPlot = chart.gethChartPlot();
chartPlot.setPosition(new Position(-0.5, -0.5));

Please refer to the online API documentation for more information (quadbase.util.IPlot).

10.6.1.1.6. Drawing Multiple Charts in same Plot

EspressChart allows multiple charts to be overlapped and shown one above the other (using the primary chart's axes). The canvas of the primary chart is used and therefore 2D charts cannot be added to 3D charts and vice versa. All charts overlapped onto the primary chart will have any text and canvas information removed. Please note that since resulting chart will use the primary chart's category and scale, add on charts must also use the similar categories and scales to be displayed correctly. For Scatter and Surface charts, both x and y axis scales should be taken into consideration.

To utilize this feature using the API, you would use the setAddOnChart method in QbChart.

The following code, which can be run as an applet or application, shows how to overlap 3 charts in one plot:

// Open the template
QbChart primaryChart = new QbChart(parent, // container 
		"AddOnChart1.cht"); // template

// Open other two templates
QbChart chart2 = new QbChart(parent, "AddOnChart2.cht");
QbChart chart3 = new QbChart(parent, "AddOnChart3.cht");

primaryChart.setAddOnChart(new QbChart[] { chart2, chart3 });

Full Source Code

Exported Results

Please refer to the online API documentation for more information (quadbase.ChartAPI.QbChart).

10.6.1.2. Hint Box

The following features describe the various visual changes that can be made to the chart hint box using the API. These include modifying the content as well as look of the hint box.

10.6.1.2.1. Modify Hint Box

EspressChart allows the Hint Box to be modified, i.e., you can dictate what the Hint Box says when it is viewed. This is done by creating a class that implements IHintBoxInfo and assigning that class using the method setHintBoxInfo in IHint.

The following code, which can be run as an applet or application, shows how to modify the hint box info:

// Open the template
QbChart chart = new QbChart(parent, // container 
		"ModifyHintBox.cht"); // template

IHintBoxInfo hintBoxInfo = new Hint();
chart.gethDataPoints().gethHint().setHintBoxInfo(hintBoxInfo);

...

class Hint implements IHintBoxInfo {

      public Vector getHint(PickData pickData) {
            Vector vec = new Vector();

            if (pickData.series != null)
                  vec.addElement("(" + pickData.seriesName+ ") " + pickData.s_series);

            if (pickData.category != null)
                  vec.addElement("(" + pickData.categoryName + ") " + pickData.s_category);

            if (pickData.s_value != null)
                  vec.addElement("(" + pickData.valueName + ") " + pickData.s_value + (pickData.value > 7 ? ":Good" : ":Restock"));

            return vec;

      }

}

Full Source Code

Exported Results

Please refer to the online API documentation for more information (quadbase.util.IHintBoxInfo).

This functionality is only available for stand-alone charts.

10.6.1.2.2. Data and Hyperlink Hint Box Offset

EspressChart allows an offset to be set for the Data and the HyperLink hint box so that it doesn't overlap the chart or any other component in the chart.

To utilize this feature in the API, get a handle to IHint (from either the chart object or the IHyperLinkSet object) and then use the setOffset method.

IHint dataHints = chart.gethDataPoints().gethHint();
dataHints.setoffset(new Dimension (30, 20));

Please refer to the online API documentation for more information (quadbase.util.IHint).

10.6.1.2.3. Hint Box Border Color

EspressChart allows the color of the Hint box border to be set using the API. This can be done by getting a handle to IHint and using the setBorderColor method.

IHint chartHintBox = chart.gethHint();
chartHintBox.setBorderColor(Color.red);

Please refer to the online API documentation for more information (quadbase.util.IHint).

10.6.1.2.4. Customize Image Map Hint Box

EspressChart allows the customization of the hint box text when exporting the chart to a map file. When the map file is included in a DHTML/HTML file, the customized hint box is visible when the mouse is moved over the data points of the chart. You can create a customized image map hint box by creating a class that implements ICustomizedImageDataMapHintBox and assign that class to the setImageMapDataHintBoxHandle method in QbChart.

The following code, which can be run as an applet or application, shows how to customize the image map hint box:

// Open the template
QbChart chart = new QbChart(parent, // container 
		"CustomizeImageMapHintBox.cht"); // template

chart.setImageMapDataHintBoxHandle(new customizeImageMap());

try {
	// Export chart to image and map file
	chart.export(QbChart.PNG, "CustomizeImageMapHintBox", "CustomizeImageMapHintBox", 0, 0,
			true);
} catch (Exception ex)
{
	ex.printStackTrace();
}

...

class customizeImageMap implements ICustomizeImageMapDataHintBox {

      public String customizeHintBox(String str) {
            return str.substring(6, 11) + " " + str.substring(str.length()-3);

      }

}

Full Source Code

Exported Map

Exported Image

Please refer to the online API documentation for more information (quadbase.util.ICustomizeImageMapDataHintBox).

10.6.1.3. Legend/Annotation

The following features describe the various visual changes that can be made to the chart legend and/or any annotation using the API. These include modifying the content as well as look of the chart legend/annotations.

10.6.1.3.1. Annotation with Symbol

EspressChart allows symbols to be included with an Annotation thus allowing symbols and strings to be placed in the chart. One of the applications of this feature is to create your own legend in place of the default legend created by EspressChart.

A new constructor has been created for IAnnotation, which can be used for adding symbols and text.

The following code, which can be run as an applet or application, shows how to combine symbols with an Annotation:

// Open the template
QbChart chart = new QbChart(parent, // container 
		"AnnotationWithSymbol.cht"); // template

// Create custom legend
IAnnotationSet set = chart.gethAnnotations();
String[] text = { "New Legend", "Hello World", "ABC", "I got It" };
int[] shape = { QbChart.PLUS, QbChart.NOSYMBOL, QbChart.SQUARE, QbChart.DASH };
Color[] color = { Color.red, Color.black, Color.blue, Color.white };
IAnnotation anno = set.newAnnotation(text, shape, color);
Point_2D newPosition = new Point_2D(.65f, .7f);
anno.setRelativePosition(newPosition);
set.addAnnotation(anno);

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.IAnnotationSet and quadbase.util.IAnnotation).

10.6.1.3.2. Set Reference Position of Legend and Annotation Text

EspressChart allows the reference positions of legend and any annotation texts to be set at either the upper left corner or default position (lower left corner). To change the reference position to the upper left position, you would use the setReferenceAtTop method in ICanvas.

ICanvas canvas = chart.gethCanvas();
canvas.setReferenceAtTop(true);

Please refer to the online API documentation for more information (quadbase.util.ICanvas).

10.6.1.4. Misc.

The following features describe the various visual changes that can be made to the different components of the chart. These include modifying the content as well as look of the chart and its elements.

10.6.1.4.1. Ticker Label Replacement

EspressChart allows ticker labels to be replaced by user-defined strings. This enables the users to put in their own ticker values.

To replace ticker labels, use the method setTickerLabels in IAxis.

IAxis hXAxis=chart.gethXAxis();
hXAxis.setTickerLabels(new String[] {new String("a"), new String("b"), new String("c")});

Please refer to the online API documentation for more information (quadbase.util.IAxis).

10.6.1.4.2. Customizable Data Top Label

EspressChart allows data top labels for both primary and secondary charts to be customized. You can do this by creating a class that implements IDataLabelInfo and passing that class using the setDataLabelInfo method in IDataPointSet.

The following code, which can be run as an applet or application, shows how to combine symbols with an Annotation:

// Open the template
QbChart chart = new QbChart(parent, // container 
		"CustomizeDataTopLabel.cht"); // template

chart.gethDataPoints().setDataLabelInfo(new customizeDataTopLabel());

...

class customizeDataTopLabel implements IDataLabelInfo {

	static final long serialVersionUID = 1;

	public String getDataLabel(PickData pickData, String originalDataLabel) {
		return (pickData.toString());
	}
}

Full Source Code

Exported Image

Note that any customization to the data top labels will not be evident unless they are visible.

Please refer to the online API documentation for more information (quadbase.util.IDataLabelInfo).

10.6.1.4.3. Show Axis as Date/Time/Timestamp

EspressChart allows the value axis to be shown in units of time/date (instead of numeric units) for any chart, which has a value axis. Note that the data for the value axis must still be numeric.

To utilize this feature using the API, get a handle to IAxis and use the setDisplayLabelAsDate method.

IAxis chartYAxis = chart.gethXAxis();
chartXAxis.setDisplayLabelAsDate(true);

Please refer to the online API documentation for more information (quadbase.util.IAxis).

10.6.1.4.4. Selective String Rendering

Strings, which are drawn horizontally or vertically, look better when not anti-aliased. However, strings at other angles look better when anti-aliased. EspressChart allows certain text to be anti-aliased and other strings (0 and 90 degree angles) to be drawn without anti-aliasing.

To utilize this feature using the API, get a handle to IDataPointSet and use the setDisableJava2DForStraightText method.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setDisableJava2DForStraightText(true);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.1.4.5. Drawing Data Points above Horizonval/Vertical/Trend Lines

EspressChart allows the data points to be drawn on top of any horizontal/vertical/trend lines i.e., it appears like the data points are resting on top of the line instead of being overshadowed by the line.

To utilize this feature using the API, get a handle to ILinePropertySet and use the method setDataDrawnOnTop.

ILinePropertySet lineProperties = chart.gethLineProperties();
lineProperties.setDataDrawnOnTop(true);

Please refer to the online API documentation for more information (quadbase.util.ILinePropertySet).

10.6.2. Data

The features, shown below, deal with the data in the chart and its components. Each feature below changes data shown (typically the presentation of the data shown) or obtains the data in the chart. These changes are also carried forth when exported to a static image.

10.6.2.1. Getting the Coordinates

EspressChart allows you to get the information of a datapoint based on a specified pixel position. This returns the category, value, series and sumby (if they are there) of the data point at the specified pixel location and otherwise returns null.

To get pickData, use the method getPickData(width, height) in IHint.

IDataPointSet dataPoints=chart.gethDataPoints();
IHint hint=dataPoints.gethHint();
PickData pickdata=hint.getPickData(200, 300)        // pixel at width=200 and height=300

Please refer to the online API documentation for more information (quadbase.util.IHint).

10.6.2.2. Set Data Limit at Axis Scale

When a manual axis is applied, EspressChart gives you the option to truncate data points that are beyond the maximum value on the axis. You can set the data limit by using the method setLimitAtAxisScale in IDataPointSet.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setLimitAtAxisScale(true);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.2.3. Set Null Data as Zero

EspressChart can now represent any null data as zero data (i.e., datapoints with an associated 0 value). To accomplish this, use the setNullDataAsZero method in IDataPointSet.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setNullDataAsZero(true);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.2.4. Additional Trend Line Options

EspressChart allows you to get the minimum, the maximum, the probability as well as the inverse normal in addition to the mean value for the normal curve trend line as well as draw standard deviation trend lines, by calling ITrendLine and using the appropriate method.

To utilize this feature in the API, you need to call ITrendLine and use the appropriate methods.

[Note]Note

You can only draw standard deviation trend lines for a normal curve if the chart is a histogram chart with setLinearScale and setRounded true.

The following code, which can be run as an applet or application, shows how to get information from a normal curve trendline in the chart:

ITrendLine normalCurve = (ITrendLine)chart.gethDataLines().elements().nextElement();
System.out.println("Mean = " + normalCurve.getMean());
System.out.println("St. Dev = " + normalCurve.getStandardDev());
System.out.println("Min = " + normalCurve.getMin());
System.out.println("Max = " + normalCurve.getMax());
System.out.println("Dev of 1.0, Prob = " + normalCurve.getProbability(1.0));
System.out.println("Back Calculated Dev = " + normalCurve.getInverseNorm(normalCurve.getProbability(1.0)));

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.ITrendLine).

10.6.3. Chart Specific

The features, shown below, deal with the specific chart types. Each feature below shows additional functionality available to the chart, depending on the chart type. These changes are also carried forth when exported to a static image.

10.6.3.1. Column/Bar Charts

The following features describe the various changes that can be made to column/bar charts using the API. These include modifying the content as well as look of the chart.

10.6.3.1.1. Color Separator

EspressChart allows different colors to be shown for the columns based on defined category values. To use color separator, use the method setColorSeparators in IDataPointSet.

The following code, which can be run as an application or applet, shows how to set up the color separator:

IDataPointSet hDataPoints=chart.gethDataPoints();
hDataPoints.setColorSeparators(new Color[]{Color.green, Color.red, Color.blue},
                               new Integer[]{new Integer((int)Math.rint(9)), new Integer((int)Math.rint(14))},
                               QbChart.ASCENDING);

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.1.2. Disabling Shadow

EspressChart allows the shadow that appears for the columns/bars to be rendered visible or invisible. You can use this feature by getting a handle to IDataPointSet and use the setShowShadowOnPoint method.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setShowShadowOnPoint(false);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.2. Pie Charts

The following features describe the various changes that can be made to pie charts using the API. These include modifying the content as well as look of the chart.

10.6.3.2.1. Drawing Pie Slices Clockwise/Counter Clockwise

EspressChart now allows the slices in a pie chart to be drawn in clockwise as well as counter clockwise order. To set the clockwise/counter clockwise option, use the reverseOrder method in IDataPointSet.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.reverseOrder(QbChart.CATEGORY);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.2.2. Pie Border for 0% and 100% Slices

EspressChart offers the option of removing the pie border for slices that are 0% or 100% of the whole pie. You can do this by getting a handle to IPiePropertySet and use the setRadialBorderDrawnForZero method.

IPiePropertySet pieProperties = chart.gethPieProperties();
pieProperties.setRadialBorderForZero(true);

Please refer to the online API documentation for more information (quadbase.util.IPiePropertySet).

10.6.3.2.3. Customize Separator between Category and Percent Value Strings in Pie Legend

EspressChart allows user-defined separators to be placed between the Category and Percent Value Strings in the legends for Pie Charts. This can be done by getting a handle to IPiePropertySet and use the setSepSymbol method.

IPiePropertySet pieProperties = chart.gethPieProperties();
pieProperties.setSepSymbol(",");

Please refer to the online API documentation for more information (quadbase.util.IPiePropertySet).

10.6.3.2.4. Pie Border Color Customizable

EspressChart allows the user to specify the color for the pie border. This is accomplished by using the setBorderColor method in IPiePropertySet.

IPiePropertySet pieProperties = chart.gethPieProperties();
pieProperties.setBorderColor(Color.red);

Please refer to the online API documentation for more information (quadbase.util.IPiePropertySet).

10.6.3.3. Line Charts

The following features describe the various changes that can be made to line charts using the API. These include modifying the content as well as look of the chart.

10.6.3.3.1. Line Area

EspressChart allows you to create line areas between a horizontal line and the data line to denote the change. For example, you could have a horizontal line at 25 and a data line. All areas enclosed by the data line and horizontal line and above the horizontal line can be one color and all areas enclosed by the horizontal line and data line and below the horizontal line can be another color. Please note that this feature is only available for 2D Line charts with no series. Also note that you need to set the color above and below the horizontal line in order to use this feature.

To use this feature in the API, you must get a handle to ILinePropertySet and use the setAreaVisible and setAreaColors methods.

The following code, which can be run as an applet or application, shows how to use line area:

ILinePropertySet lineProperties = chart.gethLineProperties();
lineProperties.setAreaVisible(true);
lineProperties.setAreaColors(Color.green, Color.yellow);

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.ILinePropertySet).

10.6.3.4. Scatter Charts

The following features describe the various changes that can be made to scatter charts using the API. These include modifying the content as well as look of the chart.

10.6.3.4.1. Show Series in Top Label

EspressChart allows series to be shown in the top labels for scatter charts. This can be done by using the method showSeriesInTopLabel in IDataPointSet.

IDataPointSet dataPoints=chart.gethDataPoints();
dataPoints.showSeriesInTopLabel(true);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.4.2. Drawing Order

EspressChart allows the connecting lines for a Scatter chart to be drawn in the order of the data set. For example, if the data contains the following points (0, 2), (3, 4), (1, 2), (2, 5), the default presentation for the connecting lines would generate a line from (0, 2) to (1, 2) to (2, 5) and finally (3, 4). However, you can generate the connecting lines in the order of the data.

To utilize this feature using the API, get a handle to IDataPointSet and use the setConnectLinesInOriginalOrder method.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setConnectLinesInOriginalOrder(true);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.4.3. Scatter Chart Cube Width

EspressChart allows the cube width of 3D Scatter charts to be changed to any size. To modify the cube width, first get a handle to IDataPointSet and use the setScatterCubeWidth method.

IDataPointSet dataPoints = chart.gethDataPoints();
dataPoints.setScatterCubeWidth(15);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.5. Overlay Charts

The following features describe the various changes that can be made to overlay charts using the API. These include modifying the content as well as look of the chart.

10.6.3.5.1. Multiple Axes Titles

EspressChart allows the setting of a different title for each axis in an overlay chart. This can be done by getting a handle to each individual axis and using the gethTitle().setValue method. You get the handle to the individual axis by specifying the layer.

IAxis axis0 = chart.gethYAxis();
axis0.gethTitle().setValue("XYZ");

IAxis axis1 = chart.gethAxis(1); // Get axis of Layer 1
axis1.gethTitle().setValue("ABC");

IAxis axis2 = chart.gethAxis(2); // Get axis of Layer 2
axis2.gethTitle().setValue("DEF");

Please note that before you set the titles, you need to draw the chart in the background.

Please refer to the online API documentation for more information (quadbase.util.IAxis).

10.6.3.6. Dial Charts

The following features describe the various changes that can be made to dial charts using the API. These include modifying the content as well as look of the chart.

10.6.3.6.1. Control Area Scale Labels

EspressChart allows the starting and ending scale of a control area to be shown as labels. This can be done by obtaining a handle to a control area and use the setShowLabel method.

ControlRange cr1 = chart.gethControlRanges().elementAt(0);
cr1.setShowLabel(true);

Please refer to the online API documentation for more information (quadbase.util.ControlRange).

10.6.3.7. HLCO Charts

The following features describe the various changes that can be made to HLCO charts using the API. These include modifying the content as well as look of the chart.

10.6.3.7.1. Changing Candle Stick Color

EspressChart allows you to change the candlestick color for HLCO charts using the API only. To do so, you will need to get a handle to IDataPointSet and use setCandleStickColors method.

IDataPointSet dataPoints = chart.gethDataPoints();
// Up color is green, Down color is red
dataPoints.setCandleStickColors(Color.green, Color.red);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.7.2. Changing Candle Stick Wicker Width

EspressChart allows you to change the candlestick wicker width (the upper and lower extensions of candlesticks) for HLCO charts using the API only. To do so, you will need to get a handle to IDataPointSet and use the method setCandleStickWidth. The number passed is the ratio of the candle wicker width to the candle width.

IDataPointSet dataPoints = chart.gethDataPoints();
// Set width to 0.5
dataPoints.setCandleStickWidth((float)0.5);

Please refer to the online API documentation for more information (quadbase.util.IDataPointSet).

10.6.3.8. Surface Charts

The following features describe the various changes that can be made to surface charts using the API. These include modifying the content as well as look of the chart.

10.6.3.8.1. Heat Map

EspressChart allows users to draw a surface chart like a contour map. Basically, the surface chart can be drawn in sections, with different colors according to the threshold values specified.

The following code, which can be run as an applet or application, shows how to create a surface chart with a heat map:

double [] heatMapValues = {3, 6};
Color [] heatMapColors = { Color.green, Color.yellow, Color.red};
ColorSpectrum heatMapColorSpectrum = new ColorSpectrum(heatMapColors, heatMapValues);
I3DPropertySet set = chart.geth3DProperties();
set.setColorSpectrum(heatMapColorSpectrum);

The code above creates a 3D surface chart with 3 color sections, green, yellow and red. The threshold values determining the colors are 3 and 6.

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.ColorSpectrum and quadbase.util.I3DPropertySet).

10.6.4. Performance

The features, shown below, deal with improving the performance of the chart generation and export. Each feature below shows additional functionality available to the chart, to decrease memory resources and time needed to generate the chart.

10.6.4.1. BufferedImage or Frame

EspressChart allows the choice of using either java.awt.image.BufferedImage or java.awt.Frame during export to improve performance. By default, EspressChart uses java.awt.Frame to create the chart object. Using java.awt.Frame gives better performance as the number of data points increases while using java.awt.image.BufferedImage yields better performance on larger chart dimensions. This is done by using the setBufferedImageUsed method in QbChart.

chart.setBufferedImageUsed(true);

Please refer to the online API documentation for more information (quadbase.ChartAPI.QbChart).

This functionality is only available for stand-alone charts.

10.6.4.2. Chart Generation Order

EspressChart allows you to choose the order in which the chart is generated and even add elements in the generation of the chart using the API only. For example, you can now draw a background, and then a circle and have the chart generated in the center of the circle to create a chart. You can do this by creating a class that implements the IChartGraphics interface and then assigning the class to the setChartGraphics method in QbChart. In essence, the IChartGraphics interface allows you to add or modify any graphics information before or after drawing the chart.

The following code, which can be run as an applet or application, shows how to generate charts and graphics in a specific order:

// Open the template
QbChart chart = new QbChart(parent, // container 
		"ChartGeneration.cht"); // template

chart.setChartGraphics(new chartGenerationGraphics());

...

class chartGenerationGraphics implements IChartGraphics {

	static final long serialVersionUID = 1;

	public void initializeGraphics(Graphics g, int w, int h) {
		g.setColor(Color.red);
		g.fillOval(50, 50, 400, 400);
	}

	public void finalizeGraphics(Graphics g, int w, int h) {
		g.setColor(Color.white);
		g.fillOval(125, 225, 50, 50);
		g.setColor(Color.orange);
		g.drawString("HELLO WORLD", 150, 250);
	}
}

Full Source Code

Exported Image

Please refer to the online API documentation for more information (quadbase.util.IChartGraphics).

This functionality is only available for stand-alone charts.

10.6.5. Viewer

The features, shown below, deal with the Viewer when viewing the chart in either a java application or java applet. Each feature below shows additional functionality available to Chart Viewer.

10.6.5.1. Call Back Mechanism

EspressChart has a call back mechanism for higher levels to handle the event. When a data object in the chart is selected by the viewer, an action event is generated. The event argument contains an instance of PickData, which provides information of the series, category, value, etc of the data point selected.

The following code, which can be run as an applet or application, shows how to capture an event:

static TextField textField;

// Open the template
QbChart chart = new QbChart(parent, // container 
		"CallBack.cht"); // template

chart.addActionListener(new callBackActionListener());

...

class callBackActionListener implements ActionListener {

      public void actionPerformed(ActionEvent e) {
            Object arg = ((QbChart) e.getSource()).getArgument();

            String click;

            switch (e.getModifiers()) {

            case QbChart.LEFT_SINGLECLICK:
                  click = "Left single click";
                  break;

            case QbChart.LEFT_DOUBLECLICK:
                  click = "Left double click";
                  break;

            case QbChart.RIGHT_SINGLECLICK:
                  click = "Right single click";
                  break;

            case QbChart.RIGHT_DOUBLECLICK:
                  click = "Right double click";
                  break;

            default: // shall not happen
                  click = "Error !";

            }

            if (arg instanceof PickData)
                  textField.setText(((PickData) arg).toString() + " " + click);

            else
                  textField.setText((String) arg + " " + click);

      }

}

Full Source Code

Exported Image

This functionality is only available for stand-alone charts.

10.6.5.2. Disable/Enable Tool Tips Text

EspressChart allows the tool tips text for the navigation panel to be enabled and disabled. This can be done by using the method setToolTipEnabled in I3DControlPanel. Note that this option is for 3D charts only.

I3DControlPanel controlPanel = chart.geth3DControlPanel();
controlPanel.setToolTipEnabled(true);

Please refer to the online API documentation for more information (quadbase.util.I3DControlPanel).

10.6.5.3. Canvas Area

EspressChart allows the viewpanel containing the canvas to be selected so that more event properties (i.e., user defined event properties) can be added. You can do this by getting a handle to ICanvas and using the getCanvasArea() method to return the component.

ICanvas chartCanvas = chart.gethCanvas();
Component chartCanvasComponent = chartCanvas.getCanvasArea();

Please refer to the online API documentation for more information (quadbase.util.ICanvas).