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

Message ListMessage List     Post MessagePost Message

  How to Handle Data with 8 Decimal places
Posted by MarkZB on Jun-21-2018 05:12
Attachments:
My X axis array comprises values such as 0.00000081, 0.0000084 etc

First problem:

If i pass such an array to barLayer.setXData(xRates);

the spacing on the x axis is enormous (I only see 1 item)

My current workaround is too multiply the data by 100000000

var sells_rate = LIST_SELLS.Select(x => (double)(x.Rate * 100000000)).Take(cnt).ToArray();

However I would prefer to maintain the original values. Is there a better way?

My second problem is with Zooming

Once I multiply above array by 100000000 I get round values such as 81, 84 etc

However getValueAtViewPort returns fractionals eg viewPortStart = 81.800000000000011 which does not match to my x array

// Get the start date and end date that are visible on the chart. #VIEWPORT
var viewPortStart = winChartViewer.getValueAtViewPort("x", viewer.ViewPortLeft);
var viewPortEnd = winChartViewer.getValueAtViewPort("x", viewer.ViewPortLeft + viewer.ViewPortWidth);

What is the correct way of handling this?
getValueAtViewPort.png

  Re: How to Handle Data with 8 Decimal places
Posted by MarkZB on Jun-21-2018 08:07
Attachments:
FYI - the doubles are being passed as 6.8E-07 ie 0.00000068

Note that if i multiply the number by 1000, the problem in goes away.

Its as if Chart Director is losing decimal places....
8decdouble.png

  Re: How to Handle Data with 8 Decimal places
Posted by Peter Kwan on Jun-22-2018 03:02
Attachments:
Hi MarkZB,

As I do not have your chart image or data, it is hard to know what is the cause of "the spacing on the x axis". I guess it is due to the default axis indentation for bar charts or any "box based" charts (candlesticks, box-whisker). See:

http://www.advsofteng.com/doc/cdnet.htm#Axis.setIndent.htm

The default axis indentation is designed for label based x-axis, which is the most common type of axis for "box based" charts. You may try to disable it to see if it solves the problem:

c.xAxis().setIndent(false);

For the viewport, when zooming in, the user can drag a rectangle to select the region to zoom in. There is no requirement that the edges of the viewport must align with a data point. I have attached a screenshot that shows that the edges of the rectangle are not aligned with the data points.

Also, when your drag using the mouse, there is always the confusion as to where is the mouse. On Windows, the mouse must be at a pixel position, but a pixel is not a point - it is a region (a square). The left edge, right edge and center of the pixel rectangle can represent different values. So the mouse is actually pointing at a range of values, and there is no guarantee that the value used for the viewport aligns with any of the data point.

What is important is whatever the viewport happens to be, the chart will display all the data representation inside the viewport.

Regards
Peter Kwan
zoom_example.png