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

Message ListMessage List     Post MessagePost Message

  Custom Symbol w addScatterLayer (x-axis offset)
Posted by Thom on May-29-2012 21:37
I am using the following code which is working as expected but I need the ability to slightly
offset the x-axis of the symbol position to the left or right of its set position. I have tried
setPOS or alignment but I cannot seem to get the syntax correct.

c.addScatterLayer(null, new ArrayMath(data7).selectEQZ(new
ArrayMath(pointType).sub(1).
result(),Chart.NoValue).result(),"BC (R) w
Masking").getDataSet(0).setDataSymbol2("lessthanred.png");

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Peter Kwan on May-30-2012 00:35
Hi Thom,

The details really depends on which part of the chart you would like to offset, and whether you would like to offset using the axis unit, or the pixel unit. An example to offset using the axis unit is:

ScatterLayer layer = c.addScatterLayer(null, new ArrayMath(data7).selectEQZ(new
ArrayMath(pointType).sub(1).
result(),Chart.NoValue).result(),"BC (R) w
Masking");

layer.getDataSet(0).setDataSymbol2("lessthanred.png");

//offset by half the x-axis label distance
layer.setXData(0.5, data7.length - 1 + 0.5);

//Offseting the data points may cause the points to move outside the x-axis range.
//ChartDirector may then extend adjust the x-axis range to keep the data point within
//the range. If you do not want the x-axis to be adjusted, please use the following
//code the set the x-axis labels.
c.xAxis().setLinearScale(0, labels.length - 1, labels);

Hope this can help.

Regards
Peter Kwan

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Thom on May-30-2012 01:00
In this case I have a static x-axis which cannot change due to other data points that must stay on the x-axis. I am using a mult-line/custom symbol chart.

I need the ability to control a series of y-axis data points and offset them (left or right) from the static x-axis.

For instance, if I have a data point at (10, 4000), I need the ability to have it plot at (10, 3995) or at (10, 4005). There needs to be enough offset to being noticeable to the end-user but only for a certain set of data points.

Hope this makes it a little clearer.

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Thom on May-30-2012 22:19
Peter,

By chance have you had a chance to review my last post?

Appreciate any assitance you may be able to provide.

Thank you,

Thom

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Peter Kwan on May-30-2012 23:24
Hi Thom,

I may be confused when you mentioned you would like to "slightly offset the x-axis of the symbol position to the left or right". In ChartDirector, the x-axis is by default horizontal, but can also be vertical (if you use BaseChart.swapXY).

If you have not called BaseChart.swapXY, then the x-axis is the horizontal axis. Offseting a point left or right can be achieved by modifying its x-coordinates. One method is to use Layer.setXData, which is already mentioned in my last message.

If you have called BaseChart.swapXY, then the y-axis is the horizontal axis. In this case, offseting a point left or right can be achieved by modifying the y-coordinates.

From what you mentioned, it seems you are intending to move the horizontal position in pixel coordinates. In other words, the horizontal movement does not need to reflect any data value. In other words, the movement can be 0.1, 1, 5, 10, 100, etc in data values. The actually data values do not matter as long as the movement is a few pixels.

For pixel based movements, if you are using a custom symbol, a simple method is just to shift your symbol. For example, you can create an image of 32 x 32 as your symbol. Instead of putting your symbol shape right at the middle of your symbol image, you can move your symbol shape to the left side of your symbol image. (The symbol image would need to have a transparent background.)

Hope this can help.

Regards
Peter Kwan

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Thom on May-30-2012 23:41
Attachments:
Peter,

I understand what you are recommending but I thought I would attach what I've created in CD to hopefully better explain myself.

I need the ability to take the custom left and right bracket symbols and shift them to the left or right side of the x-axis. They cannot appear on the x-axis lines. I realize this seems strange but this is requirement when plotting a hearing audiogram.

Thanks again,

Thom
Audiogram.pdf
Audiogram.pdf

74.44 Kb

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Peter Kwan on May-31-2012 01:41
Hi Thom,

I believe the right or left bracket symbols in your chart are implemented as custom images. In this case, you can just shift your custom image to the left or right in your image file. (I noted that your image has a white background. You may want to change the image background to transparent.)

In the following example, I am using a custom DrawArea as the symbol. Basically, it is just an image 16 x 16 in size, with a Transparent background, and with the "[" symbol dock to the left side of the image:

DrawArea d = new DrawArea();
d.setSize(16, 16, Chart.Transparent);
d.line(0, 1, 4, 1, 0xff0000, 2);
d.line(0, 0, 0, 15, 0xff0000, 2);
d.line(0, 15, 4, 15, 0xff0000, 2);

c.addScatterLayer(null, new ArrayMath(data7).selectEQZ(new
ArrayMath(pointType).sub(1).
result(),Chart.NoValue).result(),"BC (R) w
Masking").getDataSet(0).setDataSymbol3(d);

I have not tried myself, but I think the shifted "]" symbol is:

DrawArea d = new DrawArea();
d.setSize(16, 16, Chart.Transparent);
d.line(11, 1, 15, 1, 0xff0000, 2);
d.line(14, 0, 14, 15, 0xff0000, 2);
d.line(11, 15, 15, 15, 0xff0000, 2);

Hope this can help.

Regards
Peter Kwan

  Re: Custom Symbol w addScatterLayer (x-axis offset)
Posted by Thom on May-31-2012 02:28
That is perfect, looks so much better than the custom image. This product has tremendous capabilities.

Thom