
//==================================================================
//
//	bar_cht.cpp	-- demonstrates a simple 2D bar chart
//
//==================================================================

#include <zaf.hpp>
#include <cf_api/bz_zcht.hpp>
#include <cff3_zaf.h>

const int NUM_GROUPS = 5;
const int NUM_POINTS = 10;

double	DATA[NUM_GROUPS][NUM_POINTS] = 
{ 
	{ 33, 30, 27, 24, 21, 18, 15, 12,  9,  6 },
	{ 20, 18, 14,  2, 14, 37, 35, 30, 24, 23 },
	{ 16, 15, 23, 17, 24, 20, 18, 13, 28, 16 },
	{ 20, 15, 10, 12, 14, 20, 24, 28, 30, 32 },
	{ 12,  8,  6,  8, 12, 15, 16, 15, 12,  8,},
};




//
//	ChartWindow is a simple ZafWindow enclosing a ZafChart
//

class ChartWindow : public ZafWindow
{
public:
    ChartWindow ();
private:
  	ZafChart*		chart;
};





ChartWindow::ChartWindow ()
		: ZafWindow (10, 10, 50, 10)
{
	AddGenericObjects (new ZafStringData ("ChartFolio Test"));

    // 
    //	add a ZafChart to our Window:
    //
	chart = new ZafChart (0, 0, 0, 0, CF_ID_BAR_2D);
    chart->SetRegionType (ZAF_AVAILABLE_REGION);
    Add (chart);

	//
	//	add data to our chart:
	//
	for (int i = 0; i < NUM_GROUPS; i++)
	{
    	for (int j = 0; j < NUM_POINTS; j++)
        {
		    chart->AddDataPoint (i + 1, DATA[i][j]);
        }
    }
}





//
//	Simple, generic Main () -- add a new window to the window manager 
//	and allow Control () to process events
//
ZafApplication::Main ()
{
	zafWindowManager->Add (new ChartWindow);
    Control ();
	return (0);
}





