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

Message ListMessage List     Post MessagePost Message

  Add label control to finance chart
Posted by Tunde on Jun-13-2013 21:58
Hi Peter,

I have chart the interactive finance chart. I want users to be able to drag and drop a label on any part of the chart. they can change the text, color or delete the label. However, if the chart is saved/printed, the labels will be saved/printed on the chart.

Kindly help with a clure to go about this please

Thanks
Tunde

  Re: Add label control to finance chart
Posted by Peter Kwan on Jun-14-2013 01:24
Hi Tunde,

The usual method to allow a user to edit text is to simply put a textbox onto the chart.

If you are using Windows OS, you may have some icons on your desktop. Please try to click on the text label of the icon to try to change the text label (or right click on the icon and select rename), and see what happens. When you try to modify the text, a text box immediately appear so that you can edit text. It is easy to see that the text box is not the original text on the icon, as the style is slight different and the text is in a slight different position.

So for your case, when the mouse is in "text edit" mode, when it clicks on some text, you can pop up a text box to allow the user to edit the text. After that, you can draw the text back onto the chart. You can allow drag and drop by dragging the text box around (or by dragging a small image containing the text). You may allow the user to change color and font style like in Windows Paint or Photoshop (there is a button bar that the user can use to change the color and style).

You may consider your system to be a like a tiny "Photoshop" for interactive editing, but just for editing text, and you apply it to add text to the chart.

Regards
Peter Kwan

  Re: Add label control to finance chart
Posted by Tunde on Jun-24-2013 22:48
Attachments:
Hi Peter,

Thanks for your code it now works. Now i want to be able to do the following:
1. Add line to the candlestick chart. User draw the line by clicking a location and draw the
line by dragging the mouse (i know this will be under the mousedown event). the problem
now is how do i get the x,y values when the use click down the mouse.
2. I want the user to be able to save/print the chart with this drawing.

3. If i want to change the color of any line chart, how will the user select the line he/she
want to change its color?

4. I have attached a file demonstrating the area where i want the label to appear. please
help with this.

Thanks
Tunde
financechart.docx
financechart.docx

202.54 Kb

  Re: Add label control to finance chart
Posted by Peter Kwan on Jun-25-2013 04:58
Hi Tunde,

1. The Microsoft .NET mouse click event handler will provide you with the mouse coordinates. In the crosshair sample code I provided to you in previous post, it contains code to convert mouse coordinates to data values. May be you can it as a reference.

2. You may use BaseChart.makeImage to create the chart as an .NET System.Drawing.Image object. You can then print it normally just like any other image. (Please refer to the Microsoft .NET documentation on how to print in .NET. In particular, you may refer to the documentation on System.Drawing.Printing.)

You may also save System.Drawing.Image as a file just like a normal image. The BaseChart.makeChart also allows you to save the chart as an image file.

3. You would need to decide how the user can select the line (as the user interface is designed by you). For example, the user can select the line by click on the line, but in (1) you also use clicking to indicate that the user wants to draw a new line, so you need to decide how to handle the user interface. ChartDirector can only provide mouse click events so you know where the user has clicked. You would need to determine whether the click means selecting a line or drawing a line or other things.


4. If you know where you would like to add a label, you may use BaseChart.addText to add the label to the chart.

Hope this can help.

Regards
Peter Kwan