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

Message ListMessage List     Post MessagePost Message

  Tables in the title bar
Posted by Eva on Sep-09-2013 21:42
Attachments:
Hi Peter,
I need to add some additional aggregated data into tables to the title bar of my Gantt Chart.
So, I created two tables with the following code:
CDMLTable table1 = c.addTable(x1, y1, Chart.TopLeft , nCols, nRows);
CDMLTable table2 = c.addTable(x2, y2, Chart.TopRight , nCols, nRows);

I?m having trouble positioning the tables, i.e. calculating (x,y) coordinates.  It doesn?t seem I can get them out the from my chart metrics.
Here are my chart metrics:
w=950&h=735&vl=25&vt=140&vw=900&vh=500

For example I want to position the left table at point (25px, 25px) (in reference to the TopLef), and the right table at point (925px, 25px) (in reference to TopRight) (as I included in the attached image).

What is the best way to figure this out?  Or maybe I need to use another method to create the tables?

Thank you,
Eva
TitleBar.png

  Re: Tables in the title bar
Posted by Peter Kwan on Sep-10-2013 01:21
Hi Eva,

The chart metrics are information for ChartDirector's internal use. You should not need to look at the chart metrics.

Anyway, all the information in the chart metrics are provided from your code. For example, the chart width is provided from your code. So your code should already know the chart width without look at the chart metrics. If you have the BaseChart object, you can also use BaseChart.getWidth to get the chart width.

Hope this can help.

Regards
Peter Kwan

  Re: Tables in the title bar
Posted by Eva on Sep-10-2013 01:54
Hi Peter,

I printed the metrics only for your information as an example to refer to. I did setup the width and hight of the chart and plot area in my code expilictly, I know. My question was how can I place the CDMLTable's object exactly where I want them.  For example, it doesn't work for me when I use x=25 and y=25 (px) as a TopLeft reference point's coordinates for a left table as I presented in the screen shot model.  Maybe I'm not using the method correctly.

On some of my other charts I use CDML language using block tags to pass to c.addTitle method. This works fine, but now I wanted to use CDMLTable to get the structure of the table. One time earlier I used CDMLTable with the axis, so I'm expecting that the CDML tables must use a different scale. Is this true? If so, how can I calculate this?

Thank you,
Ewa

  Re: Tables in the title bar
Posted by Peter Kwan on Sep-11-2013 01:49
Hi Eva,

I have just tried the following code. The tables are created correctly and are at their expected positions. The top-left corner of table1 is at (25, 25) in the chart, while the top-right corner of table2 is at (925, 25) in the chart. I am using the latest version of ChartDirector.

May be you can try the same code to see if the tables are at their expected position.

// The data for the line chart
double[] data = {30, 28, 40, 55, 75, 68, 54, 60, 50, 62, 75, 65, 75, 91, 60, 55, 53, 35, 50, 66, 56, 48, 52, 65, 62};

// The labels for the line chart
string[] labels = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"};

XYChart c = new XYChart(950, 400, 0xffffff, 0x000000);

int x1 = 25;
int y1 = 25;
int x2 = 925;
int y2 = 25;
int nCols = 4;
int nRows = 4;
CDMLTable table1 = c.addTable(x1, y1, Chart.TopLeft , nCols, nRows);
CDMLTable table2 = c.addTable(x2, y2, Chart.TopRight , nCols, nRows);

for (int i = 0; i < nCols; ++i)
{
   for (int j = 0; j < nRows; ++j)
   {
       table1.setText(i, j, "T1 = " + (i * nRows + j));
       table2.setText(i, j, "T2 = " + (i * nRows + j));
   }
}

c.setPlotArea(50, 120, 850, 240);

// Add a line chart layer using the given data
c.addLineLayer(data);

// Set the labels on the x axis.
c.xAxis().setLabels(labels);

// Display 1 out of 3 labels on the x-axis.
c.xAxis().setLabelStep(3);

// Output the chart
WebChartViewer1.Image = c.makeWebImage(Chart.PNG);


If the above example works, but your actual code does not work, is it possible to create an example so that I may reproduce the problem?

Regards
Peter Kwan

  Re: Tables in the title bar
Posted by Eva on Sep-12-2013 02:47
Attachments:
Thank you, Peter!

It looks like the problem is in the alignment Chart.TopRight.  I ran your code with my version of ChartDirector, and there is no right table at all. See that in the attached screen shot.  I have been testing only with Chart.TopRight, so I didn?t realize that the Chart.TopLeft was working correctly as one would expect.

I don?t have the latest version. How do you check the version of ChartDirector?

Thanks,
Eva
Tables_test.png

  Re: Tables in the title bar
Posted by Peter Kwan on Sep-12-2013 04:18
Hi Eva,

I have checked our source code records, and confirmed that there is a bug in ChartDirector 5.0 that the CDMLTable alignment would be incorrect except the TopLeft alignment, and that bug is fixed in ChartDirector 5.1.

Because no one had ever reported this issue to us, so this issue was entered on our bug list. It was discovered accidentally during ChartDirector 5.1 development, and was fixed as part of the ChartDirector 5.1 code.

The ChartDirector version can be obtained by using the Chart::getVersion API. You can also compared the date of the DLL or shared object with the ChartDirector 5.1 announcement date (Jun 25, 2012 as according to http://www.chartdir.com/forum/index.php?bn=chartdir_announcement). If it is earlier than the annoucement date, it is likely to be ChartDirector 5.0.

Hope this can help.

Regards
Peter Kwan

  Re: Tables in the title bar
Posted by Eva on Sep-13-2013 04:02
Thank you Peter!

So, what are my options to have that bug corrected?
Thanks,
Eva

  Re: Tables in the title bar
Posted by Peter Kwan on Sep-13-2013 15:28
Hi Eva,

You may upgrade to ChartDirector 5.1. Upgrading from ChartDirector 5.0 to 5.1 is free of charge.

In the minimum, you just need to download ChartDirector 5.1, and replace your existing ChartDirector DLLs (netchartdir???.dll if you are using .NET) or JAR (ChartDirector.jar or ChartDirector_s.jar if you are using Java) with the ones from the new version.

Hope this can help.

Regards
Peter Kwan