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

Message ListMessage List     Post MessagePost Message

  My Point and Figure Chart
Posted by icm63 on Jan-14-2009 00:29
Using your code here : http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=point+and+figure&thread=1171375913#N1171375913

Q: How does remove the % axis on the right hand side, and replace it with a mirror of the left hand axis (so they are both the same) ?

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-14-2009 02:31
Hi icm63.

Actually, I do not remember why there is a percentage axis in the chart. This axis probably has no purpose (may be I forgot to remove some testing code when I posted the code in the forum).

Anyway, the percentage axis is generated from the last 4 lines:

Dim startPrice As Double
startPrice = 24
c.syncYAxis(100.0/120, -40)
c.yAxis2().setLabelFormat("{value|2}%")

If you remove them, there wil be no percentage axis. If you use the following line instead, the left and right axes will become identical.

c.syncYAxis(1, 0)

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-14-2009 03:29
Attachments:
Thanks, I am working with your code and I am a newbie..on your control..

How do I adjust your code to allow a more presentabe axis and grid (maybe grid needs to stay this way on the PF structure ??)
see doc attached...
Doc2.doc
Doc2.doc

44.50 Kb

  Re: My Point and Figure Chart
Posted by icm63 on Jan-14-2009 10:12
Forget the last question, cracked it !

  Re: My Point and Figure Chart
Posted by icm63 on Jan-15-2009 05:43
You must have had this Yaxis issue a few times..for an xy chart used on the PF chart above posts.

say..

Max value 500
Min Value 300
Diff is 200

How to set this code to get the most dense but readable axis on the chart ?

c.yAxis().setMultiFormat(Chart.RegularSpacingFilter(40, 1), "{value|0}")

How to determine the number 40..when a stock is btw 9.50 and 9.75, or another is btw 20.25 and 30.25 or another 250 to 500..

Why code do you advise/use to get a dense ( ie lots of labels) but readable to the eye ???

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-15-2009 19:32
Hi icm63,

To draw a PF chart, first you need to determine the box size (the price range represented by a box). The box size is either entered by the user, or your code would need to find some way to determine the box size. Some people will just hard coded the box sizes to use for all possible price ranges (from 0.01 to 1000000).

After you have determined the box size, you can use the same method as in the sample code to determine the y-axis scale:

Dim maxValue As Double = Math.Ceiling(New ArrayMath(riseSymbolsY).max() / boxSize) * boxSize
Dim minValue As Double = Math.Floor(New ArrayMath(fallSymbolsY).min() / boxSize) * boxSize

c.yAxis().setLinearScale(minValue, maxValue, boxSize)

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-15-2009 22:39
Sorry you missed my point...

This code determines the labels on the y axis, thats my issue,

c.yAxis().setMultiFormat(Chart.RegularSpacingFilter(40, 1), "{value|0}")

How to determine that so, please re read my post..

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-15-2009 23:04
Hi icm63,

Do you mean you must insist on using the following code to set up the y-axis labels, and do not allow me to modify the code or to suggest an alternative?

c.yAxis().setMultiFormat(Chart.RegularSpacingFilter(40, 1), "{value|0}")

If you do not allow me to change the above code, I do not know what to do, because the above code will not achieve what you want.

If you can allow me to change the above code, the method I suggest in the last message is the standard method used for "Point and Figure Chart". (Because you mentioned about PF Chart - which I assume mean "Point and Figure Chart", so I suggest the standard method for  "Point and Figure Chart".)

If you want to use other methods, you may just try to use:

c.yAxis().setAutoScale(0, 0, 0);
c.yAxis().setTickDensity(15);

The above should create a rathar compact axis. It is a general method to create a compact y-axis.

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-15-2009 23:27
If you scroll up to the doc attached, you see a Point and Figure chart, with a crammed Y axis. A stock can be either btw 2.5 and 2.7 or 300 and 500 for the bars selected.

So no matter the stock price range I need to determine readable lables on the Y axis...so thats was my question, determining readable Y axis lables that are compact but also readable no matter the data. So which of the code does this best ?

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-16-2009 01:03
Hi icm63,

For some reasons, I cannot see the attached documents.

Anyway, both method I suggest can give good y-axis labels.

The first method (specific to P & F) ensures the y-axis labels are the same spacing as  the P & F symbols. In the second method, the y-axis labels are just good labels, which may or may not be the same spacing as the P & F symbols.

(You probably know that to draw a P & F chart, you need to specify the price range each symbol represents, just like you need to specify a period to draw a moving average line.)

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-19-2009 11:10
NOTE: I have used your 'Point and Figure' chart (PF) code referenced in the first post of this thread.

I have the PF working great. MY Next task is to get some tooltip and price interaction from client side. Tooltips etc

But as it uses x2 of the 'addScatterLayer' how does one add a javascript tooltip (as per examples : C:\Program Files\ChartDirector\VBNetASP\jsclick.aspx)

I added this below your code and the chart didnt render

        'Client Side actions
        Dim tooltip As String = "title='{xLabel}:{value|0}"

        WebChartViewer1.ImageMap = c.getHTMLImageMap("xystub.aspx", "", tooltip)

My PF chart is in a asp.net 2.0 ascx user control, so I have no idea what this means "xystub.aspx" ?

So where do I start ???

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-20-2009 03:42
Hi icm63,

The tooltip in your case does not work because there is an error. It should be:

"title='{xLabel}:{value|0}'"

In general, please make sure your tooltips are legal HTML attributes.

Note that the PF chart does not have x-axis labels for the symbols, so {xLabel} will be empty in the tooltip.

The method for using Javascript on the PF chart is the same as any other chart. Simply attach a Javascript event handler.

myHandler = "onmouseover='doSomething({x}, {value});' "

WebChartViewer1.ImageMap = c.getHTMLImageMap("xystub.aspx", "", myHandler)

In the above, doSomething is the Javascript function that you want to activate when the mouse is over the symbols.

The "xystub.aspx" is URL of the handler when the user click on the symbols. If you do not want the chart to be clickable, you may use an empty string. If you want to use another handler, just enter the URL of that handler there.

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-22-2009 14:45
HI,

I wish to place on the bottom left hand corner of my chart some text like.

www.mywebsite.com

How do I use 'DrawArea.text' to do this.

Chart type XY chart, 'Point and Figure' (PF), as per above posts in this thread.

Reference your code for the PF :

Dim c As XYChart = New XYChart(PlotWidth, PlotHeight)

When I go c.

DrawArea.text is not a property of this class, where is it, which class ??

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-22-2009 19:59
Hi icm63,

There are several examples that come with ChartDirector demonstrating putting some arbitrary text somewhere in the chart. For example, in the "Icon Pie Chart (2)", there are some company name and logo at the bottom right corner of the chart. The API to use is BaseChart.addText.

For example:

c.addText(0, PlotHeight - 1, "Some Text", "Arial Bold", 8, &H000000, Chart.BottomLeft)

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-24-2009 02:40
Attachments:
HI,

Next challenge with the point and figure I want to place a horizontal triangle marker on the right axis to show where the last close was of the day.

Marker : 'Custom Scatter Symbols' Right axis 4, left axis 1

But I would like to add some 1 extra dummy space so I can place the bar in on the chart of the PF chart.

I have used the exact same arrays as your code, but as I dont know if the last bar will be a down or an up, how do I add a another space on my chart with that curve ball ??

see attached doc of my chart so far ....
PFtodo.zip
PFtodo.zip

13.33 Kb

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-24-2009 03:29
Hi icm63,

If I were you, I probably will just add a margin to the x-axis. The margin can be adjust according to the size of your arrow symbol.

c.xAxis().setMargin(10); //add a 10 pixel margin.

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-24-2009 04:04
Thats sounds good, I will give it a go, and what the code for adding a simple marker ??

  Re: My Point and Figure Chart
Posted by icm63 on Jan-24-2009 12:28
I just want to add a SINGLE marker (ie close on the point and figure bar) on the last bar or Y axis as in the picture posted in the above posting, I dont want to load up an array...

Do I have to load another XY scatterlayer for a single marker ???

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-24-2009 15:39
Hi icm63,

You can use other methods to add a single mark. I am not sure why you do not want to just add another scatter layer with data arrays, as it is only one line or code. It is already quite simple. The following code assumes you want to use a custom symbol (your special "arrow" shape):

'create two arrays, each with 1 element, add use them to add a scatter layer with a given symbol
c.addScatterLayer(New Double() { xCoor }, New Double() { yCoor }).setDataSymbol2
(pathToMySymbolShape)

If you want other methods, which does not need the two arrays above, you may use a mark line, like:

Dim m As Mark = c.yAxis().addMark(yCoor -1, "<*img=" & pathToMyStringShape & "*>")
m.setMarkColor(Chart.Transparent, &H000000, Chart.Transparent)
m.setAlignment(Chart.Right)

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-25-2009 02:32
Thanks,

1)The above code to add a marker, adds the marker to the close ON THE BAR, I was hoping to place the marker within the 10px right hand margin created from an earlier post, so hows does one shit marker 10px to the right from the last bar ???

2) I have followed the javascript clickable chart example to allow me to get price returned from (outside of chart) mouse over action, however the price is only returned from the bars on the chart, rather than where ever the mouse cursor goes on the chart ( ie non PF bar areas as well), no matter where bars are, I was after full chart price x and y returned. Is that possible, if so how ?

So far really like the product, soon I will be an expert and my questions will diminish,Thx !

  Re: My Point and Figure Chart
Posted by icm63 on Jan-25-2009 02:53
I get error "cant convert string to integer" with the addmark code ..

On this part .."<*img=images/ArrowQuadRev0.gif*>")

    Dim b As Mark = c.yAxis().addMark(LClose - 1, "<*img=images/ArrowQuadRev0.gif*>")
        b.setMarkColor(Chart.Transparent, &H0, Chart.Transparent)
        b.setAlignment(Chart.Right)

It seams .. from the help that... linecolor goes there

[VB.NET]  Public Function addMark(value As Double, lineColor As Integer [, text As String [, font As String [, fontSize As Double ]]]) As Mark

Anyways this didnt work either

Dim b As Mark = c.yAxis().addMark(LClose - 1, &H0, "<* img=" & Replace(AppDomain.CurrentDomain.BaseDirectory, "/", "\") & "images/ArrowQuadRev0.gif *>")
b.setMarkColor(Chart.Transparent, &H0, Chart.Transparent)
b.setAlignment(Chart.Right)

  Re: My Point and Figure Chart
Posted by icm63 on Jan-25-2009 03:10
If I wish to use this code...

'create two arrays, each with 1 element, add use them to add a scatter layer with a given symbol
c.addScatterLayer(New Double() { xCoor }, New Double() { yCoor }).setDataSymbol2
(pathToMySymbolShape)


Its a little hard as how do I get the coordinates for the last close on the scatter chart
your PF code ends up with this...

            c.addScatterLayer(fallSymbolsX, fallSymbolsY, Nothing, _
            Chart.Cross2Shape(0.2), symbolSize, RGB(0, 0, 255), RGB(0, 0, 255))
            c.addScatterLayer(riseSymbolsX, riseSymbolsY, Nothing, _
            Chart.CircleSymbol, symbolSize, &HAC9FF, RGB(235, 0, 0))

How does one know what is the format of the lastbar rising or falling ??

And the X and Y symbols have been normalised from the close array loaded from price data, so out put is x and y, not date and close.

So I hope you get the addmark working for a image, thats seams easier ???

  Re: My Point and Figure Chart
Posted by icm63 on Jan-25-2009 03:18
Attachments:
Yippe got it working...

see attached file..

This is in the only issue oustanding...

2) I have followed the javascript clickable chart example to allow me to get price returned from (outside of chart) mouse over action, however the price is only returned from the bars on the chart, rather than where ever the mouse cursor goes on the chart ( ie non PF bar areas as well), no matter where bars are, I was after full chart price x and y returned. Is that possible, if so how ?
IanPF1001.zip
IanPF1001.zip

21.49 Kb

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-25-2009 17:16
Hi icm63,

ChartDirector will inform you the propeties (the data values) of the objects on the chart. If you just want to know where the mouse is on the chart, you do not need anything from ChartDirector. You can use normal Javascript code.

To do this, you need to be familiar with Javascript. In Javascript, you can get the mouse coordinate from your mouse event handler of the <IMG>, so you know where is the mouse on the chart. Your code also know what is the axis scale (the axis position and the axis scale are set by your own). So with the mouse coordinates, you can translate it to the price value on the axis. The whole process does not require any input or output from ChartDirector.

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-26-2009 00:33
I know javascript can read X and Y from an IMG image, no problems.

BUT how do I get your chart axis levels (max and min) into the javascript function onmouseover <IMG> function, as its from codebehind ??

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-26-2009 00:52
Hi icm63,

In the last chart image you attached, the y-axis range is from 229 to 618.

I am not sure why it is from 229 to 618. I assume your code sets it. If this is the case, your already knows the axis levels.

Your code needs to pass this information from the server to the client side. You may use any standard method you like that is from sending server information to the client. For example, you can output the information as HTML. On the client side, you can use Javascript to read the HTML. The HTML can be a hidden <INPUT> field, or can be normal HTML text enclosing in a hidden <DIV> block, etc.. You can also put the information in a member variable, and then use <%=myMaxValue%> to insert the value into the HTML. You also can pass information as cookies, etc.

Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Jan-26-2009 01:18
Thanks...

BUt the IMG of the PF chart also includes the axis info and chart heading does it not, I mean the IMG is not just the simple gridded area is it, so I would have to deduct these areas from the XY conversion to the chart price. Getting too hard..

Is there an easy way, like load up a dummy scatterlayer data, thats is transparent, so cursor sees this data for price cursor over action only ????

  Re: My Point and Figure Chart
Posted by Peter Kwan on Jan-27-2009 03:34
Hi icm63,

To get the value on the axis, you only need two type of information:

(a) The scale on the axis (like 229 to 618 in your last attached chart). The scale is provided by your code, so your code already have these values.

(b) The position of the axis (like the pixel coordinate of the axis end pont). This information is also provided by your code. There is no need for your code to "get" this information. For example, in the original PF Chart sample code, there is a line:

c.setPlotArea(50, 30, 400, 400).setGridColor(&Hcccccc, &Hcccccc)

So the top end of the y-axis must be y = 30 relative to the top of the image, and the length must be 400. The above values are entered from your code to ChartDirector.


With the above values, given a y-mouse coordinate relative to the image, the y-value on the axis must be:

yValue = yMaxScale - (yMaxScale - yMinScale) * (yMouseCoor - 30) / 400;


Hope this can help.

Regards
Peter Kwan

  Re: My Point and Figure Chart
Posted by icm63 on Feb-16-2009 05:18
Attachments:
Issue with my Point and Figure ( I thought I fixed this)..but

The symbols breach upper and lower boundaries of the chart, I use your code from thi site..

I thought I fixed this by getting max and min of the two types of symbolsdata with this code...
        Dim maxValueRise As Double = (Math.Ceiling(Util.MaxMinDBLArray(riseSymbolsY, 1) / boxSize) * boxSize)
        Dim maxValueFall As Double = (Math.Ceiling(Util.MaxMinDBLArray(fallSymbolsY, 1) / boxSize) * boxSize)
        Dim minValueRise As Double = (Math.Floor(Util.MaxMinDBLArray(riseSymbolsY, 0) / boxSize) * boxSize)
        Dim minValueFall As Double = (Math.Floor(Util.MaxMinDBLArray(fallSymbolsY, 0) / boxSize) * boxSize)
        Dim maxValue As Double = Math.Max(maxValueRise, maxValueFall)
        Dim minValue As Double = Math.Max(minValueRise, minValueFall)
PFissue001.jpg

  Re: My Point and Figure Chart
Posted by icm63 on Feb-16-2009 08:37
Found the bug...

Dim minValue As Double = Math.Max(minValueRise, minValueFall)

should be..

Dim minValue As Double = Math.Min(minValueRise, minValueFall)

Silly me !!