Chart Legend


Applet code: <applet code=com.objectplanet.chart.ChartApplet width=450 height=300 archive=chart.jar> <param name=chart value=bar> <param name=rangeStep value=100> <param name=sampleValues value="250,150,50,150,250,350,450,550,450,350,250,150,50,150,250,350"> <param name=sampleColors value="#8AD0F5,#8AB8F5,#899BF4,#AE89F4,#E889F4,#F58AC9,#F68B9B,#F69D8B,#F6B58B,#F6C78B,#F6D88B,#F6E88B,#F6F68B,#DCF58A,#9AF58A,#89F4D8"> <param name=multiColorOn value=true> <param name=insideLabelFont value="Serif,bold,14"> <param name=legendOn value=true> <param name=legendPosition value=bottom> <param name=legendColumns value=4> <param name=legendLabels value="sample 1, sample 2, sample 3, sample 4, sample 5, sample 6, sample 7, sample 8, sample 9, sample 10, sample 11,sample 12, sample 13, sample 14, sample 15, sample 16"> <param name=legendFont value="Arial,bold,10"> <param name=rangeLabelFont value="Arial,bold,12"> <param name=sliceSeperatorColor value=white> <param name=barWidth value=1> <param name=background value=white> </applet>
Servlet code: <img src="http://localhost:8080/servlet/com.objectplanet.chart.ChartServlet? chart=pie& width=450& height=300& rangeStep=100& sampleValues=250,150,50,150,250,350,450,550,450,350,250,150,50,150,250,350& sampleColors=%238AD0F5,%238AB8F5,%23899BF4,%23AE89F4,%23E889F4,%23F58AC9,%23F68B9B,%23F69D8B,%23F6B58B,%23F6C78B,%23F6D88B,%23F6E88B,%23F6F68B,%23DCF58A,%239AF58A,%2389F4D8& multiColorOn=true& insideLabelFont=Serif,bold,14& legendOn=true& legendPosition=bottom& legendColumns=4& legendLabels=sample1,sample2,sample3,sample4,sample5,sample6,sample7,sample8,sample9,sample10,sample11,sample12,sample13,sample14,sample15,sample16& legendFont=Arial,bold,10& rangeLabelFont=Arial,bold,12& sliceSeperatorColor=white& barWidth=1& background=white">
Application code: package com.objectplanet.chart.testing; import com.objectplanet.chart.*; import java.awt.*; public class Bar { public static void main(String[] argv) { double[] sampleValues = new double[] {250,150,50,150,250,350,450,550,450,350,250,150,50,150,250,350}; String[] legendLabels = new String[] {"sample 1","sample 2","sample 3","sample 4","sample 5","sample 6","sample 7","sample 8","sample 9","sample 10","sample 11","sample 12","sample 13","sample 14","sample 15","sample 16"}; Color[] sampleColors = new Color[] {new Color(0x8AD0F5),new Color(0x8AB8F5),new Color(0x899BF4),new Color(0xAE89F4),new Color(0xE889F4),new Color(0xF58AC9),new Color(0xF68B9B),new Color(0xF69D8B),new Color(0xF6B58B),new Color(0xF6C78B),new Color(0xF6D88B),new Color(0xF6E88B),new Color(0xF6F68B),new Color(0xDCF58A),new Color(0x9AF58A),new Color(0x89F4D8)}; BarChart chart = new BarChart(); chart.setSampleCount(sampleValues.length); chart.setSampleValues(0, sampleValues); chart.setSampleColors(sampleColors); chart.setMultiColorOn(true); chart.setRange(0, 600); chart.setFont("rangeLabelFont", new Font("Arial", Font.BOLD, 13)); chart.setBarWidth(1); chart.setLegendOn(true); chart.setLegendLabels(legendLabels); chart.setLegendPosition(Chart.BOTTOM); chart.setLegendColumns(4); chart.setFont("legendFont", new Font("Arial", Font.BOLD, 10)); chart.setBackground(Color.white); 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(); } }