介绍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 use method setChartType(type) to change the style of the chart, the parameter type is one of the three values(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-axis value, 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.

1395298.html?type=1

--------------------------
新闻: Google Earth惊现失落之城亚特兰蒂斯
导航: 博客园首页   知识库   新闻   招聘   社区   小组   博问   网摘   找找看

转载于:https://my.oschina.net/javastudy/blog/36

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值