ChartDirector

div.post div.entry { font-family: Georgia,"Times New Roman",Times,sans-serif } div.post div.entry h1, div.post div.entry h2, div.post div.entry h3 { margin-top: 24px; margin-bottom: 12px; } div.post div.entry h1 { padding: 5px; color:white; background-color: gray; } div.post h2 { font-size: 22px; line-height: 100%; } div.post div.entry pre.code { border-style: dashed; border-left: solid 5px #6ce26c } div#license_information { background-color: #f8f8ee; border: solid 1px #e8e7d0; padding: 5px 10px 0px 10px; min-height: 10px; margin-top: -15px; margin-bottom: 30px; color: #666666 }

1 Page UI:

<%@ Register TagPrefix="chart" Namespace="ChartDirector" Assembly="netchartdir" %>

<div>
   <chart:WebChartViewer ID="WebChartViewer1" runat="server" height="300px" width="600px" />
</div>

2 Code-Behind steps:

// The data for the bar chart

double[] data = {85, 156, 179.5, 211, 123};

// The labels for the bar chart

string[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};

2 .1 new IChart

// Create a XYChart object of size 250 x 250 pixels

XYChart c = new XYChart(250, 250);

// Set the plotarea at (30, 20) and of size 200 x 200 pixels

c.setPlotArea(30, 20, 200, 200);

2.2 add image Layer

// Add a bar chart layer using the given data

c.addBarLayer(data);

// Set the labels on the x axis.

c.xAxis().setLabels(labels);

2.3 output chart

// output the chart

WebChartViewer1.Image = c.makeWebImage(Chart.PNG);

//include tool tip for the chart

WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='{xLabel}: US${value}K'");

3 Classes

posted @ 2010-08-27 11:49  望风.  阅读(518)  评论(0)    收藏  举报