Java 上有大名鼎鼎的JFreeChart (http://www.jfree.org/jfreechart/) 用作生成不同的統計圖表, 如PieChart, Histogram 等.
而.Net 平台上亦同樣有JFreeChart.Net for Visual Basic/ Visual Basic .Net / C # /
J # (http://www.ujihara.jp/jbyjsharp/jfreechart/), 可是, 其功能是較原有Java 版少的, 但是, .Net 免費的東西也算可以吧.
要在VB/VB.Net 上運行JFreeChart.Net, 需要以下的DLL:
Apache.Xml.Commons.dll
JCommon.dll
JFreeChart.dll
JSharpLib.dll
vjslib.dll
首4個的DLL 可以在JFreeChart.Net的網頁上下載, 最後一個可以在VS 2008 的Add Reference 內找到.
Imports org.jfree.data.general
Imports org.jfree.chart
Imports org.jfree.chart.labels
Imports org.jfree.chart.title
Imports System.IO
Dim data As DefaultPieDataset = New DefaultPieDataset
For i As Integer = 0 To des.Count - 1
data.setValue(des.Item(i), bit.Item(i))
Next
Dim jChart As JFreeChart = ChartFactory.createPieChart3D("Bits' usage breakdown by field name", data, True, False, False)
Dim pieplot3d As plot.PiePlot3D = CType(jChart.getPlot(), plot.PiePlot3D)
Dim bgColor As Color = Color.FromArgb(239, 239, 239)
Dim percentFormat As java.text.NumberFormat = New java.text.DecimalFormat("#0%")
Dim noFormat As java.text.NumberFormat = New java.text.DecimalFormat("#0")
Dim copyright As TextTitle = New TextTitle("Bits' usage breakdown by field name", New Font("SansSerif", 16, FontStyle.Bold))
jChart.getRenderingHints().put(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)
pieplot3d.setStartAngle(150D)
pieplot3d.setDirection(org.jfree.util.Rotation.CLOCKWISE)
pieplot3d.setLabelFont(New Font("Microsoft Sans Serif", 10, FontStyle.Regular))
pieplot3d.setLabelGap(0.02)
pieplot3d.setCircular(True)
pieplot3d.setLegendLabelGenerator(New StandardPieSectionLabelGenerator("{0}"))
pieplot3d.setForegroundAlpha(0.5F)
pieplot3d.setNoDataMessage("No data to display")
pieplot3d.setLabelGenerator(New StandardPieSectionLabelGenerator("{0}: {1} ({2})", noFormat, percentFormat))
jChart.setBackgroundPaint(bgColor)
ChartUtilities.saveChartAsPNG(New FileInfo(Application.StartupPath + "\temp\pieChart.png"), jChart, 559, 543)
No comments:
Post a Comment