首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

引见JComponentPack产品中的JBasicChart图表控件

2012-11-06 
介绍JComponentPack产品中的JBasicChart图表控件Use JBasicChart in JComponentPack JBasicChart provides

介绍JComponentPack产品中的JBasicChart图表控件

Use JBasicChart in JComponentPack

 

JBasicChart provides a basic chart component.
It could draw 3 styles graph, for example: PIE, LINE, BAR.

The following code demonstrates how to use JBasicChart.
JBasicChart basicChart = new JBasicChart();
basicChart.setModel(createBasicChartModel());
basicChart.setChartType(ChartType.BAR);

private BasicChartModel createBasicChartModel_() {
        double[] yaxis = {1.000, 3.000, 2, 4, 0, 3.000, 0.000, 0.000, -5.000, 4.000, 3.000};
        int[] xaxis = {200701, 200612, 200611, 200610, 200609, 200608, 200607, 200606,200605, 200604, 200603};
        DefaultBasicChartModel model = new DefaultBasicChartModel();
        model.addSeries("a", yaxis);
        for (int i = 0; i < xaxis.length; i++) {
            model.setCategoryName("" + xaxis[i], i);
        }
        return model;
}

It is easy to use JBasicChart, you could use method setModel(model)to change the data which displayed on the chart, and also you could usemethod setChartType(type) to change the style of the chart, theparameter type is one of the threevalues(ChartType.BAR、ChartType.LINE、ChartType.PIE).

To change the data of the chart, you should learn more about DefaultBasicChartModel.
addSeries(String name,double[] values),this method add a series values which will be y-axisvalue, each value have a category name, use the method setCategoryName(String name, int categoryIndex) to set it.
addSeries(String name, double[] values, int index),when you saw this method, you should know this model could add multi-series values to it.

It also have some other methods which are easy to use, for example:
getCategoryCount()
getCategoryName(int categoryIndex)
getSeriesCount()
getSeriesName(int seriesIndex)
removeSeries(int index)
etc.

For more information, please see DefaultBasicChartModel and JBasicChart.

奇新Java控件——Java控件提供商和Java RIA, Web, J2ME解决方案开发商

JComponentPack是基于Swing框架的Java GUI控件集合,它包括JDataGrid电子表格版本, JDataGrid数据库版本,JComponentSet--Java swing控件集。

 

 

热点排行