krysalis-jcharts/src/java/org/krysalis/jcharts/test DualAxisComboTestDriver.java,NONE,1.1

Chris McKay <[email protected]> Thu, 01 Jul 2004 02:06:43 +0000
Newsgroups gmane.comp.krysalis.jcharts.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11406/src/java/org/krysalis/jcharts/test

Added Files:
	DualAxisComboTestDriver.java 
Log Message:
Test case for Dual Y axis changes

--- NEW FILE: DualAxisComboTestDriver.java ---
/***********************************************************************************************
 * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
 *
 * Redistribution and use of this software and associated documentation ("Software"), with or
 * without modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright statements and notices.
 * 	Redistributions must also contain a copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
 * 	conditions and the following disclaimer in the documentation and/or other materials
 * 	provided with the distribution.
 *
 * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
 * 	products derived from this Software without prior written permission of Nathaniel G.
 * 	Auvil.  For written permission, please contact [email protected]
 *
 * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
 * 	in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
 * 	registered trademark of Nathaniel G. Auvil.
 *
 * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
 *
 * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
 ************************************************************************************************/

package org.krysalis.jcharts.test;


import java.awt.*;

import org.krysalis.jcharts.axisChart.AxisChart;
import org.krysalis.jcharts.axisChart.customRenderers.axisValue.renderers.ValueLabelPosition;
import org.krysalis.jcharts.axisChart.customRenderers.axisValue.renderers.ValueLabelRenderer;
import org.krysalis.jcharts.chartData.*;
import org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries;
import org.krysalis.jcharts.encoders.*;
import org.krysalis.jcharts.imageMap.ImageMap;
import org.krysalis.jcharts.properties.*;
import org.krysalis.jcharts.properties.util.*;
import org.krysalis.jcharts.types.ChartType;

/******************************************************************************************
 * This file provides examples of how to create all the different chart types provided by
 *  this package.
 *
 * @author Chris McKay
 * @version $Id: DualAxisComboTestDriver.java,v 1.1 2004/07/01 02:06:40 kiwicmc Exp $
 *******************************************************************************************/

public class DualAxisComboTestDriver {
    boolean supportsImageMap() {
        return true;
    }

    public static void main(String[] args) throws PropertyException, ChartDataException {
        ChartProperties               chartProperties = new ChartProperties();
        StackedBarChartProperties   stackedBarChartProperties = new StackedBarChartProperties();;
        BarChartProperties            barChartProperties = new BarChartProperties();
		IAxisDataSeries               dataSeries;
		AxisChartDataSet              axisChartDataSet;
        AxisProperties                axisProperties = new AxisProperties(false);
        ChartFont                     axisScaleFont;
        ChartFont                     axisTitleFont;

		axisScaleFont = new ChartFont(new Font("Arial", Font.BOLD, 10), Color.black);
		axisTitleFont = new ChartFont(new Font("Arial", Font.BOLD, 10), Color.black);
    
        axisProperties.getYAxisProperties().setShowEndBorder(false);
        axisProperties.getXAxisProperties().setShowEndBorder(false);

        axisProperties.getXAxisProperties().setLabelRotationAngle(30);

    //Dual axis properties
		((DataAxisProperties) axisProperties.getYAxisProperties()).setNumItems(9); 
		((DataAxisProperties) axisProperties.getYAxisProperties()).setUserDefinedScale(0, 25);
		// LHS axis look and feel
        axisProperties.getYAxisProperties().setScaleChartFont(axisTitleFont);
        axisProperties.getYAxisProperties().setTitleChartFont(axisTitleFont);
        axisProperties.getYAxisProperties().setAxisTitleChartFont(axisTitleFont);
		
        axisProperties.getXAxisProperties().setScaleChartFont(axisScaleFont);
        axisProperties.getXAxisProperties().setTitleChartFont(axisScaleFont);
        axisProperties.getXAxisProperties().setAxisTitleChartFont(axisScaleFont);

		axisProperties.getRightYAxisProperties().setShowAxis(true);
		((DataAxisProperties) axisProperties.getRightYAxisProperties()).setNumItems(5); 
		((DataAxisProperties) axisProperties.getRightYAxisProperties()).setUserDefinedScale(0, 25);
		// RHS axis look and feel
		axisProperties.getRightYAxisProperties().setTitleChartFont(axisTitleFont);
		axisProperties.getRightYAxisProperties().setScaleChartFont(axisScaleFont);
		axisProperties.getRightYAxisProperties().setAxisTitleChartFont(axisTitleFont);
		axisProperties.getRightYAxisProperties().setPaddingBetweenAxisTitleAndLabels(3);
		axisProperties.getRightYAxisProperties().setTitleChartFont(axisTitleFont);

        String[] axisLabels = {"Aug 13", "Aug 14", "Aug 15", "Aug 16", "Aug 17", "Aug 18", "Aug 19", "Aug 20", "Aug 21", "Aug 22", "Aug 23", "Aug 24", "Aug 25", "Aug 26"};
        dataSeries = new DataSeries(axisLabels, " ", "Total Backup Events", "Success Percentage",  null);

        stackedBarChartProperties.setShowOutlinesFlag(false);

		//Bars
        double[][] barData = { 
          { 11, 120, 163, 150, 107, 148, 152, 169, 144, 140, 159, 131, 176,  66}, 
          {  0,   6,   4,   6,   9,   6,   7,   7,   7,  12,   9,  13,  11,   2},
          {  0,  12,   4,   2,   1,  22,   5,   2,   2,   2,   0,   0,   3,   3}};

        Paint[] paints = {new Color(0x00, 0x56,0x99), new Color(0xD1,0xD6,0x18), new Color(0xB3,0x05,0x05) };
        String[] legendLabels = {"Successful", "Warnings", "Failures"};
        axisChartDataSet = new AxisChartDataSet(barData, legendLabels, paints, ChartType.BAR_STACKED, stackedBarChartProperties);
//        Stroke[] lineStrokes1 = {LineChartProperties.DASHED_LINE_STROKE, LineChartProperties.DASH_DOT_LINE_STROKE, LineChartProperties.DEFAULT_LINE_STROKE};
//        Shape[] lineShapes1 = {PointChartProperties.SHAPE_TRIANGLE, PointChartProperties.SHAPE_CIRCLE, PointChartProperties.SHAPE_DIAMOND};
//        LineChartProperties lineChartProperties1 = new LineChartProperties(lineStrokes1, lineShapes1);
//        axisChartDataSet = new AxisChartDataSet(barData, legendLabels, paints, ChartType.LINE, lineChartProperties1);

        dataSeries.addIAxisPlotDataSet(axisChartDataSet);

        //Lines
        double[][] lineData = { 
          {100,  91,  97,  98,  99,  87,  96,  98,  98,  98, 100, 100,  98,  95}, 
//          { 85,  85,  85,  85,  85,  85,  85,  85,  85,  85,  85,  85,  85,  85}};
          { 76,  76,  76,  76,  83,  83,  83,  83,  83,  83,  83,  76,  76,  76}};

        Stroke[] lineStrokes = {LineChartProperties.DASHED_LINE_STROKE, LineChartProperties.DASH_DOT_LINE_STROKE};
        Shape[] lineShapes = {PointChartProperties.SHAPE_TRIANGLE, PointChartProperties.SHAPE_CIRCLE};
        Paint[] linePaints = {Color.GRAY, Color.BLUE};
        String[] lineLegendLabels = {"Success Percentage", "Successful Backups Goal - 85.0%"};

        LineChartProperties lineChartProperties = new LineChartProperties(lineStrokes, lineShapes);
        axisChartDataSet = new AxisChartDataSet(lineData, true, lineLegendLabels, linePaints, ChartType.LINE, lineChartProperties);
        dataSeries.addIAxisPlotDataSet(axisChartDataSet);

        LegendProperties legendProperties = new LegendProperties();
        legendProperties.setBorderStroke(null);
        legendProperties.setChartFont(axisScaleFont);

        AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 752, 485 );

        axisChart.renderWithImageMap();
        ChartTestDriver.exportImage( axisChart, "DualYAxisChart.png" );
	}

}



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com