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

Message ListMessage List     Post MessagePost Message

  positioning textbox objects dynamically for addBarLayer2
Posted by Steve on Dec-08-2012 04:29
Attachments:
Hi,

I am using classic asp.

I am adding the bar layer like this:
Set layer = c.addBarLayer2(cd.Side)
call layer.setBarWidth(barWid)

then within my loop I am adding the datasets like this:
Call layer.addDataSet(arrData(iLayer), chartColor, arrDataLegendLabel(iLayer))

so within the same loop if I wanted to be able to call this:
set barbox = c.addText(xcoor,ycoor,barSigPlusMinus,"arial.ttf",tempFontSize,&Hff0000)

How would I calculate xcoor and ycoor to be positioned directly above the corresponding
bar that is in the last position in each dataset?

I tried using c.getXCoor(v) and c.getYCoor(v), but it always returns the same values no
matter which data point I am referencing.  I've since read this is expected from
addBarLayer2().

I have 1 to 4 datasets depending on input from the user each with four data points.  The
individual bar widths change to accomodate 'barWid' depending on the number of
datasets displayed.  The user also has the option to show a full range scale or auto scale
to the data on the y-axis.  This makes the top/middle portion of any one bar very
dynamically placed in the plotarea.

Screenshots attached.  I need the red plus signs above the bars and above any values
displayed.

In case it matters I am adding the labels within the same loop like this:
Call
layer.setDataLabelStyle("arial.ttf",tempFontSize,&H000000,tempRot).setPos(0,tempYoff)
Call layer.setDataLabelFormat("{value|0}"&pctSgn)

I had been fiddling with the numbers and it is sort of there left/right for three datasets,
but I would much rather have a dependable way to get the correct coordinates from the
chart rather than computing hard coded values for different amounts of datasets.

Any help is appreciated.

Thanks,
Steve
helpBarLayer2_cdforum.png
helpBarLayer2_cdforum2.png

  Re: positioning textbox objects dynamically for addBarLayer2
Posted by Peter Kwan on Dec-10-2012 23:21
Hi Steve,

If the axis is automatically scaled by ChartDirector, then ChartDirector cannot known the axis scale until you have entered all the data to the chart, because it can only determine the axis scale based on all your data. It means you cannot add a bar, then compute the coordinates to add the symbol, and then go to the next bar. You would need to add all the bars, and inform ChartDirector that it can now auto-scale the axis (as ChartDirector cannot know if you have already added all the data or not) by using BaseChart.layout. Then you can use Axis.getXCoor and Axis.getYCoor.

However, in your case, I think you should not need to worry about the pixel coordinates at all. You can just ask ChartDirector to add the "barSigPlusMinus" to the end of the bar with your other labels. The label type in your case can be added using addCustomGroupLabel (which is a label on top of the bar).

For example:

Set layer = c.addBarLayer(cd.Side)
For i = 0 To dataSetCount - 1
   Call layer.addDataSet(arrData(i), chartColor, arrayDataLegendLabel(i))
   lastBar = Ubound(arrData(i))
   For j = 0 To lastBar
        label = "{value|0}" & pctSgn
        If j = lastBar Then label = label & "  <*color=FF0000*>" & barSigPlusMinus
        Call layer.addCustomGroupLabel(i, j, label, "arial.ttf",tempFontSize,&H000000,tempRot)
   Next
Next

Hope this can help.

Regards
Peter Kwan

  Re: positioning textbox objects dynamically for addBarLayer2
Posted by Steve on Dec-11-2012 03:39
Hi Peter,

This is exactly what I was trying to do.  Thanks a bunch!

Not a huge deal, but as well as plus signs there are also minus signs being displayed.  The
rotation of the entire label doesn't matter for plus signs because it looks the same,
however, minus signs are now vertical instead of horizontal.

Is there a way to rotate just one character within the group label?

  Re: positioning textbox objects dynamically for addBarLayer2
Posted by Steve on Dec-11-2012 03:53
Hi,

I figured out the solution to my most recent questions.  I just built the label a little
differently.

If j = lastBar Then label = "<*color=FF0000*>" & barSigPlusMinus & "<*br*>
<*color=000000*>" & label.


Thanks again for your help.