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

Message ListMessage List     Post MessagePost Message

  Scaling
Posted by John on Jul-08-2013 20:25
Attachments:
Hi,

These are the X and Y co-ordinates values for A1 Raw-P2-PSIA Curve shown in the screen shot 1.
397.116  , 14.562
350.615 , 14.578
319.514. 14.581
293.314, 14.586

These are the X and Y co-ordinates values for A2 Raw-P2-PSIA Curve shown in the screen shot 1.
406.349, 14.706
361.349, 14.712
330.75 , 14.716
271.95 , 14.723

When I try to break the curves at some point X = 340, my plot is like in Screen shot 2.The breaking of lines is not viewed properly due to the change in Y-Scale.

Suggest me a way to resolve this issue.

Thanks in advance,
John.
Screen Shot 1.png
Screen Shot 2.png

  Re: Scaling
Posted by Peter Kwan on Jul-09-2013 02:08
Hi John,

It seems ChartDirector believes there is a point with a very large value in your data. So ChartDirector sets the y-axis top limit to a very large value to accomodate all the data points. As a result, the other normal data points, which are now very small in value compared to the top limit, become very close to the zero line.

Would you mind to clarify how do you "break the curves at some point X = 340". The suggested method is to insert a NoValue point at X = 340, like: (*** Note *** the exact syntax of NoValue depends on your programming language)

397.116  , 14.562
350.615 , 14.578
340, NoValue
319.514. 14.581
293.314, 14.586

Then in the spline layer, please use layer.setGapColor to set the gap to transparent. For example, in PHP, it is like "$layer->setGapColor(Transparent);".

For testing, you may want to try one curve only and use hard coded data as above. If the hard coded data works, but your actual data do not work, it means your actual data are not the same as the hard coded data. One possible reason is that the X=340 point is set to an unexpected value.

Note that if you manipulate the data after inserting the NoValue point, your data manipulation code must be designed to support NoValue. In the past, I have seen code that manipulates data (eg. by dividing the data by 100) after inserting the NoValue point. If the code does not specifically handles NoValue, it will divide the NoValue point by 100 as well, and it would be no longer a NoValue point.

If the above still does not solve the problem, is it possible to inform me the charting code you are using with the hard coded data? I will try the code to diagnose the problem.

Regards
Peter Kwan

  Re: Scaling
Posted by John on Jul-09-2013 20:36
Hi Peter Kwan,

Thanks for your reply.

The solution you provided is well but it is not suitable for our application why because we are calculating the coefficients for each separated line after breaking the curve.
In order to break the curve we are creating two arrays. One array will contain the values which are less than the break value and the other will contain the values  greater than the break value.

Main array : rp->second[ii].xMainValuesList
Separate arrays : pData1 and pData2


for each (double dXVal in rp->second[ii].xMainValuesList)
{
double dYVal = rp->second[ii].yMainValuesList[j];
if (nRangeBreak != -1)
  {
   if (dXVal <= nRangeBreak)
     {
     pData1.xMainValuesList->Add(dXVal);
     pData1.yMainValuesList->Add(dYVal);
     }

   else if(dXVal > nRangeBreak)
     {
     pData1.xMainValuesList->Add(dXVal);
     pData2.yMainValuesList->Add(dYVal);
     }
  }
}


Thanks in advance,
John.

  Re: Scaling
Posted by Peter Kwan on Jul-10-2013 04:22
Hi John,

The method you use, which is to break the dta arrays into 2 arrays, should also work.

To verify, I suggest you use hard coded data for the two segments:

Line 1:
397.116  , 14.562
350.615 , 14.578

Line 2:
319.514. 14.581
293.314, 14.586

If the hard coded data works, but your pData1 and pData2 do not work, it is probably because the pData1 and pData2 are not equivalent to the hard coded arrays.

Actually, by just reading your code, there are something I cannot understand. For example, in your code, you have a line:

double dYVal = rp->second[ii].yMainValuesList[j];

But the value ii abd j are never changed in your for loop. It means dYVal is a constant in the loop, and does not change at all. Also in your code are the following lines:

     pData1.xMainValuesList->Add(dXVal);
     pData2.yMainValuesList->Add(dYVal);

I cannot understand why you add the x-coordinate to pData1, but the y-coordinate to pData2. In fact, the x-coordinate in never added to pData2 in your code.

Again, to diagnose the problem, you may want to display the values in pData1 and pData2 out in your debugger, or to create a text string from the data values in pData1 and pData2, and use the text string as the chart title (so you can see the actual arrays being used).

Regards
Peter Kwan

  Re: Scaling
Posted by John on Jul-10-2013 13:40
Hi,

Thanks for your reply.

My code works well and good in case of one breaking one curve.
But when I try two break two lines at a time there is a problem in Y Scale as I mentioned in my first post regarding this issue.

My code snippet is :

for each (double dXVal in rp->second[ii].xMainValuesList)
{
double dYVal = rp->second[ii].yMainValuesList[j];
if (nRangeBreak != -1)
  {
  if (dXVal <= nRangeBreak)
   {
pData1.xMainValuesList->Add(dXVal);
pData1.yMainValuesList->Add(dYVal);
   }
  else if(dXVal > nRangeBreak)
   {
pData2.xMainValuesList->Add(dXVal);
pData2.yMainValuesList->Add(dYVal);
   }
j++;

}

After debuugging, I can conclude that values in the data arrays pData1 and pData2 are correct.But still I dont understand why there is a change in Y scale and Why ChartDirector sets the y-axis top limit to a very large value.

Please suggest me a solution to control the the Y scale.

Thanks in advance,
John.

  Re: Scaling
Posted by Peter Kwan on Jul-11-2013 01:26
Hi John,

Have you tried to use hard coded data for testing, like:

array<double> line1x = {397.116, 350.615};
array<double> line1y = {14.562, 14.562};

array<double> line2x = {319.514, 293.314};
array<double> line2y = {14.581, 14.586};

array<double> line3x = {406.349, 361.349};
array<double> line3y = {14.706, 14.712};

array<double> line4x = {330.75, 271.95};
array<double> line4y = {14.716, 14.723};

If the chart does not work even if using hard coded data, please kindly inform me the charting code you are using, so that I can reproduce the problem using the same hard coded data.

If the hard coded data works, but your actual code does not work, it means the arrays produced by your actual code is not the same as the hard coded arrays. Because you have only provided a short part of your code, it is hard for me to diagnose where could be the problem.

Just by reading your code, there can be a lot of potential problems, which may not be an actual problem if all the code is known. For example, in your code, it is not know how the variable "j" is initialized. Is it initialized to 0? If you use the same code for both lines, are you sure the "j" is initialized to 0 for the first line, then re-initialized to 0 again for the second line?

Similarly, if the pData1 and pData2 are reused for the second line, are you sure they have been completely re-initialized (eg. the length of the xMainValuesList and yMainValuesList reset to 0)?

In your code, it does not include how you convert the pData1 and pData2 into arrays. Even if pData1 and pData2 are correct, if the conversion to arrays are incorrect, then the arrays are incorrect, and it can produce issues.

Also, have you tried my suggestion by creating a text representation of your arrays, and display it as the chart title? What you do see? Is it possible to attach the chart produced and also inform me of the part of the code that produces the chart?

Regards
Peter Kwan