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

Message ListMessage List     Post MessagePost Message

  Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-09-2009 20:07
Attachments:
Hi there,

Please consider the attached file, I want to draw a similar chart, I have done all the codings the couple of things i cant do are:
The join lines, like i want to have some sort of pointer there.
And I want to draw the join line(pointer) of the sector label at the start of the sector rather than the middle of the sector.

Can i do this in chartdirector. Or is there any other way i can do this like by extending the some class. I am drawing in C#.


Thanks
Imran
chart.jpg

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-10-2009 01:21
Hi Imran,

I think you can draw the chart you want as a polar chart. See the "Polar Line Chart" sample code for an example. It is quite similar to your chart. The arrows can be created using a PolarVectorLayer.

I have tried the following code, and it seems to create something quite close to what you need:

PolarChart c = new PolarChart(460, 460);
c.setPlotArea(230, 230, 180);

//set up the angular scale from 0 - 360, and put labels around the chart
c.angularAxis().setLinearScale2(0, 360, new string[] {"xxx", "yyy", "zzz", "aaa"});

//set up the radial axis scale from 0 - 1
c.radialAxis().setLinearScale2(0, 1, new string[] {"", " "});
c.radialAxis().setColors(Chart.Transparent, Chart.Transparent)

//set the vectors just outside the chart at radius = 1
PolarVectorLayer layer = c.addVectorLayer(new double[] { 1, 1, 1, 1 }, new double[] { 0, 30, 60, 90 }, new double[] { 5, 5, 5, 5 }, new double[] { 180, 210, 240, 270 }, Chart.PixelScale, 0x000000);

//arrows pointed towards the data point
layer.setArrowAlignment(Chart.TopCenter);

//set the arrow shape to be a regular triangle
layer.setArrowHead2(new int[] { -5, -5, 0, 5, 5, -5 });

//set arrow size to be 10 x 10 pixels
layer.setArrowHead(10, 10);


*** NOTE ***: For simplicity, I have only entered 4 labels and 4 arrows above. Please extend them to the number of labels and arrows you need.

Hope this can help.

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-10-2009 15:07
Peter Kwan,

Thanks for your quick response and i got the idea which will solve me problem


Thanks
Imran

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-12-2009 00:47
Attachments:
Hi,

Please see the attached chart, Now as i have done with the pointers on top of each sector, But i can not display the values as labels, I have a string array which i want to pass to the chart and want to display those values but as you can see it only shows the pointer for the value "1". Is there any way i can add the labels from any other array.


Thanks
chart.jpg

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-12-2009 01:02
Hi Imran,

Yes. You can display any text strings or values you like. For example, in the code in my last message, it can show arbitrary text with the arrows.

For your case, may be you can inform me the charting part of the code, so I know how your chart is configured, and where does the "1" labels come from. I can then modify it to show the "values". (Please also clarify what type of values you would like to display.)

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-12-2009 15:13

Please consider the following statement:

//set the vectors just outside the chart at radius = 1
PolarVectorLayer layer = c.addVectorLayer(new double[] { 1, 1, 1, 1 }, new double[] { 0, 30, 60, 90 }, new double[] { 5, 5, 5, 5 }, new double[] { 180, 210, 240, 270 }, Chart.PixelScale, 0x000000);

The above line is from your example, Now if you can tell me how I set a string array to show the values:

My string array should be some thing like the following:
new string[] {"1:0","4:0","5:40","9:01",};

currently the "1"s are coming from the "xData" attribute of the addVectorLayer.

Hope i convey my point.

Regards
Imran

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-14-2009 17:11
Hi Imran,

In the original code I suggest, the labels are added using the angularAxis, like:

c.angularAxis().setLinearScale2(0, 360, new string[] {"xxx", "yyy", "zzz", "aaa", "", "ttt", "", "sjf" .....});

The labels are added as evenly spaced on the angular axis, because in your original example, the spokes seem to be evenly spaced.

If you would like to add the labels at arbitrary positions along the perimeter, you may use AngularAxis.addLabel. For example:

double[] positionOfLabels = {0, 30, 60, 90};
string[] labels = {"1:0","4:0","5:40","9:01"};

for (int i = 0; i < labels.Length; ++i)
    c.angularAxis().addLabel(positionOfLabels[i], labels[i]);

Hope this can help.

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-14-2009 21:26
Peter,

Thanks and Yes that solved me problem, Now I have an other question which is Can i store the chart as an image file. Is so can you please guide me.

Thanks
Imran

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-15-2009 02:16
Hi Imran,

The API is BaseChart.makeChart. For example:

c.makeChart("c:\\\\aaa.png");

Note that the path above is the file system path, not a URL path. If you are using ASP.NET, and you would like to use URL path, please remember to use Server.MapPath to convert the URL path to file system path first, before passing the path to ChartDirector.

Hope this can help.

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-26-2009 13:48
Hi there,


If you would like to add the labels at arbitrary positions along the perimeter, you may use AngularAxis.addLabel. For example:

double[] positionOfLabels = {0, 30, 60, 90};
string[] labels = {"1:0","4:0","5:40","9:01"};

for (int i = 0; i < labels.Length; ++i)
    c.angularAxis().addLabel(positionOfLabels[i], labels[i]);



Please consider the image uploaded in my first post. I want to labels to be in the same style, I am trying the set the angle of the labels by the following

for (int i = 0; i < labels.Length; ++i)
{
    c.angularAxis().addLabel(positionOfLabels[i], labels[i]);
    c.angularAxis().setLabelStyle("Arial", 7, 0x000000, 90);
}

I am trying to set this in a loop as you have advised, unlink in the above statement i am providing a array of angles but it seems that it is picking either the first or the last value of the angles array.

Can you please suggest my a way how i can achieve this.


Thanks and kind regards
Imran

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-27-2009 04:13
Hi Imran,

Assuming the "positionOfLabels" you are using is 0 - 360, have you set the angular axis scale to 0 - 360? For example:

c.angularAxis().setLinearScale2(0, 360, new string[] {});

If the above still cannot solve the problem, would you mind to inform me the complete charting part of your code, so I may know how your current chart is configured? Please also attach an image of the chart you get so far.

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-27-2009 21:07
Attachments:
Attached are my sourcecode, output image and the required chart.

Actually i want the direction of the labels same as in the 2nd image.  which is at 90 degree of the pointer.

Please let me know if you got my point

Thanks
Imran
image_now.png
temp.aspx
temp.aspx

3.27 Kb
    
chart.jpg

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-29-2009 02:50
Hi Imran,

I see what you mean now.

Unluckily, in ChartDirector, the rotation angles of all the angular axis labels are always the same. There is only one font angle applied to all angular labels. So it cannot achieve the font angles in your 2nd image.

Regards
Peter Kwan

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-29-2009 11:54
Ok, So can we have the labels in a way so that they wont overlap to each other, my only problem is that when they are very close they overlap.


Regards
Imran

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Peter Kwan on Dec-29-2009 21:43
Attachments:
Hi Imran,

After some thoughts, I have created an example in which the text labels are added as custom text (using BaseChart.addText), and compute the position of the labels directly.

Attached please find an example and the code that produced the chart.

Hope this can help.

Regards
Peter Kwan
polarline.png
polarline.aspx
polarline.aspx

2.74 Kb

  Re: Pie Chart: Can some one draw join line at the start of the sector
Posted by Imran on Dec-30-2009 19:21
Hi Peter,

Great! It seems this will solve me problem, let me check it and i will come back to you if i need some help.


Thanks
Imran