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

Message ListMessage List     Post MessagePost Message

  Finance Chart - Dividends addScatterLayer
Posted by Travis on Sep-22-2015 11:23
Attachments:
I have an asp project where I am attempting to show stock dividends.  When I add the
dividend data via the addScatterLayer the dividends show up for the correct amount and
for the correct days.  The problem is the dividend amount is small compared to recent price
activity and it expands the yAxis2 scale due to the relatively small dividend price.   See
image.  The small blue circles are the dividend amount and note the large gap between
them and the candlesticks.

What can I do to prevent the dividends from expanding the yAxis2 scale?

I've tried adding a scatter layer with yData() using my low price and an offset, then adding
an extra set of fields via addExtraFields(labels) with my labels being the actual dividend
values.  Couldn't get the label values to display for the javascript traceFinance() routine.

I'll face a very similar issue once I try to add stock splits.  Their values are ratios (2:1, 1:4,
etc.) and would like to know what approach I should use to add these too.

Thanks.
dividendsIncreasesYScaleScope.jpg

  Re: Finance Chart - Dividends addScatterLayer
Posted by Peter Kwan on Sep-23-2015 02:37
Hi Travis,

To prevent any layer from affecting the yAxis2 scale, you may set the layer to use other
axis, not the yAxis2 axis.

From your description, it seems you just want to put some symbols on the financial chart on
the dividend days, but the position of the symbols are not related to the dividend. I have
this impression because you mentioned that you can put the "dividend" symbols at the low
price, which is unrelated to the "dividend".

The issue is the label values. For the labels values, please add another layer using the
dividend values. To avoid that layer from affecting the yAxis or yAxis2 scale, please use
another axis. You may hide that extra axis and the layer so that it will not visibly affect you
chart. In this way, the track cursor will show your dividend data. An example is:

' Add the main chart with 240 pixels in height
Dim m As XYChart = c.addMainChart(240)

Dim hiddenAxis As Axis = m.addAxis(Chart.Left, 0)
hiddenAxis.setColors(Chart.Transparent, Chart.Transparent)

Dim hiddenLayer As Layer = m.addLineLayer(dividend, &Hff0000, "Dividend")
hiddenLayer.setUseYAxis(hiddenAxis)
hiddenLayer.setLineWidth(0)

Hope this can help.

Regards
Peter Kwan

  Re: Finance Chart - Dividends addScatterLayer
Posted by Travis on Sep-23-2015 04:45
Peter, thank you that really helped.

For the scatter layer, I'd like to create a tooltip.  I'm using:
scatterLayer.setHTMLImageMap("", "", "onmouseover='showDataPointToolTip({value})'
onmouseout='hideToolTip()'"

The javascript function displays the tooltip properly, but the value is my low price with the
offset value.   I'd like for it to display the dividend value.  Is it possible to show the dividend
value from the hidden layer in the scatter layer's tooltip?

Also, what approach would you recommend for doing the same with splits?  Again, splits are
not double, but are ratios such as 2:1, 1:4 and I can't see how to add these as an array to
something like the addLineLayer.

Kind regards,
Travis

  Re: Finance Chart - Dividends addScatterLayer
Posted by Peter Kwan on Sep-24-2015 00:55
Hi Travis,

Since you would like the tooltip to display when the mouse is over the scatterLayer, you
would need to attach the dividend value as an extra field to the scatterLayer.

For track cursors, the track cursor displays irrespective of whether it is over the scatter
symbol or any data point, so in this case, it is better to add it as a separate invisible layer.
For the tooltip, it only displays when the mouse is over the scatterLayer. So the best
method is to attach the tooltip value (the dividend) to the scatterLayer. It is like:

scatterLayer.addExtraField(dividend);
scatterLayer.setHTMLImageMap("", "", "onmouseover='showDataPointToolTip({field0})'
onmouseout='hideToolTip()'"

For splits can also be added similar to the above. In fact, you can add any text you like:

scatterLayer.addExtraField(anArrayOfTextForTooltips);
scatterLayer.setHTMLImageMap("", "", "onmouseover='showDataPointToolTip({field0})'
onmouseout='hideToolTip()'"

Hope this can help.

Regards
Peter Kwan

  Re: Finance Chart - Dividends addScatterLayer
Posted by Travis on Sep-24-2015 06:25
Peter, thank you very much!  This is exactly what I needed.

To anyone else this might help, on the addExtraField(), your array should exclude any extra
data points not visible.  So, I ended up using:

scatterLayer.addExtraField(dblDividends.Skip(intExtraDays).ToArray())