原創(chuàng)|其它|編輯:郝浩|2012-10-18 15:44:15.000|閱讀 1013 次
概述: Visifire for Silverlight/WPF制作透明圖表的例子和大家分享一下。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
這里將Visifire for Silverlight/WPF實(shí)例教程分享給大家,希望對(duì)大家有幫助!
網(wǎng)上Silverlight實(shí)例教程有很多,但在這些Silverlight實(shí)例教程中有也有很多沒(méi)有價(jià)值,我覺(jué)得這一篇有些用處所以分享給大家!
使用Visifire創(chuàng)建的圖表,默認(rèn)的是帶邊框、背景色(使用Xaml代碼創(chuàng)建的圖表默認(rèn)背景是透明的,使用C#代碼創(chuàng)建的圖表默認(rèn)背景色是白色的)、坐標(biāo)和圖表格(ChartGrid)的,有時(shí)為了實(shí)現(xiàn)特殊的需求,需要將圖表的背景做成透明的。在Xaml代碼中,可以通過(guò)設(shè)置Chart的 “BorderThickness”屬性為“0”和Axis的“Enabled”屬性為“False”輕松實(shí)現(xiàn)透明效果。
下面我們通過(guò)C#代碼來(lái)實(shí)現(xiàn) Visifire圖表的透明效果。
/*****第一段代碼*****/ Chart chart = new Chart(); chart.Width = 400; chart.Height = 300; DataSeries dataSeries = new DataSeries(); dataSeries.RenderAs = RenderAs.Column; dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "Wall-Mart", YValue = 351139 }); dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "Exxon Mobil", YValue = 345254 }); dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "Shell", YValue = 318845 }); dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "BP", YValue = 274316 }); dataSeries.DataPoints.Add(new DataPoint { AxisXLabel = "General Motors", YValue = 207349 }); chart.Series.Add(dataSeries); chart.SetValue(Grid.ColumnProperty, 1); LayoutRoot.Children.Add(chart);
去掉圖表的邊框和背景色,在上面的代碼第3行后面加入下面的代碼:
/*****第二段代碼*****/ //將邊框設(shè)為0 c hart.BorderThickness = new Thickness(0);// 將背景色設(shè)為透明6 chart.Background = new SolidColorBrush(Colors.Transparent);
去掉坐標(biāo)軸,接著上第二段代碼再加入下面的代碼:
/*****第三段代碼*****/ //去掉X軸 Axis xaxis = new Axis(); xaxis.Enabled = false; chart.AxesX.Add(xaxis); //去掉Y軸 Axis yaxis = new Axis(); yaxis.Enabled = false; chart.AxesY.Add(yaxis);
最后再去掉圖表格,在第三段代碼的第5行和第10行下面分別插入下面的代碼:
//插入第三段代碼第5行后面 ChartGrid xgrid = new ChartGrid(); xgrid.Enabled = false; xaxis.Grids.Add(xgrid); //插入第三段代碼第10行后面 ChartGrid ygrid = new ChartGrid(); ygrid.Enabled = false; yaxis.Grids.Add(ygrid);
至此我們就將Visifire圖表設(shè)置成透明的了。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:云世界