ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  layout
Posted by acura on Nov-28-2006 21:22
Attachments:
hi

     i want the zone to be displayed from  y-axis2 which is in blue color(see  pic 2 chart1.png). but the zone is displaying form y -axis(orange color) . i used c.layout() to draw rectangle. but that rectangle is displaying out side plotarea . this is my code. plz help me






double[] data0 = {110,170,115,220,125,185,220};
double[] data1 = {110,115,95,110,90,112,125};
double[] data2 = {98,100,80,95,85,100,105};
String[] labels = {"Sun","Mon","Tue", "Wed",  "Thu",  "Fri",  "Sat"};
if (xaxis >= 160 && yaxis >= 120) {
c =new XYChart(xaxis-30, yaxis-30);
c.setPlotArea(28, 19,(xaxis-35-30),(yaxis-38-30),0xFFFFFF,-1,0xffffff,c.dashLineColor(0xB2B2B2, Chart.DashLine)); //34, 10,118,83
} else {
c =new XYChart(120, 100);
c.setPlotArea(20, 16,68,50,0xFFFFFF,-1,0xffffff,c.dashLineColor(0xB2B2B2, Chart.DashLine));
}
SplineLayer layer = c.addSplineLayer();
SplineLayer layer1 = c.addSplineLayer();
c.yAxis().setTitle("(mmHg)", "Arial",7,0xF9A01B).setAlignment(Chart.TopCenter);

c.yAxis().setColors(0xF9A01B, 0xF9A01B, 0xF9A01B);
c.yAxis().setLabelStyle("Arial Bold",8,0xF9A01B,0);
layer.setUseYAxis(c.yAxis());
layer.addDataSet(data1,0xF9A01B,"").setDataSymbol(Chart.DiamondSymbol,10,0xF9A01B,0xF9A01B);
layer.addDataSet(data2,0xF9A01B,"").setDataSymbol(Chart.DiamondSymbol,10,0xF9A01B,0xF9A01B);
        layer.setLineWidth(2);
        layer.setUseYAxis(c.yAxis());
        if (xaxis > 160 && yaxis > 120) {
leftAxis = c.addAxis(Chart.Left, -34);
c.xAxis().setMargin(8,38);
} else {
leftAxis = c.addAxis(Chart.Left, -22);
c.xAxis().setMargin(6,28);
}
        leftAxis.setTitle("(mg/dL)", "Arial",7,0x00ADEF).setAlignment(Chart.TopRight2);
        leftAxis.setColors(0x00ADEF, 0x00ADEF, 0x00ADEF);
        leftAxis.setLabelStyle("Arial Bold",8,0x00ADEF,0);

layer1.addDataSet(data0,0x00ADEF,"").setDataSymbol(Chart.CircleSymbol,8,0x00ADEF,0x00ADEF);
leftAxis.addZone(130,165, 0xBAD5F0);
layer1.setUseYAxis(leftAxis);

        c.xAxis().setLabels(labels);
if (xaxis <= 160 && yaxis <= 120)
c.xAxis().setLabelStep(3);

c.xAxis().setLabelStyle("Arial Bold",8,0x000000,0);
c.yAxis().setLinearScale(40,290,80);
leftAxis.setLinearScale(60,230,80);
c.yAxis().setWidth(2);
leftAxis.setWidth(2);
c.xAxis().setWidth(2);
}
          c.layout();
         c.getDrawArea().rect(28, 60, 500,95, 0xffffff, 0xffffff);
viewer.setImage(c.makeImage());
chart2.png
chart1.png

  Re: layout
Posted by Peter Kwan on Nov-29-2006 03:53
Hi Acura,

In your case, your rectangle is drawn before the zone, so it has no effect. The zone will overwrite the white rectangle.

I suggest you may consider not to use addZone at all. Try use the following code:

//remember to use transparent plot area background
c.setPlotArea(28, 19,(xaxis-35-30),(yaxis-38-30), Chart.Transparent,-1,0xffffff,c.dashLineColor(0xB2B2B2, Chart.DashLine));

.....draw chart as usual .....

c.layout();

//draw zone
int yCoor1 = c.getYCoor(130, leftAxis);
int yCoor2 = c.getYCoor(165, leftAxis);

if (xaxis > 160 && yaxis > 120) {
   c.getDrawArea().rect(28 + 34, yCoor1, xaxis - 35 - 30 - 34, yCoor2 - yCoor1 + 1, 0xBAD5F0, 0xBAD5F0);
} else {
   ............ similar code .............
}

Hope this can help.

Regards
Peter Kwan