如果是用Interface Builder的话,代码中在控件声明前加上IBOutlet,并在对应的动作函数的返回值类型写成IBAction,如: IBOutlet NSButton btn; -(IBAction)actionButtonClicked:(id)sender; 再打开对应的xib文件去连线就行了。
HTML部分:
<asp:Chart ID="ChartBar" runat="server" Width="800px" BackColor="#FFFFCC" Palette="BrightPastel" BorderWidth = "2" BorderColor = "#cc9900" >
<Legends>
<asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 825pt, style=Bold">
</asp:Legend>
</Legends>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
<asp:Chart ID="ChartPie" runat="server" Width="400px" BackColor="#FFFFCC" Palette="BrightPastel" BorderWidth = "0" BorderColor = "#cc9900" >
<Legends>
<asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 825pt, style=Bold">
</asp:Legend>
</Legends>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
C#部分:
//获取每月销售情况
int[] arraySell=new int[]{10};
//获取月份
string[] arrayMonths = new string[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
//获取部门
string[] arrayDeparts = new string[] { "部门1", "部门2", "部门3" };
Series seriess = new Series("销售情况");
seriessBorderWidth = 3;
seriessShadowOffset = 2;
Series seriesPies = new Series("销售情况");
seriesPiesChartType = SeriesChartTypePie;
seriesPiesBorderWidth = 3;
seriesPiesShadowOffset = 2;
thisChartBarSeriesAdd(seriess);
thisChartPieSeriesAdd(seriesPies);
Title tBar = new Title("销售情况柱状图");
thisChartBarTitlesAdd(tBar);
Title tPie = new Title("销售情况饼状图");
thisChartPieTitlesAdd(tPie);
thisChartBarChartAreas["ChartArea1"]AxisXInterval = 1;//x轴数据显示间隔
thisChartBarChartAreas["ChartArea1"]AxisYInterval = 50;
//画柱状图
foreach (string d in arrayDeparts)
{
Series tempseries = new Series(stringFormat("{0}", d));
thisChartBarSeriesAdd(tempseries);
foreach (string m in arrayMonths)
{
foreach (int n in arraySell)
{
tempseriesPointsAddXY(m, n);
}
}
}
//画饼图
foreach (string d in arrayDeparts)
{
foreach(int n in arraySell)
{
seriesPiesPointsAddXY(d, n);
}
}
thisChartBarChartAreas["ChartArea1"]AxisXIsMarginVisible = false;
thisChartBarChartAreas["ChartArea1"]Area3DStyleEnable3D = false;
//背景色设置
thisChartBarChartAreas["ChartArea1"]ShadowColor = ColorTransparent;
thisChartBarChartAreas["ChartArea1"]BackColor = ColorAzure;
thisChartBarChartAreas["ChartArea1"]BackGradientStyle = GradientStyleTopBottom;
thisChartBarChartAreas["ChartArea1"]BackSecondaryColor = ColorWhite;
//X,Y坐标线颜色和大小
thisChartBarChartAreas["ChartArea1"]AxisXLineColor = ColorBlue;
thisChartBarChartAreas["ChartArea1"]AxisYLineColor = ColorBlue;
thisChartBarChartAreas["ChartArea1"]AxisXLineWidth = 2;
thisChartBarChartAreas["ChartArea1"]AxisYLineWidth = 2;
thisChartBarChartAreas["ChartArea1"]AxisYTitle = "销量";
//中间X,Y线条的颜色设置
thisChartBarChartAreas["ChartArea1"]AxisXMajorGridLineColor = ColorBlue;
thisChartBarChartAreas["ChartArea1"]AxisYMajorGridLineColor = ColorBlue;
//XY轴数据显示间隔
thisChartBarChartAreas["ChartArea1"]AxisXInterval = 1; //X轴数据显示间隔
thisChartBarChartAreas["ChartArea1"]AxisYInterval = 50;
//X轴线条显示间隔
thisChartBarChartAreas["ChartArea1"]AxisXMajorGridInterval = 1;
效果如下
以上就是关于如何才能把controller的HTML代码以控件形式呈现在view全部的内容,包括:如何才能把controller的HTML代码以控件形式呈现在view、.net C# Chart控件,如何动态画rangeColumn图和Bar图、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)