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

Message ListMessage List     Post MessagePost Message

  addScatterLayer
Posted by Alberto on Dec-07-2005 08:21
In Finance Chart, I want add a symbol in the graph.
I use addScatterLayer into xyCh object, but I don't see nothing.
The code is :
//array length should be the same as any other data array
double[] dataY1 = new double[timeStamps.Length];

//initialize to NoValue if not all points have data
for (int i=0; i < dataY1.Length; i++)
{
   dataY1[i] = Chart.NoValue;
}

//put data in the appropriate slot in the array
dataY1[10] = 2.88;

//draw the scatter layer
xyCh.addScatterLayer(null, dataY1, "b", Chart.InvertedTriangleSymbol);


The Value 2.88 is correct and It can be displaied correctly.

I'm sorry about my poor english...
Thanks
Alberto

  Re: addScatterLayer
Posted by Peter Kwan on Dec-07-2005 16:56
Hi Alberto,

Usually, the first few points of the chart for any data series are not displayed, as they are extra leading data used to compute moving averages only.

In the financial chart sample codes that come with ChartDirector, the number of extra points are usually in the variable extraDays or extraPoints.

So I think you code should be:

double[] dataY1 = new double[timeStamps.Length];

//initialize to NoValue if not all points have data
for (int i=0; i < dataY1.Length; i++)
{
   dataY1[i] = Chart.NoValue;
}

//put data in the appropriate slot in the array
dataY1[extraPoints + 10] = 2.88;

//draw the scatter layer
xyCh.addScatterLayer(null, dataY1, "b", Chart.InvertedTriangleSymbol);

Hope this can help.

Regards
Peter Kwan

  Re: addScatterLayer
Posted by Mike on Mar-09-2006 03:13
Is it necessary to add all the y data points? Let's say I simply want to plot a single symbol on a particular date, at a particular price. Do I need to fill an entire yData array with Chart.NoValue as in your example?

Same question for an Arbitrary XY Line chart. I'd like to plot a line segment on the FinanceGraph. I'd prefer not to interpolate each Y value to get a straight line and then fill the rest with Chart.NoValue. Is it possible to add a layer to FinanceChart that is a line segment?

Thanks!

  Re: addScatterLayer
Posted by Peter Kwan on Mar-09-2006 04:52
Hi Mike,

The method described in my example should be the easiest method to use, that is, creating an empty data series (that is a NoValue data series), and then put your data point at the correct "slot" of the data series.

For an "arbitrary XY chart", we suggest the same method as the scatter chart, but instead use a line layer. You do not need to "interpolate" the y values. You just need to insert the data points in the correct "slot" of the data series. Then you may use the following code to ask ChartDirector to join the points with line segments, skipping any intermediate NoValue points.

lineLayer.setGapColor(Chart.SameAsMainColor);

Hope this can help.

Regards
Peter Kwan

  Re: addScatterLayer
Posted by Mike on Mar-09-2006 05:12
Ah! I wasn't aware that it would not draw any lines until reaching the first non Chart.NoValue entry. This works great! Thanks!

  Re: addScatterLayer
Posted by Dario on Mar-20-2012 19:30
Attachments:
Hello,

is there also a solution for the php version of chartdirector?

for ($i = 0; $i < count($timeStamps); $i++) {
   if($signal[$i]==1) {
      $buySignals[] = $lowData[$i]-($lowData[$i]*0.001);
   }else{
      $buySignals[] = NULL;
   }
}

You can see, i put a NULL (no value) inside the array where i need no symbol to appear.

But on the chart this "no value" appears as a "0" (zero).

Any ideas or solutions? Thank you for your help.
Bildschirmfoto 2012-03-20 um 12.24.13.png

  Re: addScatterLayer
Posted by Peter Kwan on Mar-20-2012 23:19
Hi Dario,

In PHP, the syntax for NoValue is just NoValue:

for ($i = 0; $i < count($timeStamps); $i++) {
   if($signal[$i]==1) {
      $buySignals[] = $lowData[$i]-($lowData[$i]*0.001);
   }else{
      $buySignals[] = NoValue;
   }
}

Note that NoValue is a ChartDirector constant defined in the ChartDirector PHP module "phpchartdir.php". To use NoValue, please make sure you have included "phpchartdir.php" in your code.

Hope this can help.

Regards
Peter Kwan

  Re: addScatterLayer
Posted by Dario on Mar-20-2012 23:25
Great, it works. I thought NoValue is a VB syntax.

Thank you very much :)