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

Message ListMessage List     Post MessagePost Message

  Adding mark at first or last position overlaps graph axis
Posted by Wes G on Sep-04-2013 04:02
Attachments:
(in ruby)

For example:

    mark = c.xAxis().addMark(position, 0xDD8888, "Data not submitted", "", 9)
    mark.setMarkColor(0xFFBBBB, 0xAA6666)
    mark.setLineWidth(marker_width)
    mark.setAlignment(ChartDirector::Center)
    mark.setFontAngle(90)
    mark.setDrawOnTop(false)

When 'position' == 0, then the mark's width causes it to overlap the yAxis and labels.

I couldn't find a way to get the Mark bounding box.

I tried:

mark.setPos(0, mark.getTopY)

... but that appeared to affect the TextBox, not the Mark.
Screen shot 2013-09-03 at 2.56.45 PM.png

  Re: Adding mark at first or last position overlaps graph axis
Posted by Peter Kwan on Sep-05-2013 00:34
Hi Wes,

For the mark bounding box, the width of the mark is supplied by your code, so your code already knows the width (it is marker_width in your code). The height is equal to the height of the plot area, which is also supplied by your code, so your code already knows that. The "topY" is the top of the plot area (again supplied by your code), and the horizontal middle point of the mark is at x = position in data value.

For your case, I am not sure how you would like to chart to appear. It is normal for the mark to overlap the y-axis for your chart configuration. There are many methods to avoid that. For example, you may add a margin to the x-axis, so that the first label at the x-axis is not at the left edge of the plot area, but is at a margin:

c.xAxis().setMargin(marker_width / 2, marker_width / 2)

If you can inform me how you would like to chart to appear, I may try to suggest methods to configure the chart to achieve what you want.

Regards
Peter Kwan

  Re: Adding mark at first or last position overlaps graph axis
Posted by Wes G on Sep-05-2013 11:55
c.xAxis().setMargin(marker_width / 2, marker_width / 2)

That's not how I was thinking about it, adding margin INSIDE the plot area so that the
mark would fill the entire space between data points.

But that's perfect, it lets the mark area fill that space completely.

I was going to do the calculation for (plot area width / number of data points) =>
marker_width, but is there a way to make the mark auto-calculate that? Basically, I want
successive missing data points to have a completely filled background, but I could have 4-
30 values on the x-axis.

If not, no worries!  .setMargin() is just what I was looking for, thanks for the pointer!

  Re: Adding mark at first or last position overlaps graph axis
Posted by Peter Kwan on Sep-06-2013 00:23
Hi Wes G,

If your intention is to "fill the entire space between data points", you may consider to use a "zone" instead of a "mark". (Note that if you fill the entire space between data points with the same mark or zone color, it is equivalent to fill the entire plot area with the same color, so I expect in your real code, the zones or marks will be of different colors.)

For using zones, the code is like:

0.upto(myXLabels.length - 1) do |i|
   c.xAxis().addZone(i - 0.5, i + 0.5, myZoneColor)
end

The key difference between a zone and a mark is that a mark is intended to represent a single coordinate, such as a threshold value. The mark width is intended for decorative use (such as for highlighting or to facilitate human reading), and it is expressed in pixels. For a zone, it is intended to represent a range of values, and so the width is in data units. For your case, it seems zones may fit you needs better.

Hope this can help.

Regards
Peter Kwan

  Re: Adding mark at first or last position overlaps graph axis
Posted by Wes G on Sep-06-2013 00:44
Oh, I didn't realize one could pass floating values to addZone(), so the plus/minus 0.5
should be exactly what I need.

Thanks again, Peter!