摘要:目前有很多图表插件可以在开发中供开发者选择,包括Silverlight本身就内置了很多图表插件,但是多数图表插件并没有提供地理区域图表功能。例如想看一下北京十八个区县人口分布情况,当然你可以使用饼图、柱状图等,但是如果可以直接看到类似于地图的分布状况不是更加直观吗?
主要内容:
1.图表功能
2.图表设计
3.使用效果
一、图表功能
图表有以下功能特点
- 区域可定制化,今天是北京市明天可能还需要用到上海市,因此这个区域不能是硬编码的而是可以自由定制的。
- 使用灵活,插件使用者可以自用设置图表的标题、区域颜色、区域的数据显示、区域提示等。
- 支持显示图例显示和鼠标互动,提高用户体验。
- 支持保存、打印,丰富图表功能。
二、图表设计
要实现这样一个图表插件,主要解决的问题还是区域制定化的问题,这里通过XML配置的方式实现,将每个图表作为一个Chart,每个Chart中有多个Area区域。Area中主要需要对区域路径和位置的描述(也就相当于要在Silverlight中通过读取配置文件进行绘制Path,不过不用担心,这些都可以通过Express Design来实现)然后程序中通过动态创建Path来实现动态绘制。另外图片的保存功能在前面的文章"Silverlight之摄像头麦克风使用"已经说过。而在Silverlight 4中也已经提供了原生的打印功能,因此要实现这两个功能也相当容易。另外还需要用到Silverlight Toolkit中的ContextMenu将其添加到右键菜单中。下面是实现的主要类图:
ChartManager主要负责图表管理,这其中包括图表Chart和区域Area的管理,通过它可以将XML配置中的图表、区域转换为对应实体。
Chart和Area为对应的实体类,通过其各自对应的Access进行访问。
ChartImage主要是实现保存功能,而Legend是对图例的抽象。
Printer和XmlHelper是两个辅助类,用户打印和xml操作。
其中几个主要类的源代码
ChartManager
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Xml.Linq;
using CmjCharts.Util;
using CmjCharts.Entity;
using CmjCharts.Config;
namespace CmjCharts.Charts
{
public class ChartManager
{
private static object _objLock = new object();
private static ChartManager _areaManager = null;
private CmjCharts.Entity.Chart _chart = null;
private List<Area> _areas = null;
private XmlHelper _xml = null;
private ChartManager()
{
_xml = new XmlHelper(ChartConstant.ConfigFilePath);
InitChart();
InitAreas();
}
public static ChartManager Instance()
{
lock (_objLock)
{
if (_areaManager == null)
{
_areaManager = new ChartManager();
}
}
return _areaManager;
}
private void InitChart()
{
_chart = new Chart();
_chart.Title = _xml.GetAttibuteValue("Chart", "Title");
}
private void InitAreas()
{
_areas = new List<Area>();
Area ar = null;
foreach (XElement elmt in _xml.Query("Area"))
{
ar = new Area();
ar.Name = _xml.GetAttibuteValue(elmt, "Name");
ar.Data = _xml.GetAttibuteValue(elmt, "Data");
ar.Width = _xml.GetAttibuteValue(elmt, "Width");
ar.Height = _xml.GetAttibuteValue(elmt, "Height");
ar.HorizontalAlignment = _xml.GetAttibuteValue(elmt, "HorizontalAlignment");
ar.VerticalAlignment = _xml.GetAttibuteValue(elmt, "VerticalAlignment");
ar.Stretch = _xml.GetAttibuteValue(elmt, "Stretch");
ar.Stroke = _xml.GetAttibuteValue(elmt, "Stroke");
ar.Fill = _xml.GetAttibuteValue(elmt, "Fill");
ar.Margin = _xml.GetAttibuteValue(elmt, "Margin");
ar.Title = _xml.GetAttibuteValue(elmt, "Title");
ar.ShowTitle = bool.Parse(_xml.GetAttibuteValue(elmt,"ShowTitle"));
ar.TitleMargin = _xml.GetAttibuteValue(elmt, "TitleMargin");
ar.Tip = _xml.GetAttibuteValue(elmt, "Tip");
ar.DataExplain = _xml.GetAttibuteValue(elmt, "DataExplain");
ar.ShowDataExplain = bool.Parse(_xml.GetAttibuteValue(elmt, "ShowDataExplain"));
_areas.Add(ar);
}
}
public List<Area> Areas
{
get
{
return _areas;
}
}
public Chart Chart
{
get
{
return _chart;
}
}
}
}
Chart
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
namespace CmjCharts.Entity
{
public class Chart:INotifyPropertyChanged
{
private string _title = "Cmj Charts";
public string Title
{
get
{
return _title;
}
set
{
_title = value;
OnPropertyChange(new PropertyChangedEventArgs("Title"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChange(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
}
}
Area
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Collections.Generic;
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.Shapes;
using System.ComponentModel;
namespace CmjCharts.Entity
{
public class Area : INotifyPropertyChanged
{
private string _fill = "Yellow";
private string _tip = "";
private string _title = "";
private string _dataExplain = "";
public Area()
{
}
public string Name
{
get;
set;
}
public string Data
{
get;
set;
}
public string Fill
{
get
{
return _fill;
}
set
{
_fill = value;
OnPropertyChange(new PropertyChangedEventArgs("Fill"));
}
}
public string HorizontalAlignment
{
get;
set;
}
public string VerticalAlignment
{
get;
set;
}
public string Stretch
{
get;
set;
}
public string Stroke
{
get;
set;
}
public string Width
{
get;
set;
}
public string Height
{
get;
set;
}
public string Margin
{
get;
set;
}
public string Title
{
get
{
return _title;
}
set
{
_title = value;
OnPropertyChange(new PropertyChangedEventArgs("Title"));
}
}
public bool ShowTitle
{
get;
set;
}
public string TitleMargin
{
get;
set;
}
public string Tip
{
get
{
return _tip;
}
set
{
_tip = value ;
OnPropertyChange(new PropertyChangedEventArgs("Tip"));
}
}
public string DataExplain
{
get
{
return _dataExplain;
}
set
{
_dataExplain = value;
OnPropertyChange(new PropertyChangedEventArgs("DataExplain"));
}
}
public bool ShowDataExplain
{
get;
set;
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChange(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
}
}
ChartAccess
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;
using CmjCharts.Entity;
using CmjCharts.Charts;
namespace CmjCharts.EntityAccess
{
[ScriptableType]
public class ChartAccess
{
public Chart Chart
{
get
{
return ChartManager.Instance().Chart;
}
}
[ScriptableMember]
public void SetTitle(string title)
{
this.Chart.Title = title;
}
}
}
AreaAccess
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Windows.Browser;
using CmjCharts.Entity;
using CmjCharts.Config;
using CmjCharts.Util;
using CmjCharts.Charts;
namespace CmjCharts.EntityAccess
{
[ScriptableType]
public class AreaAccess
{
public AreaAccess()
{
}
public List<Area> Areas
{
get
{
return ChartManager.Instance().Areas;
}
}
public Area GetAreaByName(string name)
{
Area returnArea = null;
foreach (Area ar in this.Areas)
{
if (ar.Name == name)
{
returnArea = ar;
break;
}
}
return returnArea;
}
[ScriptableMember]
public void SetBackgrondColor(string name, string color)
{
GetAreaByName(name).Fill=color;
}
[ScriptableMember]
public void SetTitle(string areaName,string title)
{
GetAreaByName(areaName).Title = title;
}
[ScriptableMember]
public void SetDataExplain(string areaName, string explain)
{
GetAreaByName(areaName).DataExplain = explain;
}
public void SetBackgrondColor(Area area,string color)
{
area.Fill = color;
}
public void SetTipInfo(string name, string tipInfo)
{
GetAreaByName(name).Tip = tipInfo;
}
}
}
ChartTipService
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;
using CmjCharts.Entity;
namespace CmjCharts.Charts
{
public class ChartTipService
{
[ScriptableMember]
public void SetTip(string areaName, string tipInfo)
{
Path path = ((Application.Current.RootVisual) as FrameworkElement).FindName(areaName) as Path;
ToolTipService.SetToolTip(path, tipInfo);
}
}
}
Printer
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Windows;
using System.Windows.Printing;
namespace CmjCharts.Util
{
public class Printer
{
PrintDocument _doc = null;
private UIElement _uiElement = null;
private string _documentName = "CmjCharts";
public Printer()
{
_doc=new PrintDocument();
}
public Printer(UIElement uiElement,string documentName):this()
{
this._uiElement = uiElement;
this._documentName = documentName;
}
public void Print(UIElement uiEelement,string documentName)
{
_doc.PrintPage+=(sender,e)=>{
e.PageVisual=uiEelement;
};
_doc.Print(documentName);
}
public void Print()
{
if (this._uiElement != null)
{
Print(this._uiElement, this._documentName);
}
}
}
}
XmlHelper
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Collections.Generic;
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.Shapes;
using System.Xml;
using System.Linq;
using System.Xml.Linq;
namespace CmjCharts.Util
{
public class XmlHelper
{
private XDocument _xdoc = null;
public XmlHelper(string filePath)
{
_xdoc = XDocument.Load(filePath);
}
public void Add(string nodeName,string attributeName, string attributeValue)
{
XElement elmt = new XElement(nodeName);
elmt.SetAttributeValue(attributeName, attributeValue);
_xdoc.Root.Add(elmt);
}
public void Delete(string nodeName,string attributeName, string attributeValue)
{
var elmt=from p in _xdoc.Descendants(nodeName)
where p.Attribute(attributeName).Value==attributeValue
select p;
elmt.Remove();
}
public void Update(string nodeName, string attributeName, string attributeValue)
{
IEnumerable<XElement> elmts = from p in _xdoc.Descendants(nodeName)
where p.Attribute(attributeName).Value == attributeValue
select p;
XElement elmt = elmts.FirstOrDefault();
elmt.SetAttributeValue(attributeName, attributeValue);
}
public IEnumerable<XElement> Query(string nodeName, string attributeName, string attributeValue)
{
IEnumerable<XElement> elmts = from p in _xdoc.Descendants(nodeName)
where p.Attribute(attributeName).Value == attributeValue
select p;
return elmts;
}
public IEnumerable<XElement> Query(string nodeName)
{
IEnumerable<XElement> elmts = from p in _xdoc.Descendants(nodeName)
select p;
return elmts;
}
public XElement QueryFirst(string nodeName)
{
IEnumerable<XElement> elmts = from p in _xdoc.Descendants(nodeName)
select p;
return elmts.FirstOrDefault();
}
public string GetAttibuteValue(XElement element, string attributeName)
{
return element.Attribute(attributeName).Value;
}
public string GetAttibuteValue(string elementName, string attributeName)
{
return GetAttibuteValue(QueryFirst(elementName), attributeName);
}
}
}
再看一下配置文件,需要注意的是文件中路径、长、宽、间隔等是可以通过Expression Design中绘制然后导出XAML粘贴过来的。
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
<?xml version="1.0" encoding="utf-8" ?>
<Chart Title="Cmj Charts">
<Area Name="HuaiRou" Title="怀柔" ShowTitle="true" TitleMargin="440,110,0,0" Tip="怀柔区" DataExplain="4%" ShowDataExplain="true" Width="164" Height="298.54" Margin="364.157,10.4598,0,0" Stretch="Fill" Stroke="White" Fill="#FFFFFF00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 408.158,110.833L 404.158,107.5L 402.824,101.5C 402.824,101.5 394.824,102.166 395.491,99.4998C 396.157,96.8331 393.491,91.4998 393.491,91.4998L 378.157,75.4998L 373.491,70.8331C 373.491,70.8331 372.824,54.1664 379.491,54.8331C 386.157,55.4998 384.824,53.4998 384.824,53.4998C 384.824,53.4998 392.824,55.4998 394.824,62.1664C 396.824,68.8331 406.824,68.1664 406.824,68.1664L 413.491,69.4998C 413.491,69.4998 402.824,48.8331 405.491,48.1664L 409.491,37.4998L 425.491,40.8331L 432.824,34.8331L 441.491,34.8331L 450.824,42.1664L 451.491,28.8331L 455.491,23.4998L 450.824,21.4998C 450.824,21.4998 450.158,12.1664 456.157,10.8331C 462.157,9.49982 468.157,12.1664 468.157,12.1664C 468.157,12.1664 468.824,12.8331 476.157,16.1664C 483.491,19.4998 478.824,25.4998 478.824,25.4998L 475.491,32.1664L 475.491,40.8331L 473.491,44.8331L 483.491,58.1664L 485.491,66.1664C 485.491,66.1664 496.824,68.8331 496.157,72.8331C 495.491,76.8331 503.491,80.1664 506.157,87.4998C 508.824,94.8331 521.491,92.8331 521.491,92.8331L 528.157,105.5C 528.157,105.5 518.158,108.166 512.824,120.166L 499.491,122.833L 500.824,138.166L 494.824,140.833C 494.824,140.833 478.824,144.833 479.491,151.5C 480.157,158.166 476.824,166.166 476.824,166.166L 478.824,176.833L 480.157,186.833L 470.824,195.5C 470.824,195.5 476.158,196.166 478.157,201.5C 480.157,206.833 476.157,219.5 476.157,219.5L 478.157,229.5C 478.157,229.5 489.491,244.833 481.491,263.5L 486.157,272.166L 495.491,278.833L 492.157,287.5L 486.824,291.5C 486.824,291.5 467.491,313.5 470.157,308.166C 472.824,302.833 468.824,300.166 468.824,300.166L 452.157,302.833C 452.157,302.833 438.158,290.166 437.491,294.166C 436.824,298.166 423.491,300.166 423.491,300.166L 420.824,295.5L 408.157,287.5L 408.157,278.833L 395.491,273.5L 384.824,263.5C 384.824,263.5 376.824,262.166 376.157,259.5C 375.491,256.833 366.158,252.833 365.491,256.833C 364.824,260.833 364.157,249.5 364.157,249.5L 368.157,244.833C 368.157,244.833 362.824,234.833 368.824,230.166C 374.824,225.5 370.157,225.5 370.157,225.5L 366.157,222.833L 373.491,216.833L 384.824,216.166L 386.157,221.5L 392.824,224.833L 408.824,221.5L 423.491,222.166L 428.157,215.5L 424.824,208.166L 418.157,204.166L 412.824,204.166L 417.491,195.5L 423.491,195.5L 432.824,172.166L 438.824,169.5L 442.824,163.5L 435.491,162.833L 427.491,156.833L 427.491,152.166L 419.491,151.5L 426.157,126.166L 413.491,114.833L 408.158,110.833 Z "/>
<Area Name="YanQing" Title="延庆" ShowTitle="true" TitleMargin="330,184,0,0" Tip="延庆区" DataExplain="2%" ShowDataExplain="true" Width="235.4" Height="201.125" Margin="205.657,104.208,0,0" Stretch="Fill" Stroke="White" Fill="#FFFF0064" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 53,62.5L 59,65L 64.5,65L 72.5,67.5C 72.5,67.5 76.5,78.5 75.5,74.5C 74.5,70.4999 83.5,66 83.5,66C 83.5,66 87.5,66 89.5,67.5C 91.5,68.9999 95.5,60 95.5,60L 99,60.5C 99,60.5 100.5,58 101.5,56.5C 102,55.75 104,52.0625 107,49.5C 110,46.9375 114,45.5 114,45.5L 119,45.5L 120.5,35.5L 126,24.5L 132.5,19.5C 132.5,19.5 133.5,18.5 138,7.49998C 142.5,-3.50002 148,1.49998 149,-2.28882e-005C 150,-1.50005 158,11 158,11L 169,6.99998C 169,6.99998 173,10.5 180.5,7.49998C 188,4.49995 195.5,6.99998 195.5,6.99998L 203,7.49995C 203,7.49995 208.5,11.4999 210.5,11.9999C 212.5,12.5 217.5,18.5 217.5,18.5C 217.5,18.5 216,21.9999 218,22C 220,22 218,30.5 218,30.5L 215.5,38L 212,46L 221.5,49C 221.5,49 221.5,52.4999 224.5,55C 227.5,57.5 233.5,58.5 233.5,58.5C 233.5,58.5 237,62.9999 234.5,63.5C 232,64 227,66 227,66L 224,75.5L 220,82.5L 217.5,88.5L 211.5,90.5C 211.5,90.5 207,96.4999 207.5,98.5C 208,100.5 211,102.5 211,102.5L 215.5,103C 215.5,103 219,103 219.5,106.5C 220,110 219.5,114.5 219.5,114.5L 216.5,117.5L 205,116.5L 190.5,120L 184.5,119.5L 180,115.5L 177,112L 167.5,112L 160,118.5C 160,118.5 163.5,123 163,125.5C 162.5,128 159,130.5 159,130.5L 161.5,140L 158.5,145.5L 158.5,151.5L 160,155C 160,155 156,158 154.5,156C 153,154 148,154.5 148,154.5L 144.5,157.5L 140.5,155.5L 133.5,156.5L 130.5,158.5L 127.5,158L 123,160.5C 123,160.5 119.5,159 119.5,162.5C 119.5,166 117.5,170 117.5,170L 117.5,178.5L 113.5,180.5L 111.5,176L 105.5,173L 101,173L 94,171.5L 93,177C 93,177 90,178.5 88,177.5C 86,176.5 79.5,167 79.5,167L 74,170.5L 71,175L 74,181L 75,184.5C 75,184.5 73,190 73.5,192.5C 74,195 70,195.5 70,195.5L 67.5,200L 62,201L 55.5,201L 55,197L 57,189.5C 57,189.5 53,184 55,181.5C 57,179 50,175.5 50,175.5L 50,168.5L 33.5,165.5L 15.5,138.5L 8.5,136.5L 8.5,123L 5,116L 2,116L 0,112L 0,104.5C 0,104.5 4.00002,91.9999 6,92.5C 8,93 15.5,84 15.5,84L 22,84.5C 22,84.5 23,74.4999 25.5,75.5C 28,76.5001 35.5,68.9999 43,72.5L 45.5,67.5L 53,62.5 Z "/>
<Area Name="MiYun" Title="密云" ShowTitle="true" TitleMargin="540,204,0,0" Tip="密云县" DataExplain="8%" ShowDataExplain="true" Width="233.692" Height="208.692" Margin="469.245,104.143,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFE22D2D" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 56.6539,0.499992C 56.6538,0.500023 62.8077,1.26919 62.4231,2.80767C 62.0384,4.34618 60.1154,7.80767 61.6538,7.80773C 63.1923,7.80773 66.2692,8.19231 66.2692,8.19231L 69.3462,12.0385C 69.3462,12.0385 68.5769,17.8077 70.8846,19.7308C 73.1923,21.6539 76.6538,22.0385 76.6538,22.0385L 82.8077,33.1923L 92.4231,36.6539L 98.9615,36.6539C 98.9615,36.6539 106.269,33.1923 109.346,33.577C 112.423,33.9616 126.654,32.0385 126.654,32.0385L 133.192,35.1154L 143.192,34.3462L 149.346,36.2693L 156.269,40.8847L 160.885,40.5C 160.885,40.5 173.577,48.5769 174.731,50.5C 175.885,52.4231 192.423,40.1154 197.808,39.7308C 203.192,39.3462 214.731,40.1154 214.731,40.1154L 223.192,45.8847L 227.808,43.9616L 231.654,47.0385L 233.192,53.577L 228.962,57.4231L 229.346,60.8847L 225.115,62.0385L 220.5,60.8847L 218.962,58.1923L 216.269,56.6539L 216.269,60.5L 210.5,63.1923L 207.808,60.1154L 206.269,62.8077L 207.423,68.1923L 208.192,73.1923L 209.731,79.7308L 207.808,83.9616L 202.038,84.7308L 199.731,88.1923L 193.962,88.9616L 191.269,85.5L 184.731,80.8847L 181.654,82.8077L 177.808,82.4231L 173.962,85.8847L 168.577,88.577L 164.346,90.1154C 164.346,90.1154 161.269,88.9615 161.654,93.1923C 162.038,97.4231 162.038,100.115 162.038,100.115L 162.423,103.577C 162.423,103.577 162.038,107.038 158.192,106.654C 154.346,106.269 150.885,106.269 150.885,106.269C 150.885,106.269 148.192,108.192 151.654,110.5C 155.115,112.808 153.962,113.962 154.731,115.885C 155.5,117.808 157.038,122.038 157.038,122.038C 157.038,122.038 159.731,125.5 162.038,126.269C 164.346,127.038 163.192,132.038 163.192,132.038L 160.5,139.346L 159.346,146.654C 159.346,146.654 156.269,153.577 153.962,153.192C 151.654,152.808 145.115,153.192 145.115,153.192L 140.885,151.654L 131.269,155.885L 128.192,157.038L 121.654,159.346L 117.808,160.115L 108.192,164.731C 108.192,164.731 105.885,165.885 100.115,167.038C 94.3462,168.192 92.8077,169.346 92.4231,172.808C 92.0384,176.269 91.6538,178.577 91.6538,178.577L 89.7307,182.038L 85.8846,184.731L 78.9615,189.731L 76.6538,193.577C 76.6538,193.577 73.9616,200.885 77.8077,203.192C 81.6538,205.5 77.4231,206.654 77.4231,206.654L 71.2692,206.269L 67.4231,208.192L 62.8077,204.346L 59.7307,200.5L 57.0384,197.038L 54.7307,191.654L 54.3462,186.269C 54.3462,186.269 47.8078,182.808 48.9615,177.423C 50.1153,172.039 44.3462,176.269 44.3462,176.269L 42.0385,183.192L 35.8846,187.038L 30.8846,187.808L 27.8077,190.885L 23.1923,189.731L 17.423,189.731L 22.8077,182.423L 23.5769,179.346L 26.2692,175.5C 26.2692,175.5 25.1154,172.423 21.6538,172.808C 18.1923,173.192 20.1154,170.5 20.1154,170.5L 15.8846,168.577L 14.3461,161.269L 11.6538,158.577L 13.5769,152.423C 13.5769,152.423 15.5,141.654 14.3461,136.654C 13.1923,131.654 13.1923,128.962 10.1154,126.269C 7.03845,123.577 9.34613,117.423 9.34613,117.423L 6.2692,113.962C 6.2692,113.962 8.19229,102.423 10.1154,100.885C 12.0385,99.3462 9.73074,96.6539 9.73074,96.6539L 1.2692,92.0385L 0.5,88.577C 0.5,88.577 12.0385,85.1154 12.0385,82.8077C 12.0385,80.5 9.34613,76.6539 9.34613,76.6539L 10.5,73.577L 6.65384,69.3462L 7.42303,61.6539L 10.5,56.6539L 9.73074,49.7308C 9.73074,49.7308 12.4231,41.2692 15.5,41.2693C 18.5769,41.2693 25.5,34.7308 25.5,34.7308L 28.9615,36.2693L 31.6538,36.2693L 30.5,30.8847L 30.1154,23.9616L 28.9615,20.8847C 28.9615,20.8847 30.8846,17.8077 40.8846,18.577C 50.8845,19.3462 43.1923,16.6539 43.1923,16.6539L 44.7307,12.4231L 50.5,4.73083L 56.6539,0.499992 Z "/>
<Area Name="PingGu" Title="平谷" ShowTitle="true" TitleMargin="580,304,0,0" Tip="平谷区" DataExplain="5%" ShowDataExplain="true" Width="133.085" Height="129.374" Margin="541.854,256.482,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF00C800" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 80.6667,1.41663L 85.1667,2.16663L 88.6667,5.91666L 89.1667,10.4167L 94.1667,14.4167L 95.1667,22.6667L 97.9167,23.4167C 97.9167,23.4167 101.417,32.1666 100.917,33.6667C 100.417,35.1667 107.667,30.1667 107.667,30.1667C 107.667,30.1667 111.667,28.9166 112.917,35.9167C 114.167,42.9167 114.667,46.9166 113.417,48.1667C 112.167,49.4167 117.667,51.9167 117.667,51.9167L 122.167,51.1667C 122.167,51.1667 124.917,51.6666 125.667,52.6667C 126.417,53.6667 125.167,64.4167 125.167,64.4167L 131.167,65.9167C 131.167,65.9167 133.167,68.6666 132.417,70.6667C 131.667,72.6667 129.917,73.4166 128.417,74.1667C 126.917,74.9167 118.917,74.9167 118.917,74.9167L 117.417,86.4167C 117.417,86.4167 115.917,89.6666 111.167,89.6666C 106.417,89.6666 107.667,87.1667 107.667,87.1667C 107.667,87.1667 105.417,87.1666 104.167,90.1666C 102.917,93.1666 99.4167,96.1666 99.4167,96.1666C 99.4167,96.1666 96.6667,96.6666 95.9167,99.1666C 95.1666,101.667 92,100.75 92,100.75L 88.25,98.5C 88.25,98.5 88.2501,97.2499 83.75,101C 79.25,104.75 80.5001,102.75 79.5,103C 78.5,103.25 78,107 78,107C 78,107 77.5001,110.25 77,112.5C 76.5,114.75 74.5001,114.75 71.25,112.75C 68,110.75 64.5,112 64.5,112L 59.25,115C 59.25,115 45.5001,112 44,112.25C 42.5,112.5 42,115.25 42,115.25L 36.75,115.5L 33.5,121.25L 30,122.25C 30,122.25 25.0001,124 23.25,127.75C 21.5,131.5 5.50006,125 5,121C 4.5,117 6.25,118.75 6.25,118.75C 6.25,118.75 8.50006,113.75 13.5,113C 18.5,112.25 14.5,108.25 14.5,108.25C 14.5,108.25 10.2501,104.5 10.25,101.25C 10.25,98 11.25,97.5 11.25,97.5L 10.75,92.5L 10.25,82.25L 8.25,77.5L 6,77.25L 3.75,73L 4,69.75L 0.5,65.75L 1,59.5L 4,56.75L 3.75,53.75L 5.5,52.25L 5.75,50.5L 2.75,47.25L 2.75,41.75L 5.5,40L 6,37.25C 6,37.25 17.7501,29.5 18.5,27.25C 19.25,25 19,21.25 19,21.25C 19,21.25 18.7501,15 31.25,14.5C 43.75,14 36.5001,12.5 38.5,11.25C 40.5,9.99997 44,7.49997 44,7.49997L 48.5,7.74997L 54,4.49997L 58,3.99997L 63.25,0.75L 71.25,0.5L 72,2.49997L 80.6667,1.41663 Z "/>
<Area Name="ShunYi" Title="顺义" ShowTitle="true" TitleMargin="465,330,0,0" Tip="顺义区" DataExplain="5%" ShowDataExplain="true" Width="145.771" Height="110.608" Margin="410.521,280.125,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF230FD2" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 75.5834,13.1875L 82.0834,13.1875L 87.0833,13.9375L 89.5833,11.4375L 93.5833,11.4375L 99.3333,7.9375C 99.3333,7.9375 100.583,2.4375 102.583,0.9375C 104.583,-0.5625 106.583,1.1875 106.583,1.1875C 106.583,1.1875 110.333,8.4375 112.583,9.1875C 114.833,9.9375 112.833,14.1875 112.833,14.1875L 114.333,14.1875L 113.583,17.9375C 113.583,17.9375 118.333,21.6875 118.333,23.1875C 118.333,24.6875 119.833,28.9375 119.833,28.9375L 125.083,32.4375L 127.583,32.4375C 127.583,32.4375 131.083,28.1875 134.083,30.4375C 137.083,32.6875 134.083,32.6875 134.083,32.6875L 132.333,35.4375L 132.333,42.1875L 135.833,45.6875L 135.583,49.6875L 137.083,53.1875L 139.833,53.9375L 141.833,57.6875L 141.333,68.4375L 141.833,77.1875C 141.833,77.1875 142.833,82.9375 144.333,83.1875C 145.833,83.4375 145.083,88.6875 145.083,88.6875L 140.333,91.4375L 137.583,92.4375L 137.333,95.6875L 135.833,97.1875L 129.333,99.9375L 128.083,98.1875L 119.833,97.9375L 115.333,100.938L 109.083,100.438C 109.083,100.438 108.333,97.9375 105.833,97.6875C 103.333,97.4375 101.333,98.1875 100.833,100.688C 100.333,103.188 97.5833,105.188 97.5833,105.188L 90.3333,104.938L 88.8333,106.688L 85.5833,107.188L 83.8333,107.188L 80.0833,107.188L 75.0833,105.688C 75.0833,105.688 70.0834,109.187 66.3333,108.938C 62.5833,108.688 58.0833,109.938 58.0833,109.938C 58.0833,109.938 56.8334,106.187 52.8333,106.688C 48.8333,107.188 48.5833,106.188 48.5833,106.188C 48.5833,106.188 44.0834,103.687 42.5833,103.188C 41.0833,102.688 41.0833,107.188 41.0833,107.188L 34,103.354L 25.75,95.3542L 25,92.3542L 19.75,88.1042L 16,87.1042L 10.5,84.3542L 8.75,84.8542L 1.5,83.6042L 0.5,79.3542L 6.25,77.6042L 5.75,71.8542L 8.75,75.1042L 7.25,71.3542L 6,63.6042L 5.25,57.8542L 4.5,50.8542L 6,49.6042L 5,46.3542L 6.5,44.6042L 6.5,43.1042L 2.5,39.6042L 3,35.1042L 5,32.6042L 5,29.3542L 6.5,25.8542L 9.75,21.8542L 12.5,21.8542L 13,19.6042L 14.5,20.1042L 22.25,13.6042L 31,14.1042L 34.75,16.3542L 42.25,21.6042L 47.5,20.6042L 58.25,19.8542L 60,21.1042L 60.5,26.3542L 63.5,25.6042L 71,18.6042L 75.5834,13.1875 Z "/>
<Area Name="ChangPing" Title="昌平" ShowTitle="true" TitleMargin="330,304,0,0" Tip="昌平区" DataExplain="7%" ShowDataExplain="true" Width="188.75" Height="127" Margin="236.479,254.691,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFFC800" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 128.25,4.49997L 129,1.74997L 131.5,0.500031L 135.75,0.500031L 140.5,3.75003L 142,6L 148.5,8.25L 150.25,9.25L 152,11.25L 154.25,13L 157.75,19.5L 161.75,20.5L 166.75,21.5L 168.5,23L 171.25,23.5C 171.25,23.5 172.25,28.75 172,30C 171.75,31.25 173.25,33.25 173.25,33.25L 173.5,35.25L 175.75,36.5L 178.5,38L 181.25,39.25L 183.5,41.5L 186.75,42L 188.25,46L 185,47.25L 182.25,49.75L 180,51.5C 180,51.5 180.75,54 180.75,55.25C 180.75,56.5 179.5,58.5 179.5,58.5L 176.75,61.25C 176.75,61.25 176.75,63.5 176.75,64.75C 176.75,66 179.25,68 179.25,68L 179.75,69.75L 178.75,72.5L 180.25,75L 178.75,78L 179.5,86L 180.25,96.25L 181.378,97.519L 182.25,98.5L 182,101.5L 179.25,98.25L 180,102.5L 176.5,105L 174.25,105.75L 175,109L 171,115.75L 166.5,117.75L 160.75,122L 156,126.5L 155,124.5L 151.5,121L 151.75,117.25L 150.25,115.25L 145.25,115.5L 139.75,117.5L 133.75,118.25L 130.5,114.75L 129,110.5L 122,103.75L 115.75,102.75L 113.75,100.25L 113.25,97.5L 115,93.25L 111,90L 106.5,89.75L 103.5,86L 99.25,84.25L 95.25,85.75L 92.75,89.25L 92.5,92.75L 90.5,95.25L 86.75,97.25L 79,98.25L 75,97.75L 72.75,98.25L 70.75,97.5L 68.5,99.5L 65.75,98.75L 64.5,102.25L 58.75,108.25L 55.75,110.75L 52,111.5L 48.5,112.75L 45.25,111.75L 43,111.75L 39.5,112.25L 36.25,109.75L 33.75,106.25L 30.25,102.5L 24.5,99.5L 23,96.5L 22.25,94.25L 21,91.75L 21.25,90L 15.75,88.5L 11.25,88.5L 5.25,88.75L 2.75,88L 2.25,85.75L 1.25,82.25L 0.5,79.25L 2,76.75L 2.75,73.5L 2.75,72L 8.5,71L 9.75,67.25L 12.5,64.5L 12.5,61L 15,57L 18.25,54.75L 23,51.25C 23,51.25 23.75,51.25 24.75,51.25C 25.75,51.25 28.75,52.5 28.75,52.5L 30,50.75L 34.25,50.75L 36.25,49.25L 37.25,45.25L 41.5,43.75L 41.5,39.25L 41.5,36L 43,33.75L 43.75,30L 41,29L 42,25.75L 38.5,23.75L 40.75,21.75L 42.25,20.25L 42.25,18L 44.75,20.75L 46.75,18.25C 46.75,18.25 49.5,17.5 51,19C 52.5,20.5 53.25,22.25 53.25,22.25L 55.25,24.75L 56.75,27.25L 59.25,27.5L 62,25L 64,24L 63,21.75L 68.75,20L 69.75,22.25L 72.75,23.5L 74.25,23.5L 78.25,24.5L 80.5,26L 80.5,28.5L 83.5,29L 85.75,28L 85.75,24L 85,21.75L 86.5,21.5C 86.5,21.5 85.5,18 86.75,18C 88,18 88.5,18 88.5,18L 89,12.5L 90.25,9L 93.75,10L 95.25,8.25L 98.25,8.75L 100,8.25L 103,7C 103,7 105.25,3.00003 106.5,3.75003C 107.75,4.5 108.25,6 108.25,6C 108.25,6 109.5,4.99997 110.5,5.75C 111.5,6.5 112,6.75 112,6.75L 114,7.75L 115.5,4.75L 117.5,3.25003L 121,4.5C 121,4.5 120.75,6.49997 121.75,6.5C 122.75,6.5 128,5 128.25,4.49997 Z "/>
<Area Name="MenTouGou" Title="门头沟" ShowTitle="true" TitleMargin="210,380,0,0" Tip="门头沟区" DataExplain="10%" ShowDataExplain="true" Width="206.5" Height="131.683" Margin="125.521,329.966,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF5A0FC8" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 34.25,130.156L 39.5,131.156L 40.75,129.656L 42.75,129.656L 50.25,118.906L 49.75,111.406L 53.25,110.156L 56.5,110.156L 59,108.406L 61,105.656L 63.75,104.906L 68.5,100.906L 71.25,100.906L 75.75,99.1562L 86,95.6562L 91.75,92.4062L 100,92.9062L 104.5,95.1562L 111,99.6562L 114.75,99.9062L 118.25,99.4062L 125.25,94.9062L 138.5,94.6562L 141.25,96.1562L 140.75,99.9062L 142.75,102.906L 145.75,104.406L 147.25,108.406L 154.5,109.406L 157,112.906L 157,116.656L 160,120.906L 168.5,120.906L 175.75,124.406L 175.75,121.656L 176,113.156L 174.25,112.156L 176,110.906L 179.75,112.156L 183.75,111.906L 186.25,109.156L 190,107.906L 194.25,106.656L 196.25,105.906L 199.75,105.906L 201.5,105.406L 202.25,103.656L 200.75,102.656L 198.25,102.656L 198.25,99.6562L 196.5,95.4062L 194.25,93.4062L 193,91.1562L 189.75,88.4062L 188.5,83.6562L 190,83.1562L 190.5,81.1562L 186.25,78.6562L 186.25,76.9062L 188.5,75.4062L 188.5,71.9062L 188.25,69.1562C 188.25,69.1562 197,65.1562 199,66.4062C 201,67.6562 199.5,68.6562 199.5,68.6562L 204.25,66.4062L 206,65.4062L 206,60.4062L 204.25,57.4062L 200,54.4062L 192.5,54.9062L 190,52.4062L 181.5,52.4062L 179.25,51.4062L 177.75,47.9062L 177.25,42.9062L 175.5,38.6562L 170.25,33.1562L 165.25,34.6562L 157.75,36.4062C 157.75,36.4062 156,35.9062 153.75,36.4062C 151.5,36.9062 149.25,37.4062 149.25,37.4062L 146.75,33.6562L 145.25,30.6562L 141.75,27.4062L 137.75,25.6562L 134.25,22.6562L 133.5,19.6562L 131.25,14.9062C 131.25,14.9062 127.75,12.6562 122.75,11.9063C 117.75,11.1563 116.75,13.1563 116.75,13.1563L 113.75,11.9063L 111,10.4063C 111,10.4063 109.25,10.6562 108.25,10.4063C 107.25,10.1563 105.75,7.65625 105.75,7.65625L 103.75,6.65625L 101.25,2.90625L 99.75,0.90625C 99.75,0.90625 95.75,-0.343781 94.25,1.40625C 92.75,3.15625 90,3.65622 88.5,4.90625C 87,6.15625 87.25,11.1563 87.25,11.1563L 84.75,15.6562C 84.75,15.6562 80.5,16.4062 78.5,14.9062C 76.5,13.4063 72.75,13.4062 71,14.4062C 69.25,15.4062 63.75,14.6562 62.75,16.1562C 61.75,17.6562 61.5,19.9062 61.5,19.9062L 57.25,20.6562C 57.25,20.6562 54.75,18.4062 51.75,19.1562C 48.75,19.9062 47,22.1562 46.5,24.4062C 46,26.6562 45.75,27.4062 45.75,27.4062L 42.5,26.1562L 38.75,26.1562L 33,30.1562C 33,30.1562 27.5,34.1562 26.5,35.6562C 25.5,37.1562 24.75,40.4062 24.75,40.4062L 23.25,41.4062L 20,42.9062L 19,44.6562L 15.75,46.1562L 11.5,50.4062L 8.75,54.9062L 5.5,58.1562L 4.75,61.6562L 1.5,64.4062L 2.25,69.1562L 0.75,69.9062L 1,77.4062L 0.5,78.9062L 4,81.4062L 4.75,85.1562L 9.75,87.4062L 13,88.6562L 19.25,95.1562L 22.25,96.4062L 20,100.156L 20,103.656L 19.75,106.156L 24.5,106.156L 22.5,111.406L 21.5,115.406L 22,119.906L 26,124.906L 31.75,128.156L 34.25,130.156 Z "/>
<Area Name="HaiDian" Title="海淀" ShowTitle="false" TitleMargin="330,184,0,0" Tip="海淀区" DataExplain="7%" ShowDataExplain="false" Width="98.3333" Height="95.3333" Margin="294.979,337.857,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFF0064" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 74.5,34.8333L 80,35.1667L 81.8333,34L 84.5,32.8333L 86.8333,31.8333L 92.3333,32.1667L 93.5,32.8333L 93.3333,37.3333L 95,40.1667L 97.5,41.6667L 97.8333,44.1667L 95.8333,44.5L 90.1667,44.6667L 89.8333,45.6667L 87.3333,45.6667L 87.5,46.6667C 87.5,46.6667 83.6667,46.5 84.3333,46.5C 85,46.5 84.1667,48.5 84.1667,48.5L 86.3333,52.5L 87.8333,54.6667L 89.8333,58.1667L 89.5,59.5L 90.6667,63.1667L 91.1667,67.5L 87,68.5L 85.1667,70C 85.1667,70 83.3334,75.1667 84,75.6667C 84.6667,76.1667 80.8333,76.6667 80.8333,76.6667L 79,78.3333L 78.6667,94.5L 75.8333,94.8333L 75.6667,93.6667L 67.5,94.5L 67.1667,93L 63.1667,93L 62.5,94.3333L 60,94.5L 59.6667,93L 57.6667,93.3333L 56.8333,90L 57.6667,84.5L 55.5,84L 54.1667,85.1667L 51.6667,85.5L 50.6667,84.5L 47,83.3333L 46.8333,73.3333L 45.6667,71.1667L 45,69.3333C 45,69.3333 41.3334,65.1667 40.5,65.5C 39.6667,65.8333 40.6667,62.8333 40.6667,62.8333L 40.1667,60.6667L 36.6667,57.6667L 36.5,53L 35.5,51.6667L 34.5,50.1667C 34.5,50.1667 30.8334,47 30.3333,46.3333C 29.8333,45.6667 22.3333,46.5 22.3333,46.5C 22.3333,46.5 20.8334,44.1667 19.8333,44.5C 18.8333,44.8333 17,44.1667 17,44.1667L 14.8333,43.3333L 14.8333,44.3333L 11.3333,45C 11.3333,45 8.66669,42.8333 8.66669,42.1667C 8.66669,41.5 9,40.1667 9,40.1667L 8.33334,35.6667L 7,33.8333L 5.66669,30.8333L 0.5,25.1667L 4.16669,21.3333L 6.5,18.6667L 6.33334,16.1667L 7.83334,15.3333L 10,15.5C 10,15.5 12.8334,15.3333 14,15.3333C 15.1667,15.3333 16,15.8333 16,15.8333L 16.3333,14.8333L 20.5,14.6667L 25.5,14.8333L 26.5,13.6667L 29.1667,13.6667L 32.3333,11.5L 33.3333,10.1667L 34.6667,6.16666L 38.3333,1.16669L 41.8333,0.5L 44.5,2.16669L 48.1667,4.83334L 49,6.33334L 51.8333,6.16666L 54.1667,8.16666C 54.1667,8.16666 56.3334,9.66666 56.5,10.3333C 56.6667,11 55.8333,13.8333 55.8333,13.8333L 55.5,17L 56.5,18.5L 59.1667,19C 59.1667,19 61.6667,19.3333 62.1667,20C 62.6667,20.6667 65.8333,22.3333 65.8333,22.3333L 70,26.5L 70.8333,30.1667L 72.5,32.5L 74.5,34.8333 Z "/>
<Area Name="ShiJingShan" Title="石景山" ShowTitle="false" TitleMargin="330,184,0,0" Tip="石景山区" DataExplain="4%" ShowDataExplain="false" Width="41.8333" Height="45.8333" Margin="310.938,394.982,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFF7D00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 41,27.4999L 41.3333,36.3333L 39.8333,37.6666L 35.8333,38.5L 35.6667,44.5L 30.8333,45.3333L 29.6667,44.3333L 27.8333,44.3333L 28,42.8333L 20.8333,43L 19.6667,41.6666L 18,40.5L 16.6667,39.5L 16,37.8333L 12.8333,37.3333L 12.6667,34L 13.6667,33.1666L 11.3333,33.5L 11.1667,31L 9.83334,29.5L 8.83334,27.6666L 7.5,26L 6.33334,25.5L 4.5,23.6666L 3.5,23L 3.16666,18.8333L 5.16666,18.6666L 4.83334,16.6666L 3.66666,16.1666L 1.5,14L 0.5,13L 1.5,11.6666L 3.83334,10.5L 3.83334,7.5L 2.83334,4.16663L 5.83334,2.16663L 9.33334,2.16663L 13,1.66663L 13.5,3.66663L 15.1667,4.16663L 20,0.5C 20,0.5 21.8333,1.66663 22.5,2.66663C 23.1667,3.66663 24.3333,4.5 24.3333,4.5L 24.3333,7.83331C 24.3333,7.83331 28.5,11.3333 29.6667,14C 30.8333,16.6666 31,16.1666 31,16.1666L 30.8333,26.1666L 33.5,26.5L 36.1667,28L 37.6667,29C 37.6667,29 39.9999,26 41,27.4999 Z "/>
<Area Name="ChaoYang" Title="朝阳" ShowTitle="false" TitleMargin="330,184,0,0" Tip="朝阳区" DataExplain="5%" ShowDataExplain="false" Width="83.9583" Height="98.9583" Margin="378.646,363.524,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF64FF00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 25.9584,92.9583L 26.9584,94.4583L 28.625,94.7917L 31.2917,95.4583L 31.4583,96.625L 33.4583,96.2917L 34.4583,97.4583L 34.2917,98.4583L 37.125,98.125L 38.125,96.9583L 40.9583,96.7917L 41.2917,95.625L 42.4583,95.9583L 43.9583,95.4583L 45.625,94.7917L 46.9583,94.7917L 47.2917,93.625L 49.4583,94.125L 50.125,92.9583L 51.625,92.9583L 51.9583,94.625L 59.125,95.125L 67.2917,94.2917L 71.2917,90.625L 74.2917,86.2917L 76.2917,83.125L 76.2917,80.4583L 77.2917,79.625L 76.9583,76.7917L 76.125,71.2917L 77.2917,65.125L 76.125,63.125L 78.625,59.9583L 79.4583,57.4583L 82.125,51.625L 81.9583,50.2917L 83.4583,49.7917L 83.125,43.7917L 82.4583,32.4583L 81,28.8333L 79.5,27.3333L 76.1667,26.8333L 72.8333,24.5L 67.3333,20L 63,18.3333L 59.3333,12.8333L 57.6667,11.6667L 57.3333,9.83334L 54.3333,6.99997L 51.5,4.49997L 47.8333,3.99997L 46,2.16666L 42.6667,1.66666L 40,0.999969L 33.6667,0.499969C 33.6667,0.499969 30.8334,2.99997 30.6667,5.49997C 30.5,7.99997 27.6667,7.49997 27.6667,7.49997L 23.6667,8.33334L 15.5,16.6667L 14.1667,18.1667L 12.6667,18.6667L 7,18.6667L 3.16666,20.5L 0.5,21.8333L 1.66666,25L 3,28L 5.66666,32.1667L 6.83334,36.8333L 7.83334,37.8333L 7.83334,42.1667L 9.5,43.8333L 12.3333,43.5L 14,43L 14.8333,41L 18.1667,41.3333L 19.6667,43.1667L 21.6667,45C 21.6667,45 23,46 23,46.6667C 23,47.3333 22.8333,49.3333 22.8333,49.3333C 22.8333,49.3333 23.8334,51.8333 24,52.5C 24.1667,53.1667 26,56.8333 26,56.8333L 25.8333,61.8333L 24.8333,64.1667C 24.8333,64.1667 24.5,65.1667 25.1667,65.1667C 25.8333,65.1667 26.8333,67.8333 26.8333,67.8333L 27.3333,74.6667L 28.3333,78.3333L 28.8333,80L 31.1667,81.3333L 34,81.8333L 34.5,87.1667L 29.5,87.6667C 29.5,87.6667 28.1667,89 28.3333,91C 28.5,93 25.8333,91.6667 25.8333,91.6667L 25.9584,92.9583 Z "/>
<Area Name="XiCheng" Title="西城" ShowTitle="false" TitleMargin="330,184,0,0" Tip="西城区" DataExplain="7%" ShowDataExplain="false" Width="19" Height="23.5" Stretch="Fill" Margin="372.771,405.982,0,0" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF64FF00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 15.8334,1.83337L 15.5,8.5L 16.6667,9.66669L 18.5,10.5001L 18.1667,18.5001L 17.8333,20.5001L 17.5,22.1667L 0.666656,23.0001L 0.833344,17.5001L 0.5,13.1667L 0.833344,9.83337L 2.5,8.66669L 4.83334,8.50006L 6.16666,6.66669L 6.33334,4.16669L 6.66666,2.16669L 9.5,0.500061L 14.5,0.666687L 15.8334,1.83337 Z "/>
<Area Name="DongCheng" Title="东城" ShowTitle="false" TitleMargin="330,184,0,0" Tip="东城区" DataExplain="8%" ShowDataExplain="false" Width="16.6666" Height="26.1667" Margin="387.604,404.316,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFF0064" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 0.5,2.33328L 5.33334,2.33328L 5.83328,0.833282L 9.16663,0.499969L 12.1666,3.33328L 13.3333,4.49997L 14,5.83328L 14.3333,10.6667L 15.8333,13.6667L 16.1666,23.3333L 14.8333,24.3333L 9.16663,24.3333L 8.16663,25.5L 4.16663,25.6666L 2.16663,24.6667L 2.49997,22.6667L 3.83328,13.5C 3.83328,13.5 2.5,11.5 1.49997,11.5C 0.499969,11.5 0.999969,5.66666 0.999969,5.66666L 0.5,2.33328 Z "/>
<Area Name="XuanWu" Title="宣武" ShowTitle="false" TitleMargin="330,184,0,0" Tip="宣武区" DataExplain="5%" ShowDataExplain="false" Width="19.6667" Height="14.6667" Margin="373.271,428.149,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF009664" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 0.666718,0.666687L 15.6667,0.5L 16.6667,2L 17.8333,3C 17.8333,3 18.6667,3 18.8333,3.66669C 19,4.33334 19.1667,11.5 19.1667,11.5L 18.3333,12.6667L 17.8333,14.1667L 6.5,14L 5.16666,13.3333L 4,9.16669L 3,7.33334L 0.5,6.83334L 0.666718,0.666687 Z "/>
<Area Name="ChongWen" Title="崇文" ShowTitle="false" TitleMargin="330,184,0,0" Tip="崇文区" DataExplain="6%" ShowDataExplain="false" Width="17.5" Height="15" Margin="389.271,427.982,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF5A0FC8" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 1.00003,0.5L 3.50003,1.5L 7,1.50003L 13.5,0.666687L 14.8333,0.666687L 16.1667,2.83337L 17,10.1667L 15.1667,12.1667L 13.1667,13L 5.33334,13.1667L 4.5,14.1667L 2.33334,14.5L 1.83334,11.8334L 3.66666,11.5L 3.33334,4.16669L 2.83334,3.16669L 1.66666,2.33337L 0.5,1.83337L 1.00003,0.5 Z "/>
<Area Name="TongZhou" Title="通州" ShowTitle="true" TitleMargin="470,460,0,0" Tip="通州区" DataExplain="4%" ShowDataExplain="true" Width="117" Height="159.75" Margin="430.271,383.149,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFC80FA0" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 20.75,4.00003L 21.75,0.500031L 27.5,3.00003L 31.75,3.75003L 38.5,7.00003L 45.75,7.00003L 54.75,3.25003L 60,3.75003L 63.5,4.50003L 65.5,4.75003L 67.25,7.50003L 67.75,16.75L 64.5,25.25L 69.5,29.25L 70.25,42L 70.5,50.5C 70.5,50.5 75.75,52.5 76,54.5C 76.25,56.5 78.75,54 78.75,54L 82.5,58.5L 88,64.25L 92.25,66L 95.75,66.5L 98.75,68.5L 98.75,65L 102.75,64.25L 105.5,65.25C 105.5,65.25 109.75,69 110.5,78C 111.25,87.0001 111.25,80.25 111.25,80.25L 114,81.5L 116.25,83.5L 116.5,87L 115.5,91.5L 108.25,92.75L 106.25,95.75L 106.5,99.5L 103.5,101.5L 104.5,108.75L 99.5,112.5L 98,116.75L 98.75,121C 98.75,121 103,123 103.25,124.5C 103.5,126 104,129.25 104,129.25L 101.5,131.5L 95.75,131.25L 91.5,134.25L 89.25,134.5L 88,137.5L 85.25,140L 85.25,150.75C 85.25,150.75 79,152.75 77.75,153C 76.5,153.25 71.5,158.25 71.5,158.25L 66.5,159.25L 61.75,152.75L 53.75,153.5L 53.25,147.25L 48,139.75L 47.75,134.5L 48.25,131.5L 46.5,130.25L 40.25,129.5L 38,130L 36.5,124.75L 34.25,124.5L 29.5,117L 29.5,112.75L 26,111.25L 22.25,111.25L 15.5,114.5L 3.75,115.25L 2.75,110.5L 3.75,108.25L 3.25,98.75L 1.25,97L 2.5,92.75L 2.75,90.5L 0.75,88.5L 0.75,82.5L 1,78.5L 0.5,75L 7.5,74.75L 16,74.75L 22,68.5L 24.75,62.5L 25.5,57.5L 25.25,51.75L 26.25,47.25L 24.25,45L 24.25,43.25L 27.75,40L 28.25,37.5L 31.25,30.5L 31.25,24L 30.75,18L 31.5,12.5L 28.75,8.00003L 25,7.25003L 20.75,4.00003 Z "/>
<Area Name="DaXing" Title="大兴" ShowTitle="true" TitleMargin="380,500,0,0" Tip="大兴区" DataExplain="6%" ShowDataExplain="true" Width="144.25" Height="142" Margin="339.771,455.399,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FF64FF00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 94,43L 104.75,42.5L 108.5,41.5L 112.5,39.75L 114.75,39.5L 118.75,39L 120.25,43L 120.5,45.75L 123.75,51L 126.75,51.75L 128.5,57.25L 135.5,56.75L 137.25,58.75L 139.25,58.25L 138.75,62.25L 138,68L 140.5,71.25L 143.25,73.5L 143.75,79.25C 143.75,79.25 140.75,85.75 139.25,86C 137.75,86.25 134.25,88 134.25,88L 131.5,85.75L 129.25,88L 117.25,88.75L 109.25,81L 108.5,78.25L 106.5,78.25L 102.25,78.25L 100,81.75C 100,81.75 97.5,86 95.5,86.75C 93.5,87.5 89.75,86.75 89.75,86.75L 89,90.25L 88.5,95.5L 83.75,101L 82.5,103.75L 76.5,102.75L 75.25,108L 72.25,110.25L 67.75,111.75L 64.25,116.25L 58.75,116.75L 57,114.5L 56.5,112.5L 54.75,112.5L 55.25,115.5L 57.5,117.75C 57.5,117.75 59.75,121 61.75,121C 63.75,121 62.25,123.75 62.25,123.75L 65.75,124L 68,126.5L 68.75,134L 67.75,139L 65,141.5L 60.75,141.25L 58.75,140.5L 52,140.75L 44.75,139.75L 39.75,141L 28.75,133.5L 29,131.75L 26.75,131.25L 23.25,127.25L 19.25,125.5L 14.5,125L 11.25,122.5L 11,113.5L 10.25,107.75L 7.24997,104L 5.99997,100.5L 6.74997,98.25L 5.49997,96L 4.99997,93.25L 4.74997,85.25L 3.49997,81.75L 2.74997,74L 2.49997,66.75L 0.5,63.25L 1.25,60.5L 2.49997,55.25L 3.49997,51.25L 5.24997,48.75L 5.74997,46.25L 8.24997,45.25L 9.24997,37L 12.75,30.25L 12.75,24L 11.25,19.75L 8.74997,19.75L 12.75,15.5L 14.5,13.25L 23.5,13.25L 25.5,15.5C 25.5,15.5 26,21.25 27.25,21.5C 28.5,21.75 30.25,20.75 30.25,20.75L 31.5,13L 35,11.25L 37.75,11.25L 43.5,16.5L 47.25,18L 48,19.5L 52.75,17.5L 59.5,15.75L 63.75,15L 60,9.74997L 56.25,9.49997L 51.25,11L 49.25,11.5L 47,9.24997C 47,9.24997 49.5,4.49997 52,5.24997C 54.5,5.99997 55,4.74997 55,4.74997L 57.5,4.74997L 59.25,1.99997L 63.75,0.999969C 63.75,0.999969 70.75,4.49997 72,4.74997C 73.25,4.99997 73.25,6.74997 73.25,6.74997L 76.25,6.24997L 89.75,0.499969C 89.75,0.499969 90.5,1.99997 90.75,3.49997C 91,4.99997 91.75,16 91.75,16L 92.75,18.25L 91.75,24.5L 93.75,26L 94,32.5L 94.25,38L 92.75,42.25L 94,43 Z "/>
<Area Name="FangShan" Title="房山" ShowTitle="true" TitleMargin="220,470,0,0" Tip="房山区" DataExplain="4%" ShowDataExplain="true" Width="234.266" Height="153.5" Margin="119.021,421.399,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFFFF00" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 147.75,9.99997L 151,12.5L 152.75,16.25L 160.75,17.25L 162.75,20.75L 162.75,24L 166,28.5L 175,29L 175.5,31.25L 179,31L 182.25,32L 182.75,34.25L 185,34.25L 185.75,37.75L 186.25,49.5C 186.25,49.5 188.75,50.75 189.75,51.25C 190.75,51.75 192.25,53 192.25,53L 197.75,52.5L 197,57.75L 201,59.5L 205.5,60L 212,54.75L 213.75,54L 216.75,51.25L 219,52.25L 222,47.25L 221.5,44.5L 224.25,39.5C 224.25,39.5 225.25,37.75 229.75,41.5C 234.25,45.25 233.75,45.25 233.75,45.25L 233.5,50L 230,52.5L 231.25,54L 233.25,58.25L 232.75,63.5L 230.25,71L 229,78.5L 226.5,80.5L 226.5,83.25L 224,85L 223.75,88.5L 223.5,93.75L 222.5,99.75L 223.75,107L 223.75,115.75L 225.25,118.25L 225.75,125.75C 225.75,125.75 224.5,130.25 222.5,130C 220.5,129.75 217.75,128.5 217.75,128.5L 215.5,129L 213.5,128L 213.5,126L 209.75,128C 209.75,128 204,130 202.75,131.75C 201.5,133.5 195.5,132 195.5,132L 193,130.25L 189.5,129.25L 187.25,129.75L 176.5,130L 167.25,125.25L 160.75,126.5L 157,123.5L 155,128.25C 155,128.25 152.5,131 151.5,131C 150.5,131 147.75,130.75 147.75,130.75L 144,126.5L 142.25,125.25L 141.75,122.25L 139.5,121L 140.5,128.25L 136.75,130.25L 134.25,134.75L 131.5,135.25L 129.25,137.5L 123.5,137.75L 118.75,140L 118,145L 117.5,150.25L 113,152.5L 110,153L 108.75,151.5L 104.75,152.25L 100.25,148.25L 96.75,147L 89,145.5L 90,142.25L 87,140L 79.5,130.5C 79.5,130.5 74.25,128 75.75,123.5C 77.25,119 76.5,119.75 76.5,119.75L 72.75,115L 69.25,117.25L 58.25,118.75L 49.25,119.5C 49.25,119.5 39.25,113.5 39.25,112C 39.25,110.5 37,115 37,115L 33.25,118.5C 33.25,118.5 26.5,120.25 25.75,116.75C 25,113.25 25,107 25,107L 28,103.25L 27.75,99.25L 26.25,98L 19.25,98C 19.25,98 17.75,96.75 17.25,93.25C 16.75,89.75 18.25,89.75 18.25,89.75L 17.75,83.25L 20.75,78L 21.25,66.25L 19.25,65L 13.5,65.25L 0.5,55.5L 0.75,47.5C 0.75,47.5 0.250008,44.75 8.25,45.5C 16.25,46.25 15,44.5 15,44.5L 17.25,41.75C 17.25,41.75 21.25,40 25,42.25C 28.75,44.5 35,42.25 35,42.25L 40.5,40.25L 42.25,39.5L 46.25,40.5L 47.5,38L 49.25,38.25L 57,28L 56.5,20C 56.5,20 60.5,17.75 63.5,18.25C 66.5,18.75 66,17.25 66,17.25C 66,17.25 67.75,14.25 70,14.25C 72.25,14.25 74.25,11 74.25,11C 74.25,11 78,7.99997 79.25,8.74997C 80.5,9.49997 84.75,6.99997 84.75,6.99997L 88.5,4.99997L 92.5,4.49997L 97.75,0.499969L 99.25,1.49997L 106.75,1.24997L 109,1.49997L 118.25,8.49997L 125,7.74997L 130.75,4.24997L 144.75,3.49997L 147,4.24997L 147.75,9.99997 Z "/>
<Area Name="FengTai" Title="丰台" ShowTitle="false" TitleMargin="330,184,0,0" Tip="丰台区" DataExplain="3%" ShowDataExplain="false" Width="114" Height="51.8333" Margin="299.938,429.982,0,0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFFFFFF" Fill="#FFFF0064" VerticalAlignment="Top" HorizontalAlignment="Left" Data="F1 M 70.1667,45.5L 71,44.1667L 70.8333,38.6667L 72,37.3333L 74.1667,36.8333L 74.5,35.8333L 78.1667,36.1667L 80.3333,38.1667L 82.8333,39.8333L 85.5,42.5L 87.1667,43L 87.5,44.6667L 89.8333,45L 90.3333,43.6667L 92.5,43.6667L 95.5,42.6667L 97.6667,41.5L 101.167,41.6667C 101.167,41.6667 99.8333,40.1667 100.833,40.3333C 101.833,40.5 103.833,40.5 103.833,40.5L 103.167,38.6667L 100.333,35L 94.8333,34.6667L 91.6667,36L 89,36.3333L 87.5,35L 87.5,33L 91,30.5C 91,30.5 91.3333,29.5 92,29.5C 92.6667,29.5 94.5,29.5 94.5,29.5L 94.8333,30.5L 96.8333,30.5L 98,28.6667L 98.5,26.1667L 104.333,25.8333L 104.5,24.5L 106.5,24.6667L 107,22.1667L 108.5,21L 112.5,20.8333L 113.333,19L 113.5,15.3333L 112,13.6667L 110,13.8333L 107.833,13.5L 107.5,11.3333L 106.5,9.5L 106.333,8.33334L 105.333,10.1667L 102.667,10.8333L 94.5,11.3333L 93.6667,12.3333L 91.6667,12.6667L 80,12L 78,11.5L 77.5,7.16666L 76,5.5L 73.6667,4.83334L 73.1667,2.5L 71.5,2.33334L 71,1.33334L 62.6667,2L 57.8333,1.16666L 55,2L 54.1667,0.5L 52,0.833344L 51.5,2L 50.6667,3L 47.1667,3.5L 46.6667,9.66666L 41.3333,9.66666L 39.6667,8.83334L 38.6667,7.5L 31.6667,8.16666L 29.5,5.5L 28.6667,4.33334L 27.1667,4.16666L 26.8333,5.33334L 21.8333,5.83334L 20.3333,6.66666L 17.8333,7.33334L 15.6667,8.16666L 14.1667,9L 11.1667,9.5L 9.83334,10.8333L 9.33334,12L 6,12.1667L 6,11L 2.5,11.1667L 2.5,10.1667L 1,10.1667L 0.5,12.6667C 0.5,12.6667 1.50003,11.6667 1.83334,13C 2.16666,14.3333 1.83334,20.8333 1.83334,20.8333L 0.666656,21.3333L 0.833344,23.8333L 1.16666,24.8333C 1.16666,24.8333 2.66669,23.6667 3.33334,24.8333C 4,26 4.5,27.8333 4.5,27.8333L 5.66666,29.8333L 5.66666,40.8333L 5.66666,42.3333L 9.5,42.3333L 10.1667,43.5L 12,44L 16.5,44.3333L 16.1667,49.1667L 19,50.3333L 20.3333,51.3333L 25.1667,50.8333L 29.1667,47.8333L 33.8333,45.1667L 35.8333,42.6667L 39,42.8333L 39.8333,40L 41.3333,37.6667L 41.3333,34.5L 43.1667,32.5L 44.1667,29.8333L 47,31.1667L 49.5,32.8333L 52.1667,34L 53.1667,37.1667L 53.6667,39.3333L 63.3333,38.1667L 64.6667,40.3333L 65.6667,43.3333L 66.5,45.8333L 70.1667,45.5 Z "/>
</Chart>
Main页面XAML
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="CmjCharts.MainPage"
Width="1000" Height="600" Loaded="UserControl_Loaded">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="txtblkTitle" Grid.ColumnSpan="3" Grid.Column="0" Grid.Row="0" Text="Cmj Charts" TextAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Portable User Interface" />
<Canvas x:Name="cvsMain" Grid.Column="0" Grid.Row="1"></Canvas>
<Grid x:Name="grdLegend" Grid.Column="2" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
</Grid>
</Grid>
</UserControl>
Main页面CS
![](https://i-blog.csdnimg.cn/blog_migrate/cdec0645add3fc3c328197dda5c76203.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/81178cc93a2a3bb5048d90d76e7ec935.gif)
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Windows.Browser;
using CmjCharts.Charts;
using CmjCharts.Entity;
using CmjCharts.EntityAccess;
using CmjCharts.Config;
namespace CmjCharts
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Init();
}
private void Init()
{
ChartContextMenuAccess.ChartElement = this.LayoutRoot;
CreateContextMenu();
ExposeInterface();
GenerateChart();
}
private void GenerateChart()
{
ChartAccess chartAccess = new ChartAccess();
Chart chart = chartAccess.Chart;
this.txtblkTitle.SetBinding(TextBlock.TextProperty, new Binding("Title") { Source = chart, Mode = BindingMode.OneWay });
AreaAccess areaAccess = new AreaAccess();
int row=0;
foreach (Area ar in areaAccess.Areas)
{
Path pt = new Path();
pt.Name = ar.Name;
Binding dataBinding = new Binding("Data") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.DataProperty, dataBinding);
Binding marginBinding = new Binding("Margin") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.MarginProperty, marginBinding);
Binding withBinding = new Binding("Width") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.WidthProperty, withBinding);
Binding heightBinding = new Binding("Height") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.HeightProperty, heightBinding);
Binding horizontalBinding = new Binding("HorizontalAlignment") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.HorizontalAlignmentProperty, horizontalBinding);
Binding verticalBinding = new Binding("VerticalAlignment") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.VerticalAlignmentProperty, verticalBinding);
Binding stretchBinding = new Binding("Stretch") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.StretchProperty, stretchBinding);
Binding strokeBinding = new Binding("Stroke") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.StrokeProperty, strokeBinding);
Binding fillBinding = new Binding("Fill") { Source = ar, Mode = BindingMode.OneWay };
pt.SetBinding(Path.FillProperty, fillBinding);
ToolTipService.SetToolTip(pt, ar.Tip);
string[] mgs = ar.TitleMargin.Split(',');
StackPanel stkpnAreaFlag = new StackPanel();
stkpnAreaFlag.Margin = new Thickness(double.Parse(mgs[0]), double.Parse(mgs[1]), double.Parse(mgs[2]), double.Parse(mgs[3]));
TextBlock txtblkAreaTitle = new TextBlock();
txtblkAreaTitle.TextAlignment = TextAlignment.Center;
Binding titleBinding = new Binding("Title") { Source = ar, Mode = BindingMode.OneWay };
txtblkAreaTitle.SetBinding(TextBlock.TextProperty, titleBinding);
stkpnAreaFlag.Children.Add(txtblkAreaTitle);
if (!ar.ShowTitle)
{
txtblkAreaTitle.Visibility = Visibility.Collapsed;
}
TextBlock txtblkDataExplain = new TextBlock();
txtblkDataExplain.TextAlignment = TextAlignment.Center;
Binding dataExplainBinding = new Binding("DataExplain") { Source = ar, Mode = BindingMode.OneWay };
txtblkDataExplain.SetBinding(TextBlock.TextProperty, dataExplainBinding);
stkpnAreaFlag.Children.Add(txtblkDataExplain);
if (!ar.ShowDataExplain)
{
txtblkDataExplain.Visibility = Visibility.Collapsed;
}
grdLegend.RowDefinitions.Add(new RowDefinition());
Rectangle rctg = new Rectangle();
rctg.Width = ChartConstant.LegendWidth;
rctg.Height = ChartConstant.LegendHeight;
rctg.SetBinding(Rectangle.StretchProperty, stretchBinding);
rctg.SetBinding(Rectangle.StrokeProperty, strokeBinding);
rctg.SetBinding(Rectangle.FillProperty, fillBinding);
Grid.SetRow(rctg, row);
Grid.SetColumn(rctg, 0);
grdLegend.Children.Add(rctg);
TextBlock txtblkLegendTitle = new TextBlock();
txtblkLegendTitle.VerticalAlignment = VerticalAlignment.Center;
txtblkLegendTitle.SetBinding(TextBlock.TextProperty, titleBinding);
Grid.SetRow(txtblkLegendTitle, row);
Grid.SetColumn(txtblkLegendTitle, 1);
grdLegend.Children.Add(txtblkLegendTitle);
pt.Tag = txtblkAreaTitle;
pt.Cursor = Cursors.Hand;
pt.MouseEnter += new MouseEventHandler(pt_MouseEnter);
pt.MouseLeave += new MouseEventHandler(pt_MouseLeave);
this.cvsMain.Children.Add(pt);
this.cvsMain.Children.Add(stkpnAreaFlag);
++row;
}
for(int i=row;i<10;++i)
{
grdLegend.RowDefinitions.Add(new RowDefinition());
}
}
private void ExposeInterface()
{
HtmlPage.RegisterCreateableType("ChartAccess", typeof(ChartAccess));
HtmlPage.RegisterCreateableType("AreaAccess", typeof(AreaAccess));
ChartTipService tipService = new ChartTipService();
HtmlPage.RegisterScriptableObject("ChartTipService", tipService);
}
private void CreateContextMenu()
{
ContextMenu contextMenu = new ContextMenu();
foreach (ChartContextMenu menu in ChartContextMenuAccess.GetContextMenus())
{
MenuItem menuItem=null;
menuItem = new MenuItem();
menuItem.Name = menu.Name;
menuItem.Header = menu.Header;
menuItem.Click += new RoutedEventHandler(menuItem_Click);
contextMenu.Items.Add(menuItem);
}
ContextMenuService.SetContextMenu(this.LayoutRoot, contextMenu);
}
void menuItem_Click(object sender, RoutedEventArgs e)
{
MenuItem menu = sender as MenuItem;
ChartContextMenuAccess.MenuClick(menu.Name);
}
/// <summary>
/// 光标移出此区域时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void pt_MouseLeave(object sender, MouseEventArgs e)
{
ScaleTransform st = new ScaleTransform();
st.ScaleX = 1;
st.ScaleY = 1;
Path pt = sender as Path;
pt.RenderTransform = st;
TextBlock txtblk = pt.Tag as TextBlock;
txtblk.RenderTransform=st;
}
/// <summary>
/// 光标移动到此区域时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void pt_MouseEnter(object sender, MouseEventArgs e)
{
ScaleTransform st = new ScaleTransform();
st.ScaleX = ChartConstant.AreaZoomOffset;
st.ScaleY = ChartConstant.AreaZoomOffset;
Path pt = sender as Path;
pt.RenderTransform = st;
TextBlock txtblk = pt.Tag as TextBlock;
txtblk.RenderTransform = st;
}
}
}
三、使用效果
最后看一下使用过截图吧
图表展示
鼠标移动上之后的效果(区域放大并显示提示信息)
设置图表标题
设置区域颜色
设置区域标题
设置数据
设置提示信息
![]() | 本作品采用知识共享署名 2.5 中国大陆许可协议进行许可,欢迎转载,演绎或用于商业目的。但转载请注明来自崔江涛(KenshinCui),并包含相关链接。 |