2010-07-22 43 views
1

我一直試圖在axmapcontrol上繪製地圖,並使用相同的ITable在IDataGraphwindow2中創建散點圖。不幸的是,圖表顯示的數據是正確的,但圖上沒有點擊事件正在工作。左鍵單擊顯示內存錯誤,右鍵單擊顯示禁用的菜單。對於左鍵點擊,我認爲DataGraphTUI.dll是負責任的。當我們加載IDataGraphWindow2時,我們不會初始化它,因爲它可能會給出錯誤。如何以編程方式使用arcgis的數據圖窗口

請找到下面的代碼。

IDataGraphWindow2 pDGWin; 
IDataGraphT dataGraphT = new DataGraphTClass(); 
IWorkspace shapefileWorkspace = null; 
IWorkspaceFactory shapefileWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); 
shapefileWorkspace = shapefileWorkspaceFactory.OpenFromFile("C:\\abc.shp "), 0); 
featureWorkspace = (IFeatureWorkspace)shapefileWorkspace; 

featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension("c:\\abc.shp")); 

ITable gobjJoinedTable = (ITable)featureLayer.FeatureClass; 

LoadaxMap(); /// a method to load up the axmapcontrol 

dataGraphT.UseSelectedSet = true; 
dataGraphT.HighlightSelection = true; 
dataGraphT.GeneralProperties.Title = "Scatter Graph"; 
dataGraphT.LegendProperties.Visible = false; 
dataGraphT.get_AxisProperties(0).Title = "Y Axis"; 
dataGraphT.get_AxisProperties(0).Logarithmic = false; 
dataGraphT.get_AxisProperties(2).Title = "X Axis"; 
dataGraphT.get_AxisProperties(2).Logarithmic = false; 

ISeriesProperties seriesProps = dataGraphT.AddSeries("scatter_plot"); 
seriesProps.SourceData = axMap.get_Layer(0) as ITable; // axMap is the map control. Itable direct binding also works here 

seriesProps.SetField(0, "abc.shp-fieldname"); // you may add any fieldname 
seriesProps.SetField(1, "abc.shp-fieldname"); 

dataGraphT.Update(null); 
dataGraphT.UseSelectedSet = true; 
dataGraphT.HighlightSelection = false; 
dataGraphT.Update(null); 
pDGWin = new DataGraphWindowClass(); 
pDGWin.DataGraphBase = dataGraphT; 
pDGWin.PutPosition(546, 155, 1040, 540); 
pDGWin.Show(true); 

的內存錯誤是 訪問衝突在地址0F4E358B模塊 'DatagraphTUI.dll'。閱讀addess 00000000

+0

嘗試gis.stackexchange.com – Nate 2010-08-02 20:20:51

+0

我需要一個功能,可以在圖表中繪製數據。如果用戶從鼠標向下選擇圖中的某些數據,則可以看到axmapcontrol中繪製的相同數據。通常情況下,ArcGIS 9數據圖窗口可以很好地完成這項工作。但動態的(我試過C#),你不能讓它以我上面編碼的方式工作。因此,您可以使用MS Charts或Devexpress(如圖表)來執行繪圖和選擇功能。在選擇時,您可以獲取這些值並將其繪製在axMapcontrol中。 – subho 2010-08-13 09:37:09

回答

2

顯示圖形時出現同樣的問題。 通過使用此行代碼修正它:

graphWindow.Application = ArcMap.Application 

它所需要的是ArcMap應用程序的引用。

相關問題