#include <zaf.hpp>
#include <cf_api/bz_zcht.hpp> // ChartFolio header for ZafChart

const int DATA_GROUPS = 5;
const int DATA_POINTS = 10;

double chartData[DATA_GROUPS][DATA_POINTS] =
{
	{ 20.0, 10.0, 20.0, 10.0, 20.0, 10.0, 20.0, 10.0, 20.0, 10.0 },
	{ 20.0, 18.0, 14.0, 2.0, 14.0, 37.0, 35.0, 30.0, 24.0, 23.0 },
	{ 33.0, 30.0, 27.0, 24.0, 21.0, 18.0, 15.0, 12.0, 9.0, 6.0 },
	{ 20.0, 15.0, 10.0, 12.0, 14.0, 20.0, 24.0, 28.0, 30.0, 32.0 },
	{ 16.0, 15.0, 23.0, 17.0, 24.0, 20.0, 18.0, 13.0, 28.0, 16.0 }
};

void AddChartData(ZafChart *chart)
{
	for (int i = 0; i < DATA_GROUPS; i++)
	{
		// Add the one-based data group.
		chart->AddDataGroup(i + 1);
		for (int j = 0; j < DATA_POINTS; j++)
			chart->AddDataPoint(i + 1, chartData[i][j]);
	}
}


int ZafApplication::Main()
{
	// Needed for compilers that don't look in the library for main.
	LinkMain();

	ZafWindow *window = new ZafWindow(0, 0, 65, 15);
	window->SetSizeable(false);
	window->AddGenericObjects(new ZafStringData("ChartFolio Charts for Zinc ZAF v5.x"));

	ZafChart *chart = new ZafChart(1, 7, 36, 7, CF_ID_AREA_2D, CF_ID_YVALS_ON_INT_IS);
	AddChartData(chart);
	window->Add(chart);

	chart = new ZafChart(33, 0, 36, 7, CF_ID_BAR_2D, CF_ID_YVALS_ON_INT_IS);
	AddChartData(chart);
	window->Add(chart);

	chart = new ZafChart(1, 0, 36, 7, CF_ID_LINE_2D, CF_ID_YVALS_ON_NAT_NS);
	AddChartData(chart);
	window->Add(chart);

	chart = new ZafChart(33, 7 ,33, 7, CF_ID_STACK_2D, CF_ID_YVALS_ON_NAT_NS);
	AddChartData(chart);
	window->Add(chart);

	zafWindowManager->Center(window);
	zafWindowManager->Add(window);

	Control();

	return(0);
}
