原創|使用教程|編輯:郝浩|2013-05-15 14:47:05.000|閱讀 426 次
概述:UXChart雖然是WebUI Studio的圖表控件,下面慧都就以一個最終用戶經常提到的需求——下鉆功能為例,來講講UXChart強大的實用性。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
UXChart雖然是WebUI Studio今年才推出的圖表控件,但以功能簡約卻不簡單,實用性非常強而受到關注。下面慧都就以一個最終用戶經常提到的需求——下鉆功能為例,來講講UXChart強大的實用性。
向下鉆取這個功能如今已經不單單在報表中流行了,一個好的圖表工具一定也要具備此功能,從每年鉆取到每月或從類別鉆取到單個項目等等等等。UXChart能夠幫助開發者快速在單個數據源中,創建無限下鉆層級的圖表。
用一個簡單的下鉆圖表的例子來展示這一功能,如果需要用一個圖表來說明一個主從報表,那下鉆圖表就是最好的選擇。
	
創建下鉆圖表的步驟也非常簡單,首先使用UXChart中的Child屬性,來指定圖表和需要展示詳情的原始圖表。具體來說,所有圖表集合都需要被定義成視圖中的第一位置。在第一次加載的時候,只能展示一個圖表,其他的圖表的可見性都應該被設置為折疊。詳見以下代碼:
<dataVisualisation:UXChart x:Name="Chart1" Visibility="Visible" Child="{Binding ElementName=Chart2}"
                        DrillDownCommand="{Binding DrillDownCommand}">
</dataVisualisation:UXChart>
<dataVisualisation:UXChart x:Name="Chart2" Visibility="Collapsed"  >
</dataVisualisation:UXChart>
Next, we need to hook our custom command to control the drilldown action, we called it DrillDownCommand.
  public DelegateCommand DrillDownCommand { get; set; }
And then we assign DrillDownCommand to some execute the method in our ViewModel.
 this.DrillDownCommand = new DelegateCommand(ExecuteDrillDown); 
In the execute method, we can initialize the data from the data source and retrieve detail information about the chart itself.
    
private void ExecuteDrillDown(object parameter)
{
   UXChartDrillDownCommandArgs args = parameter as UXChartDrillDownCommandArgs;
   if (args.Level == 1)
   {
     Data parent = args.DataPointContext as Data;
     if (parent != null)
     {
       InitializeDataByArea(parent.Area);
     }
   }
}
總之,使用UXChart讓創建帶有向下鉆取功能的圖表非常簡單,而且還是無限層級的,歡迎下載試用。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都控件網