Complex Overlay Chart


Applet code: <applet code=com.objectplanet.chart.ChartApplet archive=chart.jar width=750 height=350> <param name="chart" value="bar"> <param name="sampleValues_0" value="4, 2, 6, 12, 15, 14, 24, 32, 32, 44, 37, 64, 59, 47, 62, 73, 60, 44, 61, 75, 78"> <param name="seriesRange_0" value="2"> <param name="sampleLabels" value="jul\n1999,aug\n1999,sep\n1999,oct\n1999,nov\n1999,dec\n1999,jan\n2000,feb\n2000,mar\n2000,apr\n2000,may\n2000,jun\n2000,jul\n2000,aug\n2000,sep\n2000,oct\n2000,nov\n2000,dec\n2000,jan\n2001,feb\n2001,mar\n2001"> <param name="sampleColors" value="#639a9c, #ff9a00"> <param name="background" value="white"> <param name="chartBackground" value="#ffffe7"> <param name="valueLabelsOn" value="true"> <param name="valueLabelStyle" value="inside"> <param name="sampleLabelsOn" value="true"> <param name="sampleLabelStyle" value="below"> <param name="valueLinesOn" value="true"> <param name="chartTitle" value="Bike Sales"> <param name="legendOn" value="true"> <param name="legendPosition" value="top"> <param name="legendLabels" value="Count,Sales"> <param name="rangeOn_2" value="true"> <param name="rangeStep" value="1000"> <param name="rangeStep_2" value="100"> <param name="rangePosition" value="right"> <param name="rangeposition_2" value="left"> <param name="rangeAdjusterOn" value=true> <param name="rangeAdjusterOn_2" value=true> <param name="rangeAdjusterPosition_2" value=left> <param name="rangeAdjusted_1" value="both"> <param name="sampleScrollerOn" value="true"> <param name="sampleAxisLabel" value="Sales Period"> <param name="sampleAxisLabelFont" value="Verdana, bold, 14"> <param name="rangeAxisLabel" value="US Dollars"> <param name="rangeAxisLabelFont" value="verdana, bold, 16"> <param name="rangeAxisLabelAngle" value="90"> <param name="rangeAxisLabel_2" value="Number of Sales"> <param name="rangeAxisLabelAngle_2" value="270"> <param name="rangeLabelPrefix" value="$"> <param name="multiSeriesOn" value="true"> <param name="barWidth" value="0.6"> <param name="barOutlineOff" value="true"> <param name="overlay" value="line"> <param name="overlay_seriesCount" value="2"> <param name="overlay_sampleValues_1" value="1247, 648, 1794, 2238, 3185, 3997, 4176, 9247, 8465, 14982, 12263, 21847, 23515, 18344, 20765, 25047, 18616, 16327, 19746, 22547, 24074"> <param name="overlay_sampleColors" value="#ff9a00"> <param name="overlay_valueLabelsOn" value="true"> <param name="overlay_valueLabelPrefix" value="$"> <param name="overlay_sampleHighlightOn" value="true"> <param name="overlay_sampleHighlightStyle" value="circle_opaque"> <param name="overlay_sampleHighlightSize" value="8"> <param name="overlay_lineWidth" value="4"> </applet>
Servlet code: <img src="http://localhost:8080/servlet/com.objectplanet.chart.ChartServlet? chart=bar& width=750& height=350& sampleValues_0=4,2,6,12,15,14,24,32,32,44,37,64,59,47,62,73,60,44,61,75,78& seriesRange_0=2& sampleLabels=jul\n1999,aug\n1999,sep\n1999,oct\n1999,nov\n1999,dec\n1999,jan\n2000,feb\n2000,mar\n2000,apr\n2000,may\n2000,jun\n2000,jul\n2000,aug\n2000,sep\n2000,oct\n2000,nov\n2000,dec\n2000,jan\n2001,feb\n2001,mar\n2001& sampleColors=%23639a9c,%23ff9a00& background=white& chartBackground=%23ffffe7& valueLabelsOn=true& valueLabelStyle=inside& sampleLabelsOn=true& sampleLabelStyle=below& valueLinesOn=true& chartTitle=BikeSales& legendOn=true& legendPosition=top& legendLabels=Count,Sales& rangeOn_2=true& rangeStep=1000& rangeStep_2=100& rangePosition=right& rangeposition_2=left& rangeAdjusterPosition_2=left& rangeAdjusted_1=both& sampleAxisLabel=SalesPeriod& sampleAxisLabelFont=Verdana,bold,14& rangeAxisLabel=USDollars& rangeAxisLabelFont=verdana,bold,16& rangeAxisLabelAngle=90& rangeAxisLabel_2=NumberofSales& rangeAxisLabelAngle_2=270& rangeLabelPrefix=$& multiSeriesOn=true& barWidth=0.6& barOutlineOff=true& overlay=line& overlay_seriesCount=2& overlay_sampleValues_1=1247,648,1794,2238,3185,3997,4176,9247,8465,14982,12263,21847,23515,18344,20765,25047,18616,16327,19746,22547,24074& overlay_sampleColors=%23ff9a00& overlay_valueLabelsOn=true& overlay_valueLabelPrefix=$& overlay_sampleHighlightOn=true& overlay_sampleHighlightStyle=circle_opaque& overlay_sampleHighlightSize=8& overlay_lineWidth=4">
Application code: package com.objectplanet.chart.testing; import com.objectplanet.chart.*; import java.awt.*; public class Overlay { public static void main(String[] argv) { String[] sampleLabels= new String[] {"jul\n1999","aug\n1999","sep\n1999","oct\n1999","nov\n1999","dec\n1999","jan\n2000","feb\n2000","mar\n2000","apr\n2000","may\n2000","jun\n2000","jul\n2000","aug\n2000","sep\n2000","oct\n2000","nov\n2000","dec\n2000","jan\n2001","feb\n2001","mar\n2001"}; double [] sampleValues = new double[] {4,2,6,12,15,14,24,32,32,44,37,64,59,47,62,73,60,44,61,75,78}; BarChart chart = new BarChart(); chart.setTitleOn(true); chart.setTitle("Bike Sales"); chart.setSeriesCount(1); chart.setSampleCount(sampleValues.length); chart.setSampleValues(0, sampleValues); chart.setMultiSeriesOn(true); chart.setSampleLabels(sampleLabels); chart.setSampleLabelsOn(true); chart.setSampleLabelStyle(Chart.BELOW); chart.setRangeOn(1, true); chart.setSeriesRange(0, 2); chart.setRange(0, 26000); chart.setRangePosition(0,1); chart.setRangePosition(1,0); chart.setRangeAdjusted(0, -1); chart.setLabel("rangeLabelPrefix", "$"); chart.setLabel("sampleAxisLabel", "Sales Period"); chart.setFont("sampleAxisLabelFont", new Font("Verdana", Font.BOLD, 14)); chart.setLabel("rangeAxisLabel", "US Dollars"); chart.setFont("rangeAxisLabelFont", new Font("Verdana", Font.BOLD, 16)); chart.setLabelAngle("rangeAxisLabelAngle", 90); chart.setLabel("rangeAxisLabel_2", "Number of Sales"); chart.setFont("rangeAxisLabelFont_2", new Font("Verdana", Font.BOLD, 16)); chart.setLabelAngle("rangeAxisLabelAngle_2", 270); chart.setValueLabelsOn(true); chart.setValueLabelStyle(Chart.INSIDE); chart.setValueLinesOn(true); chart.setSampleColors(new Color[] {new Color(0x639a9c), new Color(0xff9a00)}); chart.setChartBackground(new Color(0xffffe7)); chart.setBackground(Color.white); chart.setLegendOn(true); chart.setLegendPosition(Chart.TOP); chart.setLegendLabels(new String[] {"Count", "Sales"}); chart.setSampleScrollerOn(true); chart.setRangeAdjusterOn(0, true); chart.setRangeAdjusterOn(1, true); chart.setBarWidth(0.6); chart.setBarOutlineOn(false); double[] overlayValues = new double[] {1247,648,1794,2238,3185,3997,4176,9247,8465,14982,12263,21847,23515,18344,20765,25047,18616,16327,19746,22547,24074}; LineChart overlay = new LineChart(); overlay.setSeriesCount(2); overlay.setSampleCount(overlayValues.length); overlay.setSampleValues(1, overlayValues); overlay.setValueLabelsOn(true); overlay.setSampleColors(new Color[] {new Color(0x639a9c), new Color(0xff9a00)}); overlay.setLineWidth(1, 4); overlay.setSampleHighlightOn(true); overlay.setSampleHighlightStyle(1, LineChart.SAMPLE_HIGHLIGHT_CIRCLE_OPAQUE, 8); overlay.setLabel("valueLabelPrefix", "$"); chart.addOverlayChart(overlay); 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(750,350); f.show(); } }