我試圖創建一個aspx頁面,從一個chartDirector
內容響應型圖像/ PNG
回到這裏Image/Png
是我在我的VB至今:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim mychart As XYChart = New XYChart(700, 170)
Dim values As Double() = {25, 18, 15, 12, 8, 30, 35}
Dim labels As String() = {"Labor", "Licenses", "Taxes", "Legal", "Insurance",
"Facilities", "Production"}
mychart.setPlotArea(30, 20, 200, 200)
mychart.addBarLayer(values)
Response.ContentType = "image/png"
Response.BinaryWrite(mychart.makeChart2(Chart.PNG))
Response.Close()
End Sub
當我運行這個頁面我得到這個輸出:
我從下面的ASP代碼
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")
'The data for the bar chart
data = Array(85, 156, 179.5, 211, 123)
'The labels for the bar chart
labels = Array("Mon", "Tue", "Wed", "Thu", "Fri")
'First, create a XYChart of size 250 pixels x 250 pixels
Set c = cd.XYChart(250, 250)
'Set the plotarea rectangle to start at (30, 20) and of
322
'200 pixels in width and 200 in height
Call c.setPlotArea(30, 20, 200, 200)
'Add a bar chart layer using the supplied data
Call c.addBarLayer(data)
'Set the x-axis labels using the supplied labels
Call c.xAxis().setLabels(labels)
'output the chart
Response.contenttype = "image/png"
Response.binarywrite c.makeChart2(cd.PNG)
Response.end
%>
這個想法,並使用img
src
鏈接到這個頁面來呈現圖像
問題是我該怎麼做aspx
相同的實現?
注意事項我對.NET剛開始並不瞭解太多。