Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Text Help

Author
Message
Darkbluedeath
13
Years of Service
User Offline
Joined: 27th Aug 2011
Location:
Posted: 7th Sep 2011 01:23
i am trying to get my text to display the value of the bar graph.. as you will see my values scale the bars, jan is set to 2000 but if u move it, it moves the bar.. now how do i display the amount and get it move at the same time..

so if i were to put 3500 instead of 2000, it would be at the top of the bar for january.


//mathew tucker
//lab 3 - bar chart

#include "DarkGDK.h"

void DarkGDK()

{


DWORD Blue =dbRGB(0,0,255);
DWORD Red =dbRGB(255,0,0);
DWORD Green =dbRGB(0,255,0);
DWORD Yellow =dbRGB(255,255,0);
DWORD Black =dbRGB(0,0,0);
DWORD White =dbRGB(255,255,255);


dbInk(Yellow,Black);
int january=2000;
int febuary=3000;
int march=5000;

int textX1;
int textY1;

int pointPerPixel=25;
int barWidth=150;
int barHeight;

int lowerRightX;
int lowerRightY;
int upperLeftX;
int upperLeftY;

int textX;
int textY;

int lineStartX=0;
int lineStartY=400;
int lineEndX=639;
int lineEndY=400;

dbSetWindowTitle("Bar Chart");

dbLine(lineStartX,lineStartY,lineEndX,lineEndY);
//Start of January
lowerRightX=200;
lowerRightY=400;

upperLeftX=lowerRightX-barWidth;

barHeight=january/pointPerPixel;
upperLeftY=lowerRightY-barHeight;
dbInk(Blue,Black);
dbBox(upperLeftX,upperLeftY,lowerRightX,lowerRightY);
textY=420;

textX=upperLeftX+( (lowerRightX-upperLeftX) /2);

dbInk(White,Black);
dbCenterText(textX,textY,"January");
//End of January


//Start of Febuary
lowerRightX+=200;

upperLeftX=lowerRightX-barWidth;

barHeight=febuary/pointPerPixel;
upperLeftY=lowerRightY-barHeight;
dbInk(Red,Black);
dbBox(upperLeftX,upperLeftY,lowerRightX,lowerRightY);

textX=upperLeftX+( (lowerRightX-upperLeftX) /2);

dbInk(White,Black);
dbCenterText(textX,textY,"Febuary");
//End of Febuary

//Start of March
lowerRightX+=200;

upperLeftX=lowerRightX-barWidth;
barHeight=march/pointPerPixel;
upperLeftY=lowerRightY-barHeight;
dbInk(Green,Black);
dbBox(upperLeftX,upperLeftY,lowerRightX,lowerRightY);

textX=upperLeftX+( (lowerRightX-upperLeftX)/2);

dbInk(White,Black);
dbCenterText(textX,textY,"March");
//End of March
dbWaitKey();


}

Darkbluedeath
afaik
14
Years of Service
User Offline
Joined: 12th Jun 2010
Location: NYC
Posted: 7th Sep 2011 11:25
Similar to the way you placed a dbCenterText at the end of each month, place another dbCenterText that uses the same x-alignment that you used to print the months (textX) and a Y-value that is approximately 25pixels above the top of your upper Y-value.

For example
dbCenterText( textX, upperLeftY - 25, dbStr( february ) );

BTW, you spelled February wrong...
Darkbluedeath
13
Years of Service
User Offline
Joined: 27th Aug 2011
Location:
Posted: 7th Sep 2011 17:18
thanks for the help and meh.. suck at spelling

Darkbluedeath

Login to post a reply

Server time is: 2024-11-19 08:23:42
Your offset time is: 2024-11-19 08:23:42