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

Message ListMessage List     Post MessagePost Message

  Clipping
Posted by Nick on Jan-25-2008 11:24
Attachments:
I have a question that's related to clipping lines.  I have three data sets on a scatterplot chart.  The data sets don't overlap much.  Each has a trend line.  I'd like to only show the trend line in the vicinity of its data points.  That is the trend line would not show outside the minimum and maximum x and y values for the data set.

I've drawn a picture for you.  I had to vandalize the chart with some spray paint to disguise the data.  I crossed out the lines where I'd like them hidden.

Thank you for your thoughts on this,

Nick
scatter.PNG

  Re: Clipping
Posted by Peter Kwan on Jan-25-2008 16:29
Hi Nick,

You may consider to use x-zone colors as the line colors. You can configure the x-zone color to be transparent outside certain data range. So the trend line is effectively clipped with the data range.

For example (in VB/VBScript):

minXValue = cd.ArrayMath(myXData).min()
maxXValue = cd.ArrayMath(myXData).max()

Set myColor = c.xZoneColor(minXValue, cd.Transparent, c.xZoneColor(maxValue, &Hff0000, cd.Transparent))

Set layer = c.addTrendLayer(myYData, myColor)
Call layer.setXData(myXData)

(Note that the syntax differ depends on your programming language. If you need me to translate the above code to another programming language, please let me know what is your programming language.)

Hope this can help.

Regards
Peter Kwan

  Re: Clipping
Posted by Nick on Jan-30-2008 01:49
Peter,

That worked well.  ChartDirector continues to amaze and delight me.

Your code does raise another question.  How does the cd. notation work?  Is there a ChartDirector object that I need to declare or initialize?

These statements
      minXValue = cd.ArrayMath(myXData).min()
      cd.Transparent
cause compilation errors (name cd is not declared).

If I leave the cd. off, Visual Studio says the other name (Transparent) is not declared.  If I leave the cd. off the ArrayMath, VS says it's a type and cannot be used as an expression.

I have to use
      Dim minXValue = New ArrayMath(_xData).min()
      Private Const iTransparent as int32 = &HFF000000

Thank you for your help,

Nick

  Re: Clipping
Posted by Peter Kwan on Jan-30-2008 04:46
Hi Nick,

The "cd" syntax is for VB/VBScript. By VB, it means classical VB (the VB used in most Microsoft products such as the VB 6.0, or the VBA in MS Word, Excel, Access, etc).

Since you are using another programming language (VB.NET or VB 2005/2008), the syntax is different. In your case, "cd.Transparent" should be "Chart.Transparent", and "cd.ArrayMath" should be "New ArrayMath".

(Classical VB does not support namespace injection, or static class, so the "cd" syntax is needed.)

Hope this can help.

Regards
Peter Kwan