|
To display client-side charts in Swing application
you need to create MxComponent, set it's style and then model, and add it to a Swing container:
MxComponent chart = new MxComponent();
MxFrameChartStyle style = new MxFrameChartStyle();
style.legend.placement = MxStandardConstants.Placement.RIGHT;
chart.setStyle(style);
chart.setModel(new MxSampleChartModel(2,5));
add(chart);
WebCharts3D Designer can automatically generate Java code required to create a chart displayed in it.
Switch to XML Style pane and from the right mouse button menu select View>>Java and then
copy and paste the code into your program.
To completely change the chart's style and/or model use setStyle and setModel functions. For example,
to change the chart's style to pie chart you can use the following code:
MxPieChartStyle style = new MxPieChartStyle();
style.legend.placement = MxStandardConstants.Placement.RIGHT;
chart.setStyle(style);
To provide your users with persistent customizable charts you can save the charts styles in xml
format and reload them when the application restarts by using toXML() and fromXML() functions of
MxWidgetStyle class.
You can see this example running by selecting Samples topic of Swing section in
WebCharts3D Designer's Help and clicking the appropriate sample link.
|