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

Message ListMessage List     Post MessagePost Message

  How to highlight a sub chart?
Posted by JerryLia on May-24-2011 15:52
Dear Peter,

Could you give me any clue to highlight a sub chart which is added in a multichart?

any help will be appreciated!

  Re: How to highlight a sub chart?
Posted by Peter Kwan on May-25-2011 01:16
Hi JerryLia,

You can highlight using any method you like. For example, you may give it a red border, use a different background color for the highlight chart, etc.. (See BaseChart.setBackground).

Hope this can help.

Regards
Peter Kwan

  Re: How to highlight a sub chart?
Posted by How to highlight a sub chart? on May-25-2011 09:07
Hi,Peter,

Thanks for your replying!
Maybe i did not describe my problem enough clearly.For example,I have added three XYCharts to a MultiChart.When I click any of them in its plotarea with mouse,then i can highlight the selected one!My question are:

1. How to i get the clicked subchart? to identify the mouse position to see whether or not it is located in subchart's ploatarea?

2. when i set backgourd color to clicked subchart,do i have to redraw all the multichart?
any other better idea?


Sorry for my bad English!

By the way,do you understand what I posted if I write my questions in Chinese?

Jerry

  Re: How to highlight a sub chart?
Posted by Peter Kwan on May-25-2011 18:44
Hi Jerry,

1. How to i get the clicked subchart? to identify the mouse position to see whether or not it is located in subchart's ploatarea?

Most GUI framework has a "mouse down" or "mouse click" event, and you can get the mouse (x, y) position in the event handler. The exact code depends on your GUI framework (eg. the Java SWING. .NET Windows Forms, MFC, Web/Javascript are all different).

The positions of the sub-charts are provided by your code to ChartDirector (in the addChart method call), so your code already knows the positions of all sub-charts. Therefore, your code should be able to determine if any sub-chart is clicked.

2. when i set backgourd color to clicked subchart, do i have to redraw all the multichart?
any other better idea?

It depends on your GUI framework. Some GUI framework supports true transparent background. In this case, you can set the chart background to transparent, and then add a rectangular control under the sub-chart to act as its background.

Another method is to not highlighting the background, but use a red rectangle to enclose the selected sub-chart. Most GUI framework allows you to add rectangles or lines. For example, you can add an empty "label control" (most GUI frameworks support similar controls or objects), and set its background color to red, and set its size to 3 x 400. This will create a vertical line 3 pixels thick and 400 pixels height. If you have 4 lines, you can create a rectangle.

With the above methods, you do not need to touch the chart at all to highlight it. You just add other rectangular controls above or under the chart.

For your information, in the "Zoomable and Scrollable" sample code, you can "drag a rectangle" on the chart for zooming. The rectangle is created using the methods mentioned above, and the chart does not need to be redrawn.

Hope this can help.

Regards
Peter Kwan

  Re: How to highlight a sub chart?
Posted by JerryLia on May-25-2011 20:12
Peter,
Thanks for you suggestions!
I am signing a contract with your agency named huidong in
chongqing(http://www.evget.com/)