Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 How to create a bar chart
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

FPHealthcare

22 Posts

Posted - 07 Nov 2007 :  22:53:03  Show Profile  Reply with Quote
I try to create a bar chart using following code. But there is a line between two bars. also the xValues are not right. Something wrong?

ChartView chartVu = this;

Font theFont;
int nnumpnts = 6;
double []x1= new double[nnumpnts];
double []y1 = new double[nnumpnts];

// height width
x1[0] =1; y1[0]=6;
x1[1] =2; y1[1] = 7;
x1[2] =3; y1[2]=10;
x1[3] =3.7; y1[3] = 10;
x1[4] =4; y1[4] = 20;
x1[5] =4.3; y1[5] = 11;

theFont = new Font("Microsoft Sans Serif", 10, FontStyle.Bold);

SimpleDataset Dataset1 = new SimpleDataset("Actual Sales",x1,y1);
CartesianCoordinates pTransform1 = new CartesianCoordinates();

pTransform1.SetScaleStartY(0);
pTransform1.SetScaleStartX(0);
pTransform1.SetScaleStopX(5);
pTransform1.SetScaleStopY(15);

pTransform1.SetGraphBorderDiagonal(0.15, .15, .9, 0.75) ;
Background graphbackground = new Background( pTransform1, ChartObj.GRAPH_BACKGROUND,
Color.FromArgb(30,70,70), Color.FromArgb(90,20,155), ChartObj.Y_AXIS);
chartVu.AddChartObject(graphbackground);

Background plotbackground = new Background( pTransform1, ChartObj.PLOT_BACKGROUND,
Color.Black);
chartVu.AddChartObject(plotbackground);

LinearAxis xAxis = new LinearAxis(pTransform1, ChartObj.X_AXIS);
xAxis.SetColor(Color.White);
chartVu.AddChartObject(xAxis);

LinearAxis yAxis = new LinearAxis(pTransform1, ChartObj.Y_AXIS);
yAxis.SetColor(Color.White);
chartVu.AddChartObject(yAxis);

Grid ygrid = new Grid(xAxis, yAxis,ChartObj.Y_AXIS, ChartObj.GRID_MAJOR);
ygrid.SetColor(Color.White);
ygrid.SetLineWidth(1);
chartVu.AddChartObject(ygrid);
ChartAttribute attribApnea = new ChartAttribute(Color.Red,0,DashStyle.Solid);
SimpleBarPlot plotApnea = new SimpleBarPlot(pTransform1,Dataset1,5,0.0,attribApnea,
ChartObj.JUSTIFY_CENTER);
chartVu.AddChartObject(plotApnea);

quinncurtis

1164 Posts

Posted - 08 Nov 2007 :  08:08:22  Show Profile  Reply with Quote
I would guess that your bargraph width value of 5.0 is ruining your graph, since your x-data values are only between 0.3 and 1.0 units apart. As a result your bars are overlapping, and extending out of the view. Use a width value of 0.2 and you will see a very different graph.

double barwidth = 0.2;
double barbase = 0.0;

SimpleBarPlot plotApnea = new SimpleBarPlot pTransform1,Dataset1,barwidth,barbase,attribApnea, ChartObj.JUSTIFY_CENTER);

Go to Top of Page

FPHealthcare

22 Posts

Posted - 08 Nov 2007 :  14:33:55  Show Profile  Reply with Quote
Is that possible to draw a bar just like a single line? The problem is, we want to draw bars between every 0.3 in 1 x-data value.Because, the bars are very tight, they always overlapping each other, even I set the barwidth to 0.1. Thanks.
Go to Top of Page

FPHealthcare

22 Posts

Posted - 08 Nov 2007 :  14:43:55  Show Profile  Reply with Quote
Thanks, I solved the problem, I just set the barwidth to 0.00001. Now the chart looks fine.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07