|
ChartDirector Evaluation Questions |
Posted by knc on Aug-25-2006 10:51 |
|
Hi
I'm evaluating ChartDirector for use in Java applications. I have downloaded the free version and am prototyping with it, but I was wondering if you could answer some of my questions about it.
1. Can you provide the code that describes how to resize the charts if, for example, you change the frame size? I am aware that ChartDirector charts don't automatically resize and am trying to figure out how to work around this issue.
2. I will be using ChartDirector to create interactive charts, where users will be clicking on points and moving the points along the x or y axis. Does ChartDirector support this interactive behavior of dragging and dropping points on the graph?
3. For a MultiChart, is it possible to click on a point in the chart and view the x/y value information for a point on a line? I see the "hotspot" popups that appear for a line chart, but in the MultiChart FinancialChart example I didn't see this functionality. Is it possible to do this?
4. I will be using ChartDirector to plot a very large dataset, as many as 400,000 points and I will implement a horizontal scrollbar to view small subsets of the data at one time. Can you give some information about how ChartDirector will perform with a dataset this large, and what the scrolling performance will be?
5. Does ChartDirector support crosshairs?
Thanks in advance for your help!
knc |
Re: ChartDirector Evaluation Questions |
Posted by Peter Kwan on Aug-26-2006 03:53 |
|
Hi knc,
>
> 1. Can you provide the code that describes how to resize the charts if, for example, you change the frame size? I am aware that ChartDirector charts don't automatically resize and am trying to figure out how to work around this issue.
>
Basically, you may just handle the componentResized event and redraw the chart at the new size. ChartDirector allows you to draw the chart at any size you want, so you may always redraw the chart as a ratio to the frame size.
I have attached a very simple example I just wrote for your reference. (Based on the Simple Bar Chart sample code.)
>
> 2. I will be using ChartDirector to create interactive charts, where users will be clicking on points and moving the points along the x or y axis. Does ChartDirector support this interactive behavior of dragging and dropping points on the graph?
>
ChartDirector will provide you will full suite of mouse events for the data points (hot spots). You may have event handlers for mouse pressed, mouse released, mouse drag, mouse move, etc.. However, ChartDirector does not perform any particular actions in these handlers. It is expected the developers will put code in these handles to achieve what they need.
You may implement drag and drop of data points by putting code in the above handlers.
>
> 3. For a MultiChart, is it possible to click on a point in the chart and view the x/y value information for a point on a line? I see the "hotspot" popups that appear for a line chart, but in the MultiChart FinancialChart example I didn't see this functionality. Is it possible to do this?
>
In the Windows version (as opposed to the web version) of the "Interactive Financial Chart" sample code, there are also pop up boxes to show the data values (the tooltips box). However, in that sample code, we have not added the click handlers.
All ChartDirector charts are in fact clickable. You may add click handling to the chart by adding an event handler for the "hotSpotClicked" event for the data points.
>
> 4. I will be using ChartDirector to plot a very large dataset, as many as 400,000 points and I will implement a horizontal scrollbar to view small subsets of the data at one time. Can you give some information about how ChartDirector will perform with a dataset this large, and what the scrolling performance will be?
>
If you are evaluating ChartDirector for Java Ver 4.1 (released on Jul 29, 06), there is in fact some zoomable/scrollable chart sample code in it.
Basically, when the scroll bar moves, in the adjustmentValueChanged handler of your scroll bar, you may redraw the chart using the data that is in the scroll window. So at any time, ChartDirector only needs to draw the data that is visible, and it is not necessary to draw data that is outside the scroll window. As a result, no matter how large your data set is, it does not matter to ChartDirector.
In case you have not already tried, I suggest you may try the ZoomScrollDemo.java sample code that comes with ChartDirector. I have attached a screen shot for your reference in case you have not seen it.
>
> 5. Does ChartDirector support crosshairs?
>
Again, ChartDirector only supplies you with the mouse events. You may put two lines controls in front of the chart, and make it follow the mouse cursor in the mouse move event handler. This will become your cross-hair.
Hope this can help.
Regards
Peter Kwan
simplebar.java |
---|
import java.awt.event.*;
import javax.swing.*;
import ChartDirector.*;
public class simplebar
{
//Main code for creating charts
public void createChart(ChartViewer viewer, int width, int height)
{
// The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};
// The labels for the bar chart
String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};
// Create a XYChart object
XYChart c = new XYChart(width, height);
// Set the plotarea
c.setPlotArea(40, 35, width - 70, height - 75);
// Add a bar chart layer using the given data
c.addBarLayer(data);
// Set the labels on the x axis.
c.xAxis().setLabels(labels);
// output the chart
viewer.setImage(c.makeImage());
//include tool tip for the chart
viewer.setImageMap(c.getHTMLImageMap("clickable", "",
"title='{xLabel}: US${value}K'"));
}
//Allow this module to run as standalone program for easy testing
public static void main(String[] args)
{
//Instantiate an instance of this demo module
final simplebar demo = new simplebar();
//Create and set up the main window
JFrame frame = new JFrame(demo.toString());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);} });
// Create the chart and put them in the content pane
final ChartViewer viewer = new ChartViewer();
demo.createChart(viewer, 250, 250);
frame.getContentPane().add(viewer);
frame.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
demo.createChart(viewer, ((JFrame)evt.getSource()).getWidth(),
((JFrame)evt.getSource()).getHeight());
}
});
// Display the window
frame.pack();
frame.setVisible(true);
}
}
|
|
| |
Re: ChartDirector Evaluation Questions |
Posted by knc on Aug-29-2006 01:10 |
|
Hi
Thanks for the reply. I have one more question. Is it possible to plot bar charts from the top down? I would like to start the scale on the y-axis from the top left of the chart at 0, and increase in value as the Y-axis goes down. The bars should be drawn from the top. I was looking at the API to see if there is a method that could support me for this, but I don't see anything.
Best regards,
knc |
Re: ChartDirector Evaluation Questions |
Posted by Peter Kwan on Aug-29-2006 01:47 |
|
Hi knc,
You may use Axis.setReverse to reverse the axis. For example:
c.yAxis().setReverse();
If you also want to put the x-axis on the top (instead of the bottom) of the plot area, you may use:
c.setXAxisOnTop();
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector Evaluation Questions |
Posted by Alden on Feb-17-2011 20:39 |
|
Hi Peter,
You said earlier in this post:
"Again, ChartDirector only supplies you with the mouse events. You may put two lines
controls in front of the chart, and make it follow the mouse cursor in the mouse move
event handler. This will become your cross-hair."
I can get all the mouse handlers working properly, but have no clue how to code the line
controls. Do you have an example?
Regards. |
Re: ChartDirector Evaluation Questions |
Posted by Alden on Feb-17-2011 21:14 |
|
Nevermind, I found an example! |
|