${iServer2_Theme_ThemeGraph_Title}

${iServer2_Theme_ThemeGraph_Description}

Inheritance: Theme
        //制作统计专题图
        private void commit_Click(object sender, RoutedEventArgs e)
        {
            //设置了二个子项
            ThemeGraphItem item1 = new ThemeGraphItem()
            {
                Caption = "面积",
                GraphExpression = "SmArea",
                UniformStyle = new ServerStyle() { FillForeColor = new ServerColor(255, 209, 173) },
            };

            ThemeGraphItem item2 = new ThemeGraphItem()
            {
                Caption = "人口",
                GraphExpression = "Pop_1994",
                UniformStyle = new ServerStyle() { FillForeColor = new ServerColor(233, 150, 127) },
            };

            SuperMap.Web.iServerJava2.ThemeGraph themeGraph = new SuperMap.Web.iServerJava2.ThemeGraph()
            {
                Items = new List<ThemeGraphItem>() { item1, item2 },
                AxesColor = new ServerColor(255, 0, 0),
                GraduatedMode = GraduatedMode.Constant,
                GraphTextFormat = GraphTextFormat.Caption,
                GraphType = GraphType.Bar3D,
                IsGraphTextDisplayed = true,
                IsFlowEnabled = false,
                IsLeaderLineDisplayed = true,
                LeaderLineStyle = new ServerStyle
                {
                    LineColor = new ServerColor { Red = 0, Green = 255, Blue = 0 }
                },
            };

            ThemeParameters parameters = new ThemeParameters()
             {
                 LayerName = "World@world",
                 MapName = "World",
                 Theme = themeGraph,
             };

            //与服务器交互
            ThemeService themeService = new ThemeService(url) { DisableClientCaching = true };
            themeService.ProcessAsync(parameters);
            themeService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeService_ProcessCompleted);
            themeService.Failed += new EventHandler<ServiceFailedEventArgs>(themeService_Failed);
        }
Ejemplo n.º 2
0
        internal static string ToJson(ThemeGraph themeGraph)
        {
            if (themeGraph == null)
            {
                return null;
            }
            string json = "{";
            List<string> list = new List<string>();

            if (themeGraph.Items != null && themeGraph.Items.Count > 0)
            {
                List<string> tempTGI = new List<string>();
                foreach (ThemeGraphItem item in themeGraph.Items)
                {
                    tempTGI.Add(ThemeGraphItem.ToJson(item));
                }
                list.Add(string.Format("\"items\":[{0}]", string.Join(",", tempTGI.ToArray())));
            }
            else
            {
                list.Add(string.Format("\"items\":[]"));
            }

            if (!string.IsNullOrEmpty(themeGraph.OffsetX))
            {
                list.Add(string.Format("\"offsetX\":\"{0}\"", themeGraph.OffsetX));
            }

            if (!string.IsNullOrEmpty(themeGraph.OffsetY))
            {
                list.Add(string.Format("\"offsetY\":\"{0}\"", themeGraph.OffsetY));
            }
            list.Add(string.Format("\"barWidth\":{0}", themeGraph.BarWidth));
            list.Add(string.Format("\"startAngle\":{0}", themeGraph.StartAngle));
            list.Add(string.Format("\"roseAngle\":{0}", themeGraph.RoseAngle));
            list.Add(string.Format("\"isFlowEnabled\":{0}", themeGraph.IsFlowEnabled));

            if (themeGraph.LeaderLineStyle != null)
            {
                list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(themeGraph.LeaderLineStyle)));
            }
            else
            {
                list.Add(string.Format("\"leaderLineStyle\":null"));
            }

            list.Add(string.Format("\"isLeaderLineDisplayed\":{0}", themeGraph.IsLeaderLineDisplayed));
            list.Add(string.Format("\"isNegativeDisplayed\":{0}", themeGraph.IsNegativeDisplayed));
            if (ServerColor.ToJson(themeGraph.AxesColor) != null)
            {
                list.Add(string.Format("\"axesColor\":{0}", ServerColor.ToJson(themeGraph.AxesColor)));
            }
            list.Add(string.Format("\"isAxesDisplayed\":{0}", themeGraph.IsAxesDisplayed));
            if (themeGraph.AxesTextStyle != null)
            {
                list.Add(string.Format("\"axesTextStyle\":{0}", ServerTextStyle.ToJson(themeGraph.AxesTextStyle)));
            }
            list.Add(string.Format("\"isAxesTextDisplayed\":{0}", themeGraph.IsAxesTextDisplayed));
            list.Add(string.Format("\"isAxesGridDisplayed\":{0}", themeGraph.IsAxesGridDisplayed));
            if (themeGraph.GraphTextStyle != null)
            {
                list.Add(string.Format("\"graphTextStyle\":{0}", ServerTextStyle.ToJson(themeGraph.GraphTextStyle)));
            }
            list.Add(string.Format("\"graphTextFormat\":{0}", (int)themeGraph.GraphTextFormat));
            list.Add(string.Format("\"isGraphTextDisplayed\":{0}", themeGraph.IsGraphTextDisplayed));
            list.Add(string.Format("\"minGraphSize\":{0}", themeGraph.MinGraphSize));
            list.Add(string.Format("\"maxGraphSize\":{0}", themeGraph.MaxGraphSize));
            list.Add(string.Format("\"isGraphSizeFixed\":{0}", themeGraph.IsGraphSizeFixed));
            list.Add(string.Format("\"graduatedMode\":{0}", (int)themeGraph.GraduatedMode));

            list.Add(string.Format("\"themeType\":3"));

            list.Add(string.Format("\"graphType\":{0}", (int)themeGraph.GraphType));

            json += string.Join(",", list.ToArray());
            json += "}";

            return json;
        }
Ejemplo n.º 3
0
        /// <summary>${iServer2_ThemeGraph_method_FromJson_D}</summary>
        /// <returns>${iServer2_ThemeGraph_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServer2_ThemeGraph_method_FromJson_param_jsonObject}</param>
        public static ThemeGraph FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            ThemeGraph result = new ThemeGraph()
             {
                 AxesColor = ServerColor.FromJson((JsonObject)jsonObject["axesColor"]),
                 AxesTextStyle = ServerTextStyle.FromJson((JsonObject)jsonObject["axesTextStyle"]),
                 BarWidth = (double)jsonObject["barWidth"],
                 GraphTextStyle = ServerTextStyle.FromJson((JsonObject)jsonObject["graphTextStyle"]),
                 IsAxesDisplayed = (bool)jsonObject["isAxesDisplayed"],
                 IsAxesGridDisplayed = (bool)jsonObject["isAxesGridDisplayed"],
                 IsAxesTextDisplayed = (bool)jsonObject["isAxesTextDisplayed"],
                 IsFlowEnabled = (bool)jsonObject["isFlowEnabled"],
                 IsGraphSizeFixed = (bool)jsonObject["isGraphSizeFixed"],
                 IsGraphTextDisplayed = (bool)jsonObject["isGraphTextDisplayed"],
                 IsLeaderLineDisplayed = (bool)jsonObject["isLeaderLineDisplayed"],
                 IsNegativeDisplayed = (bool)jsonObject["isNegativeDisplayed"],
                 LeaderLineStyle = ServerStyle.FromJson((JsonObject)jsonObject["leaderLineStyle"]),
                 MaxGraphSize = (double)jsonObject["maxGraphSize"],
                 MinGraphSize = (double)jsonObject["minGraphSize"],
                 OffsetX = (string)jsonObject["offsetX"],
                 OffsetY = (string)jsonObject["offsetY"],
                 RoseAngle = (double)jsonObject["roseAngle"],
                 StartAngle = (double)jsonObject["StartAngle"],
             };

            if (jsonObject["graduatedMode"] != null)
            {
                result.GraduatedMode = (GraduatedMode)(int)jsonObject["graduatedMode"];
            }
            if (jsonObject["graphTextFormat"] != null)
            {
                result.GraphTextFormat = (GraphTextFormat)(int)jsonObject["graphTextFormat"];
            }
            if (jsonObject["graphType"] != null)
            {
                result.GraphType = (GraphType)(int)jsonObject["graphType"];
            }
            if (jsonObject["items"] != null)
            {
                result.Items = new List<ThemeGraphItem>();
                for (int i = 0; i < jsonObject["items"].Count; i++)
                {
                    result.Items.Add(ThemeGraphItem.FromJson((JsonObject)jsonObject["items"][i]));
                }
            }

            return result;
        }