Simple Overlay Chart


Applet code: <applet code=com.objectplanet.chart.ChartApplet archive=chart.jar width=450 height=300> <param name=chart value="bar"> <param name=sampleValues value="10,20,30,40,50"> <param name=rangeStep value=20> <param name=barWidth value="0.6"> <param name=sampleColors value="#B9E4F1"> <param name=background value=white> <param name=overlay0 value="bar"> <param name=overlay0_sampleValues value="28,46,34,45,37"> <param name=overlay0_sampleColors value="#FFDCC4"> <param name=overlay0_barWidth value="0.3"> <param name=overlay1 value="line"> <param name=overlay1_sampleValues value="6,8,14,25,17"> <param name=overlay1_sampleColors value="#B5B5EB"> <param name=overlay1_stackedOn value="true"> </applet>
Servlet code: <img src="http://localhost:8080/servlet/com.objectplanet.chart.ChartServlet? chart=bar& width=450& height=300& sampleValues=10,20,30,40,50& rangeStep=20& barWidth=0.6& sampleColors=%23B9E4F1& background=white& overlay0=bar& overlay0_sampleValues=28,46,34,45,37& overlay0_sampleColors=%23FFDCC4& overlay0_barWidth=0.3& overlay1=line& overlay1_sampleValues=6,8,14,25,17& overlay1_sampleColors=%23B5B5EB& overlay1_stackedOn=true">
Application code: package com.objectplanet.chart.testing; import com.objectplanet.chart.*; import java.awt.*; public class Overlay { public static void main(String[] argv) { double[] sampleValues = new double[] {10,20,30,40,50}; double[] overlayValues_0 = new double[] {28,46,34,45,37}; double[] overlayValues_1 = new double[] {6,8,14,25,17}; BarChart chart = new BarChart(); chart.setSampleCount(sampleValues.length); chart.setSampleValues(0, sampleValues); chart.setRelativeRange(0, 1.0, 20); chart.setBarWidth(0.6); chart.setSampleColors(new Color[] {new Color(0xB9E4F1)}); chart.setBackground(Color.white); BarChart overlay0 = new BarChart(); overlay0.setSampleCount(overlayValues_0.length); overlay0.setSampleValues(0, overlayValues_0); overlay0.setSampleColors(new Color[] {new Color(0xFFDCC4)}); overlay0.setBarWidth(0.3); chart.setOverlayChart(0, overlay0); LineChart overlay1 = new LineChart(); overlay1.setSampleCount(overlayValues_1.length); overlay1.setSampleValues(0, overlayValues_1); overlay1.setSampleColors(new Color[] {new Color(0xB5B5EB)}); overlay1.setStackedOn(true); chart.setOverlayChart(1, overlay1); com.objectplanet.chart.NonFlickerPanel p = new com.objectplanet.chart.NonFlickerPanel(new BorderLayout()); p.add("Center", chart); Frame f = new Frame(); f.add("Center", p); f.setSize(450,320); f.show(); } }