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

Message ListMessage List     Post MessagePost Message

  Scatter point appearing outside of graph
Posted by James on Apr-19-2011 22:52
Attachments:
Hi

I have a graph with X axis set to date scale

start = new DateTime(this.StartTime.Year, this.StartTime.Month, this.StartTime.Day, 12, 0, 0);
span = new TimeSpan(-96, 0, 0, 0);
startFilter = ChartDirector.Chart.StartOfDayFilter();
endFilter = ChartDirector.Chart.StartOfDayFilter();
format2 = "-{value|d}";
end = start + span;
axis.setDateScale(start, end, 0);

The graph is drawn starting from yesterday going back 96 days.

I add a scatter point to the graph but set the date of the point to be 2 days in the future.

double[] Xvalues = new double[1];
double[] Yvalues = new double[1]
Xvalues[0] = ChartDirector.Chart.CTime(DateTime.UtcNow.AddDays(2));
Yvalues[0] = 100;

ScatterLayer layer = chart.addScatterLayer(Xvalues, Yvalues, "", ChartDirector.Chart.CircleSymbol, 17);

This point is outside the range of the graph.  I would not expect it to be displayed.  However it is still displayed beyond the left side of the graph.  Below is the attached image.  For me the display of this point is a bug of chart director.

This is significant for me because i want to be able to create a scrollable scatter graph for a whole years data and not have points displayed outside of the graph area as i scroll.

How do i force the graph to only display those points that are in its displayable area?

image/x-png
Point.png

  Re: Scatter point appearing outside of graph
Posted by Peter Kwan on Apr-20-2011 00:51
Hi James,

If the axis is auto-scaled by ChartDirector, the point should be within the axis scale.

If the axis scale is set up by your code, your code already knows the axis scale. If your code still passes data points outside the axis scale to ChartDirector, by default, ChartDirector will assume your code intentionally want to plot outside the plot area. So ChartDirector will accurately plot the points outside the plot area.

If you do not want to plot outside the plot area, there are two methods:

(a) Use XYChart.setClipping to ask ChartDirector to clip the layers to the plot area. This is the method used in the "Zooming and Scrolling Demonstration" sample code in ChartDirector. For example:

c.setClipping();

(b) Do not pass the point to ChartDirector. Since your code knows the axis scale, it can remove outside points before passing the data to ChartDirector.

Hope this can help.

Regards
Peter Kwan