ThinkGeo.com    |     Documentation    |     Premium Support

Error using ZedGraph charting in Map Suite 3.0 Desktop Edition

Hi,


I'm trying to use the ZedGraph feature to incorporate pie charts using Map Suite 3.0 Desktop Edition. I've created a test WPF C# solution in Visual Studio 2008 and referenced the ZedGraph.dll and the ZedGraphStyleExtension.dll in my project. I've used the same code from the ZedGraph sample application in my xaml code behind. I've also referenced the DesktopEdition.dll and the MapSuiteCore.dll.


Whenever, I try to build the solution i get the following error message:



"Unknown build error, 'The specified path, file name or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.' " 



If I remove the reference to the ZedGraph.dll and ZedGraphStyleExtension.dll, then my solution compiles fine and I can run and view the base world map with the zoom, pan functionality.


Please advise as to what I need to do to resolve this error and be able to test the ZedGraph feature in my solution.


Thanks,


Vikram


 


 


 


 


 


 



Vikram,


Welcome you to ThinkGeo MapSuite Desktop Edition forum!
 
It seems you are trying to test against is the WPF map control, would you let me know which version are your using now? 
 
We have a sample how to use the ZendGraph as following, can you try to see it works?
HowDoI samples\ Extending MapSuite\ DrawUsingZedGraphStyle
 
If you still have problem, can you paste some of your code for us to recreate your problem?
 
Any more questions please feel free to let me know.
 
Thanks.
 
Yale

Yale, 
  
 Thanks for your response. I’m using the map control DesktopEdition.dll ver. 3.0.362.0 and MapSuiteCore.dll ver. 3.1.182.0. The ZedGraph.dll version is 5.1.4.31904 and ZedGraphStyleExtension.dll ver. 3.0.362.0. 
  
 I tried the HowDoI sample solution for ZedGraph and it works fine in that solution but the same does not work in my test WPF solution. Here’s the code from my test solution: 
  
 Window1.xaml code: 
  
 <Window x:Class=“MapSuiteTest.Window1” 
     xmlns=“schemas.microsoft.com/winfx/2006/xaml/presentation” 
     xmlns:x=“schemas.microsoft.com/winfx/2006/xaml” 
     xmlns:my=“clr-namespace:ThinkGeo.MapSuite.DesktopEdition;assembly=DesktopEdition” Loaded=“Window1_Load” 
     Title=“Window1” Height=“749” Width=“1010”> 
     <Grid> 
         <my:WpfMap x:Name=“wpfMap1” Margin=“24,22,0,0” HorizontalAlignment=“Left” VerticalAlignment=“Top” Width=“950” Height=“650”></my:WpfMap> 
     </Grid> 
 </Window> 
  
 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 Window1.xaml.cs code:  
 NOTE:- All instances of wpfMap1 give the error ‘The name wpfMap1 does not exist in the current context’ 
  
 using System; 
 using System.Collections.Generic; 
 using System.Drawing; 
 using System.Globalization; 
 using System.Linq; 
 using System.Text; 
 using System.Windows; 
 using System.Windows.Controls; 
 using System.Windows.Data; 
 using System.Windows.Documents; 
 using System.Windows.Input; 
 using System.Windows.Media; 
 using System.Windows.Media.Imaging; 
 using System.Windows.Navigation; 
 using System.Windows.Shapes; 
 using ThinkGeo.MapSuite.Core; 
 using ThinkGeo.MapSuite.DesktopEdition; 
 using ZedGraph; 
  
 namespace MapSuiteTest 
 { 
     ///  
     /// Interaction logic for Window1.xaml 
     ///  
     public partial class Window1 : Window 
     { 
         private delegate Bitmap ToUIThreadDelegate(ZedGraphDrawingEventArgs e); 
  
         public Window1() 
         { 
             InitializeComponent(); <— Get message here - “The name InitializeComponent does not exist in this context” 
         } 
  
         private void Window1_Load(object sender, RoutedEventArgs e) 
         { 
             wpfMap1.MapUnit = GeographyUnit.DecimalDegree; 
             wpfMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3); 
             wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); 
  
             ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@“C:\Murty\cities\Countries02.shp”); 
             worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; 
             worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
  
             LayerOverlay worldOverlay = new LayerOverlay(); 
             worldOverlay.Layers.Add(“WorldLayer”, worldLayer); 
             wpfMap1.Overlays.Add(“WorldOverlay”, worldOverlay); 
  
             wpfMap1.Refresh(); 
         } 
  
         private void zedGraphStyle_ZedGraphDrawing(object sender, ZedGraphDrawingEventArgs e) 
         { 
             e.Bitmap = (Bitmap)Dispatcher.Invoke(new ToUIThreadDelegate(ZedGraphDrawing), new object[] { e }); 
         } 
  
         private Bitmap ZedGraphDrawing(ZedGraphDrawingEventArgs e) 
         { 
             double scale = ExtentHelper.GetScale(wpfMap1.CurrentExtent, (float)wpfMap1.Width, GeographyUnit.DecimalDegree); 
  
             // Change the size of the graph based on the scale.  It will get bigger as you zoom in. 
             int graphHeight = Convert.ToInt32(1400000000 / scale); 
             LayerOverlay staticOverlay = (LayerOverlay)wpfMap1.Overlays[“CitiesOverlay”]; 
             ChangeLabelPosition(((ShapeFileFeatureLayer)staticOverlay.Layers[“Cities”]), graphHeight); 
  
             ZedGraphControl zedGraph = new ZedGraphControl(); 
             zedGraph.Size = new System.Drawing.Size(graphHeight, graphHeight); 
  
             zedGraph.GraphPane.Fill.Type = FillType.None; 
             zedGraph.GraphPane.Chart.Fill.Type = FillType.None; 
  
             zedGraph.GraphPane.Border.IsVisible = false; 
             zedGraph.GraphPane.Chart.Border.IsVisible = false; 
             zedGraph.GraphPane.XAxis.IsVisible = false; 
             zedGraph.GraphPane.YAxis.IsVisible = false; 
             zedGraph.GraphPane.Legend.IsVisible = false; 
             zedGraph.GraphPane.Title.IsVisible = false; 
  
             PieItem pieItem1 = zedGraph.GraphPane.AddPieSlice(Convert.ToDouble(e.Feature.ColumnValues[“WHITE”], CultureInfo.InvariantCulture), GetColorFromGeoColor(GeoColor.StandardColors.LightBlue), 0f, “White”); 
             pieItem1.LabelDetail.IsVisible = false; 
  
             PieItem pieItem2 = zedGraph.GraphPane.AddPieSlice(Convert.ToDouble(e.Feature.ColumnValues[“ASIAN”], CultureInfo.InvariantCulture), GetColorFromGeoColor(GeoColor.StandardColors.LightGreen), 0f, “Asian”); 
             pieItem2.LabelDetail.IsVisible = false; 
             pieItem2.Displacement = 0.2; 
  
             zedGraph.AxisChange(); 
  
             return zedGraph.GraphPane.GetImage(); 
         } 
  
         private static void ChangeLabelPosition(ShapeFileFeatureLayer shapeFileLayer, int graphHeight) 
         { 
             ((TextStyle)shapeFileLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[1]).XOffsetInPixel = -20; 
             ((TextStyle)shapeFileLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[1]).YOffsetInPixel = Convert.ToSingle(graphHeight * 0.4); 
         } 
  
         private static System.Drawing.Color GetColorFromGeoColor(GeoColor geoColor) 
         { 
             return System.Drawing.Color.FromArgb(geoColor.AlphaComponent, geoColor.RedComponent, geoColor.GreenComponent, geoColor.BlueComponent); 
         } 
     } 
 } 
  
  
 NOTE: If I remove the references to the ZedGraph.dll & ZedGraphStyleExtension.dll in my project and comment out all the ZedGraph related code above, the map control runs fine. 
  
 Appreciate your help! 
  
 Vikram

Vikram,


Thanks for your post and code, I reviewed your code and it seems you missed adding the ZendGraphStyle.
 
I made a separate sample same with HowDoI sample in attachment, please try it.
 
Any more questions please feel free to let me know.
Thanks.
 
Yale

1144-Post6233_Sample.zip (12.4 KB)