Bar Chart in C++

How to do this C routine in C++

Page 1 of 1

1 Replies - 3146 Views - Last Post: 11 January 2009 - 07:05 PM Rate Topic: -----

#1 jbresn   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-January 09

Bar Chart in C++

Posted 11 January 2009 - 12:34 PM

I consider myself to be a little above a beginner but not a professional programmer. I have been out of all programming for over 10 years, and with retiring recently, decided to update a program that I built in C, but have hit graphic roadblocks.

Basically the program tracks five years worth of ones Utilities Bill. In this case it is the units and Monthly Cost for Gas, Electric and Water. In C, I had a graph depicting the information for each breakout.

Below is the old C Function that would display the graph for units of Electricity used each month for 60 months. Anyone have an idea how to do this in C++?

Thanks for any assistance you can provide.


Function CODE:

makechart1()
{
float elecunits[] = { mb[0].kwh, mb[1].kwh, mb[2].kwh, mb[3].kwh, mb[4].kwh, mb[5].kwh, mb[6].kwh, mb[7].kwh, mb[8].kwh, mb[9].kwh, mb[10].kwh, mb[11].kwh, mb[12].kwh, mb[13].kwh, mb[14].kwh, mb[15].kwh, mb[16].kwh, mb[17].kwh, mb[18].kwh, mb[19].kwh, mb[20].kwh, mb[21].kwh, mb[22].kwh, mb[23].kwh, mb[24].kwh, mb[25].kwh, mb[26].kwh, mb[27].kwh, mb[28].kwh, mb[29].kwh, mb[30].kwh, mb[31].kwh, mb[32].kwh, mb[33].kwh, mb[34].kwh, mb[35].kwh, mb[36].kwh, mb[37].kwh, mb[38].kwh, mb[39].kwh, mb[40].kwh, mb[41].kwh, mb[42].kwh, mb[43].kwh, mb[44].kwh, mb[45].kwh, mb[46].kwh, mb[47].kwh, mb[48].kwh, mb[49].kwh, mb[50].kwh, mb[51].kwh, mb[52].kwh, mb[53].kwh, mb[54].kwh, mb[55].kwh, mb[56].kwh, mb[57].kwh, mb[58].kwh, mb[59].kwh, };

chartenv env;

_setvideomode(_MAXRESMODE); 

_setbkcolor(_BLUE);

if(_pg_initchart() == 0)
{
	_pg_defaultchart(&env, _PG_COLUMNCHART, _PG_STACKEDBARS);

	strcpy(env.maintitle.title, "Electrical Units Used");

	sprintf( text,"%d		  %d		  %d		  %d		  %d",yr1,yr1+1,yr1+2,yr1+3,yr1+4);

	strcpy(env.yaxis.axistitle.title, "E l e c t r i c a l   U n i t s");
	strcpy(env.xaxis.axistitle.title, text);
	env.maintitle.titlecolor = _CYAN;
	env.maintitle.justify = _PG_CENTER;
	env.yaxis.grid = 1;
	env.yaxis.axiscolor = 8;
	env.xaxis.axiscolor = 8;

	_pg_chart(&env, months, elecunits, 60);

	while (! kbhit())
	{;}
}

	_setvideomode(_DEFAULTMODE);
}


*edit: Please use code tags in the future, thanks! :code:

This post has been edited by Martyr2: 11 January 2009 - 04:09 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Bar Chart in C++

#2 perfectly.insane   User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: Bar Chart in C++

Posted 11 January 2009 - 07:05 PM

Well, this isn't C vs. C++, but about what libraries a compiler/development system comes with. A C++ compiler should compile most C code (there are very few new rules that break compatibility). Your best bet these days is to make a program that utilizes whatever the system GUI is (in this case, probably Windows). I don't know of any charting libraries for Windows off hand, but that doesn't mean that they don't exist.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1