动态生成图表

关于Foxtable是如何动态生成图表的,请参考:ChartBuilder

我们可以利用Foxtable的ChartBuilder动态生成图表,然后保存为图片文件,发送给客户端。

但是这样会产生大量的临时文件,为此WeUI提供了一个ImageToBase64方法,可以将ChartBuilder生成的图片直接转换为base64字符串发送给客户端,无需先保存为文件。

一个例子

HttpRequest事件代码:

Select Case e.Path
    Case "test.htm"
        Dim wb As New WeUI
        Dim Chart As New ChartBuilder 
        Dim Series As WinForm.ChartSeries
        Chart.PrintWidth = 140
        Chart.PrintHeight = 100
        Chart.VisualEffect = True
        For n As Integer = 0 To 1
            Series = Chart.SeriesList.Add()
            Series.Length = 10
            For i As Integer = 0 To 9
                Series.X(i) = i
                Series.Y(i) = i + n * 2 + Rand.Next(5)
            Next
        Next
        wb.AddPageTitle("","ph1","FoxUI")
        wb.InsertHTML("<img width='100%' src='" & wb.ImageToBase64(Chart.Image) &  "'/>")
       
e.WriteString(wb.Build)
End
Select

这是显示效果:

 


本页地址:http://www.foxtable.com/mobilehelp/topics/0137.htm