protected override async Task <AdUserOutputModel[]> Execute(ClaimsPrincipal principal, CancellationToken cancellationToken) { if (_cache != null && _timestamp.AddHours(4) > DateTime.Now) { return(_cache); } var config = new GraphConfiguration( _configuration["Graph:ClientId"], _configuration["Graph:TenantId"], _configuration["Graph:ClientSecret"]); var f = new GraphFacade(config); var users = await f.GetUsers(); var data = users .Where(_ => _.UserPrincipalName.Contains("@")) .Select(_ => new AdUserOutputModel { LastName = _.Surname, FirstName = _.GivenName, DisplayName = _.DisplayName, Code = _.UserPrincipalName.Split('@')[0] }).ToArray(); _timestamp = DateTime.Now; _cache = data; return(data); }
public DemoForm() { InitializeComponent(); GraphConfiguration configuration = new GraphConfiguration(); configuration.AxisXConfiguration.MajorGrid.LineColor = Color.FromArgb(200, 111, 135); configuration.Palette.Add(new PaletteItem(){Color = Color.Firebrick, HatchStyle = ChartHatchStyle.BackwardDiagonal}); configuration.Palette.Add(new PaletteItem() { Color = Color.Black, HatchStyle = ChartHatchStyle.SolidDiamond }); configuration.GraphSource = new XmlFileGraphSource(){DateTag = "aaa"}; configuration.SaveToXml("qwe.xml"); Stopwatch sw = new Stopwatch(); sw.Start(); GraphControl gc = graphControl;// new GraphControl(); gc.SetConfiguration("graphConfig.xml", Size, null); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data extraction: " + sw.ElapsedMilliseconds); #endif sw.Reset(); sw.Start(); gc.SaveImage("temp.jpg", ChartImageFormat.Jpeg); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data render by Chart control: " + sw.ElapsedMilliseconds); #endif }
private Config(ConfigurationMutable config) { Preconditions.NotNull(config, "config"); PHPSettings = new PHPConfiguration(config.PHPConfiguration.PHPPath, config.PHPConfiguration.PHPParsePath, config.PHPConfiguration.PHPExts); GraphSettings = new GraphConfiguration(config.GraphConfiguration.GraphvizPath, config.GraphConfiguration.GraphvizArguments); ComponentSettings = new ComponentConfiguration(config.ComponentSettings.ComponentFolder, config.ComponentSettings.IncludeComponents); FuncSpecSettings = new FuncSpecConfiguration(config.FuncSpecSettings.PHPSpecs, config.FuncSpecSettings.ExtensionSpecs); }
private Config(ConfigurationMutable config) { Preconditions.NotNull(config, "config"); PHPSettings = new PHPConfiguration(config.PHPConfiguration.PHPPath, config.PHPConfiguration.PHPParsePath, config.PHPConfiguration.PHPExts); GraphSettings = new GraphConfiguration(config.GraphConfiguration.GraphvizPath, config.GraphConfiguration.GraphvizArguments); ComponentSettings = new ComponentConfiguration(config.ComponentSettings.ComponentFolder, config.ComponentSettings.IncludeComponents); FuncSpecSettings = new FuncSpecConfiguration(config.FuncSpecSettings.PHPSpecs, config.FuncSpecSettings.ExtensionSpecs); }
public DemoForm() { InitializeComponent(); GraphConfiguration configuration = new GraphConfiguration(); configuration.AxisXConfiguration.MajorGrid.LineColor = Color.FromArgb(200, 111, 135); configuration.Palette.Add(new PaletteItem() { Color = Color.Firebrick, HatchStyle = ChartHatchStyle.BackwardDiagonal }); configuration.Palette.Add(new PaletteItem() { Color = Color.Black, HatchStyle = ChartHatchStyle.SolidDiamond }); configuration.GraphSource = new XmlFileGraphSource() { DateTag = "aaa" }; configuration.SaveToXml("qwe.xml"); Stopwatch sw = new Stopwatch(); sw.Start(); GraphControl gc = graphControl; // new GraphControl(); gc.SetConfiguration("graphConfig.xml", Size, null); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data extraction: " + sw.ElapsedMilliseconds); #endif sw.Reset(); sw.Start(); gc.SaveImage("temp.jpg", ChartImageFormat.Jpeg); sw.Stop(); #if STOPWATCH MessageBox.Show("Time spent for data render by Chart control: " + sw.ElapsedMilliseconds); #endif }
protected void Page_Load(object sender, EventArgs e) { _pageIndex = -1; if (!IsPostBack) { try { _root = WebDialogueContext.GetDialogueParameter<CKeyNLR>("Root", WAFContext.Session.CompleteKey(WAFContext.Session.SiteId)); _config = WebDialogueContext.GetDialogueParameter<GraphConfiguration>("Configuration", new GraphConfiguration()); ViewState["GraphConfiguration"] = _config; } catch { _root = WAFContext.Session.CompleteKey(WAFContext.Session.SiteId); _config = new GraphConfiguration(); ViewState["GraphConfiguration"] = _config; } } else { string[] s = Request["selectedNodeId"].Split('.'); if (s[0] == "OPEN") { _root = WAFContext.Session.CompleteKey(int.Parse(s[1])); WAFContext.Session.QueUIAction(new UIActionEdit(WAFContext.Session.CompleteKeyC(_root))); WebDialogueContext.CloseExchange(); } else { _root = WAFContext.Session.CompleteKey(int.Parse(s[0])); if (s.Length > 1) _pageIndex = int.Parse(s[1]); } _config = (GraphConfiguration)ViewState["GraphConfiguration"]; } //_config.PlugIn = new filter(); // _config.Depth = 3; //_config.UseIcons = true; //_config.Arrows = false; //_config.LinkTypes.Add(NodeLinkType.InternalNodeRelation); //_config.RelationIds.Add(WAF.Engine.Content.Native.RelHierarchical.RelationId); MainButton open = new MainButton(); MainButton openInModule = new MainButton(); MainButton openInWindow = new MainButton(); this.Controls.Add(open); this.Controls.Add(openInModule); this.Controls.Add(openInWindow); open.Click += new EventHandler(open_Click); openInModule.Click += new EventHandler(openInModule_Click); openInWindow.Click += new EventHandler(openInWindow_Click); open.Text = "Open"; openInModule.Text = "Open in module"; openInWindow.Text = "Open in window"; WebDialogueContext.AddDialogueButton(open); WebDialogueContext.AddDialogueButton(openInModule); WebDialogueContext.AddDialogueButton(openInWindow); MainButton moreLevels = new MainButton(); this.Controls.Add(moreLevels); moreLevels.Text = "+ depth"; moreLevels.Click += new EventHandler(moreLevels_Click); WebDialogueContext.AddDialogueButton(moreLevels); MainButton lessLevels = new MainButton(); this.Controls.Add(lessLevels); lessLevels.Text = " - depth"; lessLevels.Click += new EventHandler(lessLevels_Click); WebDialogueContext.AddDialogueButton(lessLevels); }
/// <summary> /// Draw graph according passed configuration /// </summary> /// <param name="configuration">Graph configuration</param> /// <param name="ownerSize">Owner size.</param> /// <param name="context">Configuration context.</param> public void SetConfiguration(GraphConfiguration configuration, Size ownerSize, object context) { this.chart.Series.Clear(); this.SetupGraph(configuration); switch (configuration.GraphType.Value) { case GraphTypeEnum.NameDateStackedColumn: case GraphTypeEnum.NameDateLine: this.DrawNameDateGraph(new GraphData(configuration, context), configuration); break; case GraphTypeEnum.NamedLine: this.DrawNamedGraph(new GraphData(configuration, context), configuration); break; case GraphTypeEnum.GanttDiagram: this.DrawGantt(new GanttGraphData(configuration, context), configuration); break; default: this.DrawSimpleGraph(new GraphData(configuration, context), configuration); break; } foreach (Series series in this.chart.Series) { GraphSeriesSettings seriesState = this._stateSettings.GetSeriesSettings(series.Name); series.Enabled = seriesState.Visible; if (!seriesState.Visible && configuration.GraphType.Value == GraphTypeEnum.GanttDiagram) { this.RevalueAxisY(series); } } if (configuration.GraphType == GraphTypeEnum.NameDateStackedColumn || configuration.GraphType == GraphTypeEnum.NameDateLine || configuration.GraphType == GraphTypeEnum.NamedLine ) { this.HideUnnecessaryXAxisZeroLabel(); } }
private static void MonthWeekDaySort( GraphData data, GraphConfiguration configuration, string name, Series series, ValGroup sort ) { int i = 0; int point = 0; double? value = null; for (DateTime date = data.FromDate.Date; date <= data.ToDate.Date; date = date.Date.AddDays(1)) { DateTime labelDate = date; if (sort == ValGroup.Week) { labelDate = labelDate.PreviousMonday(); } value = data.GetValueForNameAndDate(name, date, data.Configuration.ItemsConfiguration.Unit, sort); if (value != null && value >= 1.0d) { point = 0; switch (sort) { case ValGroup.Month: point = series.Points.AddXY(i, value.Value); series.Points[point].AxisLabel = date.Date.ToString("MM.yyyy"); break; case ValGroup.Day: point = series.Points.AddXY(date, value.Value); series.Points[point].AxisLabel = date.Date.ToString("dd.MM.yyyy"); break; case ValGroup.Week: point = series.Points.AddXY(labelDate, value.Value); series.Points[point].AxisLabel = labelDate.Date.ToString("dd.MM.yyyy"); break; } } else if (value != null && value < 1.0d) { } else if (configuration.GraphType.Value == GraphTypeEnum.NameDateStackedColumn) { switch (sort) { case ValGroup.Month: int t = series.Points.AddXY(i, 0.0d); series.Points[t].AxisLabel = date.Date.ToString("MM.yyyy"); while (date.AddDays(1).Day != 1) { date = date.AddDays(1); } break; case ValGroup.Day: t = series.Points.AddXY(date, 0.0d); series.Points[t].AxisLabel = date.Date.ToString("dd.MM.yyyy"); break; case ValGroup.Week: if (date.DayOfWeek == DayOfWeek.Monday) { t = series.Points.AddXY(labelDate, 0.0d); series.Points[t].AxisLabel = labelDate.Date.ToString("dd.MM.yyyy"); } break; } } i++; } }
private static void MinuteSecondSort( GraphData data, GraphConfiguration configuration, ValGroup sortGroup, string name, Series series ) { int i = 0; int point = 0; double? value = null; for (DateTime date = data.FromDate; date <= data.ToDate; date = sortGroup == ValGroup.Minute ? date.AddMinutes(1) : date.AddSeconds(1)) { value = data.GetValueForNameAndDate(name, date, data.Configuration.ItemsConfiguration.Unit, sortGroup); if (value != null && value >= 1.0d) { point = series.Points.AddXY(i, value.Value); series.Points[point].AxisLabel = date.ToString("HH:mm" + (sortGroup == ValGroup.Minute ? "" : ":ss") + " dd.MM.yy"); } else if (value != null && value < 1.0d) { } else if (configuration.GraphType.Value == GraphTypeEnum.NameDateStackedColumn) { point = series.Points.AddXY(i, 0.0d); series.Points[point].AxisLabel = date.ToString("HH:mm" + (sortGroup == ValGroup.Minute ? "" : ":ss") + " dd.MM.yy"); } i++; } }
private void DrawSimpleXYGraph(List<PlainItem> values, GraphConfiguration configuration) { var linesData = values.GroupBy(v => v.Name); int i = 0; foreach (var items in linesData) { var series = new Series(); SetupSeries(series, configuration, i++); series.IsXValueIndexed = false; series.ChartType = SeriesChartType.Line; series.Name = items.Key; this.chart.Series.Add(series); this.chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; if (configuration.AxisXConfiguration.Interval.HasValue) { this.chart.ChartAreas[0].AxisX.Interval = configuration.AxisXConfiguration.Interval.Value; } this.chart.ChartAreas[0].AxisX.LabelStyle.Format = configuration.AxisXConfiguration.Format; this.chart.FormatNumber += chart_FormatNumber; var orderedItems = items.OrderBy(itm => itm.XValue); foreach (var item in orderedItems) { var x = item.Name != null ? (object)item.Name : item.DateTime; var y = GraphData.FormatNumericValue(configuration.ItemsConfiguration.Unit, item.YValue); double fx = GraphData.FormatNumericValue(configuration.ItemsConfiguration.Unit, item.XValue.Value); series.Points.AddXY(fx, y); } } }
private void SetupChartMargin(GraphConfiguration configuration) { // // AxisX.IsMarginVisible // if (this.chart.ChartAreas[0].AxisX.LabelStyle.Enabled) { this.chart.ChartAreas[0].AxisX.IsMarginVisible = true; // top this.chart.ChartAreas[0].InnerPlotPosition.Y = configuration.GraphMargins.GetTop(); // bottom this.chart.ChartAreas[0].InnerPlotPosition.Height = configuration.GraphMargins.GetBottom(); } else { this.chart.ChartAreas[0].AxisX.IsMarginVisible = false; // top this.chart.ChartAreas[0].InnerPlotPosition.Y = 0.0f; // bottom this.chart.ChartAreas[0].InnerPlotPosition.Height = 100.0f; } // // AxisY.IsMarginVisible // if (this.chart.ChartAreas[0].AxisY.LabelStyle.Enabled) { this.chart.ChartAreas[0].AxisY.IsMarginVisible = true; // left this.chart.ChartAreas[0].InnerPlotPosition.X = configuration.GraphMargins.GetLeft(); // right this.chart.ChartAreas[0].InnerPlotPosition.Width = configuration.GraphMargins.GetRight(); } else { this.chart.ChartAreas[0].AxisY.IsMarginVisible = false; // left this.chart.ChartAreas[0].InnerPlotPosition.X = 0.0f; // right this.chart.ChartAreas[0].InnerPlotPosition.Width = 100.0f; } /* // left this.chart.ChartAreas[0].InnerPlotPosition.X = configuration.GraphMargins.GetLeft(); // right this.chart.ChartAreas[0].InnerPlotPosition.Width = configuration.GraphMargins.GetRight(); // top this.chart.ChartAreas[0].InnerPlotPosition.Y = configuration.GraphMargins.GetTop(); // bottom this.chart.ChartAreas[0].InnerPlotPosition.Height = configuration.GraphMargins.GetBottom(); */ this.chart.ChartAreas[0].Position.X = this.chart.ChartAreas[0].InnerPlotPosition.X; if (this.chart.ChartAreas[0].AxisY.LabelStyle.Enabled) { this.chart.ChartAreas[0].Position.Y = 1; } else { this.chart.ChartAreas[0].Position.Y = 0; } this.chart.ChartAreas[0].Position.Width = this.chart.ChartAreas[0].InnerPlotPosition.Width; if (this.chart.ChartAreas[0].AxisY.LabelStyle.Enabled) { this.chart.ChartAreas[0].Position.Height = 98; } else { this.chart.ChartAreas[0].Position.Height = 100; } if (!configuration.LegendConfiguration.GraphicOverlap) { this.chart.ChartAreas[0].Position.Auto = true; } else { this.chart.ChartAreas[0].Position.Auto = false; } this.chart.Padding = new Padding(0, 0, 0, 0); /* var chartArea = this.chart.ChartAreas[0]; chartArea.AxisX.IsMarginVisible = true; chartArea.AxisY.IsMarginVisible = true; chartArea.InnerPlotPosition = new ElementPosition( -0.5f, -0.5f, configuration.GraphMargins.GetRight() + 3, configuration.GraphMargins.GetBottom() + 3 ); */ }
protected void Page_Load(object sender, EventArgs e) { _config = new GraphConfiguration(Request["Configuration"]); }
private void DrawNameDateGraph(GraphData data, GraphConfiguration configuration) { int i = 0; int countPoints = -1; bool flag = false; var sortGroup = ((XmlFileGraphSource) configuration.GraphSource).ValueGroup; foreach (string name in data.Names) { var series = new Series(name) { IsXValueIndexed = true }; SetupSeries(series, configuration, i); switch (configuration.GraphType.Value) { case GraphTypeEnum.NameDateStackedColumn: series.ChartType = SeriesChartType.StackedColumn; break; case GraphTypeEnum.NameDateLine: series.ChartType = SeriesChartType.Line; break; } this.chart.Series.Add(series); switch (sortGroup) { case ValGroup.Day: case ValGroup.Week: case ValGroup.Month: default: MonthWeekDaySort(data, configuration, name, series, sortGroup); break; case ValGroup.Hour: HourSort(data, configuration, sortGroup, name, series); break; case ValGroup.Minute: case ValGroup.Second: MinuteSecondSort(data, configuration, sortGroup, name, series); break; } countPoints = countPoints == -1 ? series.Points.Count : -1; flag = flag || (countPoints != series.Points.Count); i++; } if (flag) { foreach (var chartItems in this.chart.Series) { chartItems.IsXValueIndexed = false; } } }
private void DrawGantt(GanttGraphData data, GraphConfiguration configuration) { this.chart.Series.Clear(); DrawGantt(this.chart, data.Jobs); }
private static void SetupAxisX(Axis axis, GraphConfiguration configuration) { SetupAxis(axis, configuration.AxisXConfiguration); axis.Interval = configuration.AxisXConfiguration.Interval ?? 1; switch (configuration.AxisXConfiguration.AxisXLabelFilter.Value) { case AxisXLabelFilter.All: break; case AxisXLabelFilter.AllDays: axis.IntervalType = DateTimeIntervalType.Days; break; case AxisXLabelFilter.StartOfMonth: axis.IntervalType = DateTimeIntervalType.Months; break; case AxisXLabelFilter.StartOfWeek: axis.IntervalType = DateTimeIntervalType.Weeks; axis.IntervalOffsetType = DateTimeIntervalType.Days; axis.IntervalOffset = configuration.FirstWeekDay - DayOfWeek.Sunday; break; default: throw new ArgumentException( "Invalid AxisXLabelFilter value", configuration.AxisXConfiguration.AxisXLabelFilter.ToString() ); } }
private static void SetupSeries(Series series, GraphConfiguration configuration, int index) { if (configuration.Palette.Count > 0) { PaletteItem item = configuration.Palette[index % configuration.Palette.Count]; series.BackHatchStyle = item.HatchStyle; series.Color = item.Color; } }
private static void SetupPoint(DataPoint point, GraphConfiguration configuration, int index) { if (configuration.Palette.Count > 0) { PaletteItem item = configuration.Palette[index % configuration.Palette.Count]; point.BackHatchStyle = item.HatchStyle; point.Color = item.Color; } }
private void SetupGraph(GraphConfiguration configuration) { this._graphType = configuration.GraphType; // set background color for the graph as transparent this.chart.BackColor = Color.Transparent; this.chart.ChartAreas[0].BorderWidth = configuration.AxisXConfiguration.MajorGrid.Enabled ? configuration.AxisXConfiguration.MajorGrid.LineWidth : 0; this.chart.ChartAreas[0].BorderColor = configuration.AxisXConfiguration.MajorGrid.LineColor; this.chart.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid; switch (configuration.GraphType.Value) { case GraphTypeEnum.GanttDiagram: this.chart.ChartAreas[0].AxisX.Enabled = AxisEnabled.False; SetupAxisX(this.chart.ChartAreas[0].AxisY, configuration); this.chart.FormatNumber += chart_FormatNumber; break; default: SetupAxisX(this.chart.ChartAreas[0].AxisX, configuration); SetupAxisY(configuration.AxisYConfiguration); break; } this.chart.Legends[0].Enabled = configuration.LegendConfiguration.Enabled; this.chart.Legends[0].Docking = configuration.LegendConfiguration.Docking; this.chart.Legends[0].Alignment = configuration.LegendConfiguration.Alignment; if (configuration.LegendConfiguration.GraphicOverlap) { // this.chart.Legends[0].Alignment = StringAlignment.Center; // this.chart.Legends[0].Docking = Docking.Top; this.chart.Legends[0].DockedToChartArea = this.chart.ChartAreas[0].Name; } SetupChartMargin(configuration); }
public FileDotEngine(GraphConfiguration configuration) { this.Settings = configuration; }
public static void VisualizeGraph(this IEdgeListGraph <CFGBlock, TaggedEdge <CFGBlock, EdgeTag> > graph, string path, GraphConfiguration configuration) { Preconditions.NotNull(graph, "graph"); Preconditions.NotNull(path, "path"); Preconditions.NotNull(configuration, "configuration"); var graphviz = new GraphvizAlgorithm <CFGBlock, TaggedEdge <CFGBlock, EdgeTag> >(graph); int variable = 0; graphviz.FormatVertex += (o, e) => { CFGBlock block = e.Vertex; if (block.AstEntryNode != null) { e.VertexFormatter.Label = variable + " " + block.AstEntryNode.LocalName; } else { e.VertexFormatter.Label = variable.ToString(); } variable++; }; graphviz.FormatEdge += (o, e) => { TaggedEdge <CFGBlock, EdgeTag> edgeTag = e.Edge; switch (edgeTag.Tag.EdgeType) { case EdgeType.True: e.EdgeFormatter.Label.Value = "T"; break; case EdgeType.False: e.EdgeFormatter.Label.Value = "F"; break; } }; string output = graphviz.Generate(new FileDotEngine(configuration), path); }
protected void Page_Load(object sender, EventArgs e) { string charId = Request["chart_id"]; string nodeIdString = Request["node_id"]; int nodeId; int pageIndex; if (nodeIdString.Contains('.')) { nodeId = int.Parse(nodeIdString.Split('.')[0]); pageIndex = int.Parse(nodeIdString.Split('.')[1]); } else { nodeId = int.Parse(Request["node_id"]); pageIndex = -1; } //if (!_session.NodeExists(nodeId, false, true)) { // Response.End(); return; //} CKeyNLR key = _session.CompleteKey(nodeId); int depth = int.Parse(Request["depth"]); List<GraphNode> nodes; List<GraphEdge> edges; GraphConfiguration cf = new GraphConfiguration(Request["Configuration"]); cf.Depth = depth; _session.BuildLinkGraph(key, pageIndex, cf, out nodes, out edges); StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); sb.AppendLine("<graph_data>"); sb.AppendLine("<nodes>"); string skinUrl = UI.Skins["Default"].Url; foreach (GraphNode node in nodes) { ContentBase c = _session.GetContent(node.NodeId); sb.Append("<node"); sb.Append(" id=\""); sb.Append(node.Key); sb.Append("\""); if (cf.UseIcons) { sb.Append(" graphic_image_url=\""); sb.Append(HttpUtility.HtmlAttributeEncode(c.GetThumbnailUrl(64, 64, skinUrl))); sb.Append("\""); sb.Append(" label=\"\n\n\n\n"); if (node.IsPageNode) { sb.Append("[" + node.From + ".." + node.To + "]"); } else { sb.Append(HttpUtility.HtmlAttributeEncode(tuncate(c.Name, 12))); } sb.Append("\""); } else { sb.Append(" label=\""); if (node.IsPageNode) { sb.Append("[" + node.From + ".." + node.To + "]"); } else { sb.Append(HttpUtility.HtmlAttributeEncode(c.Name)); } sb.Append("\""); } sb.Append(" depth_loaded=\""); sb.Append(node.DepthLoaded.ToString()); sb.Append("\""); sb.Append(" tooltip=\""); sb.AppendLine(HttpUtility.HtmlAttributeEncode(c.Name)); sb.AppendLine("ID: " + c.NodeId); sb.Append(HttpUtility.HtmlAttributeEncode(WAFRuntime.Definitions.ContentClass[c.ClassId].GetName(_session).ToUpper())); sb.Append("\""); sb.AppendLine(" />"); } sb.AppendLine("</nodes>"); sb.AppendLine("<edges>"); foreach (GraphEdge edge in edges) { ContentBase c1 = _session.GetContent(edge.NodeId1); ContentBase c2 = _session.GetContent(edge.NodeId2); sb.Append("<edge"); sb.Append(" id=\""); sb.Append(edge.Key); sb.Append("\""); if (edge.Links.Count > 0) { sb.Append(" tooltip=\""); for (int i = 0; i < edge.Links.Count; i++) { ContentLink link = edge.Links[i]; sb.Append(Utils.GetFriendlyName(link.LinkType.ToString()).ToUpper() + ": "); switch (link.LinkType) { case NodeLinkType.InternalNodeRelation: sb.Append(WAFRuntime.Definitions.Relation[link.RelationId].GetName(_session)); break; default: sb.Append(WAFRuntime.Definitions.Property[link.PropertyId].GetName(_session)); break; } if (c1 is UrlStatus) sb.Append("(" + ((UrlStatus)c1).Status + ")"); else if (c2 is UrlStatus) sb.Append("(" + ((UrlStatus)c2).Status + ")"); if (i + 1 < edge.Links.Count) sb.AppendLine(); } sb.Append("\""); } int thickness = edge.Links.Count; if (thickness > 7) thickness = 7; thickness = thickness * 2 - 1; if (thickness < 1) thickness = 1; switch (edge.EdgeType) { case GrapthEdgeType.NodeToPage: sb.Append(" edge_line_color=\""); sb.Append("#"); sb.Append("C4D5F4"); sb.Append("\""); sb.Append(" edge_line_thickness=\""); sb.Append(3); sb.Append("\""); break; case GrapthEdgeType.NodeToNode: case GrapthEdgeType.PageToNode: default: bool broken = false; if (c1 is UrlStatus && ((UrlStatus)c1).Status != LinkUrlStatus.Valid) broken = true; if (!broken && c2 is UrlStatus && ((UrlStatus)c2).Status != LinkUrlStatus.Valid) broken = true; string color = null; if (c1 is UrlStatus || c2 is UrlStatus) { UrlStatus a = null; if (c1 is UrlStatus) a = (UrlStatus)c1; else if (c2 is UrlStatus) a = (UrlStatus)c2; switch (a.Status) { case LinkUrlStatus.Unknown: break; case LinkUrlStatus.Valid: color = "#88CC88"; break; case LinkUrlStatus.Broken: color = "#FF4444"; break; case LinkUrlStatus.ResponseError: color = "#CC9944"; break; case LinkUrlStatus.FormatError: color = "#FF4444"; break; default: break; } } else if (edge.ContainsInternalHtmlLink()) { color = "#AACCFF"; } if (color == null) { int cc = (205 + (thickness) * 5); string xx = cc.ToString("X"); if (xx.Length == 1) xx = "0" + xx; color = string.Concat("#", xx, xx, xx); } sb.Append(" edge_line_color=\""); sb.Append(color); sb.Append("\""); sb.Append(" edge_line_thickness=\""); sb.Append(thickness); sb.Append("\""); break; } ReferenceDirection direction = edge.GetDirection(); if (cf.Arrows) { switch (direction) { case ReferenceDirection.NotRelevant: sb.Append(" arrowhead=\"false\""); break; case ReferenceDirection.Bidirectional: sb.Append(" arrowhead=\"true\" bidirectional=\"true\""); break; case ReferenceDirection.Foreward: sb.Append(" arrowhead=\"true\" bidirectional=\"false\""); break; case ReferenceDirection.Backward: sb.Append(" arrowhead=\"true\" bidirectional=\"false\""); break; default: throw new Exception("Unknown direction. "); } } switch (direction) { case ReferenceDirection.NotRelevant: case ReferenceDirection.Bidirectional: case ReferenceDirection.Foreward: sb.Append(" head_node_id=\""); sb.Append(edge.Key2); sb.Append("\""); sb.Append(" tail_node_id=\""); sb.Append(edge.Key1); sb.AppendLine("\" />"); break; case ReferenceDirection.Backward: sb.Append(" head_node_id=\""); sb.Append(edge.Key1); sb.Append("\""); sb.Append(" tail_node_id=\""); sb.Append(edge.Key2); sb.AppendLine("\" />"); break; default: throw new Exception("Unknown direction. "); } //sb.Append(" edge_length_weight=\""); //sb.Append(thickness * 2); //sb.Append("\""); } sb.AppendLine("</edges>"); sb.AppendLine("</graph_data>"); Response.Write(sb.ToString()); }
private void DrawNamedGraph(GraphData data, GraphConfiguration configuration) { int seriesIndex = 0; DateTime minDate = DateTime.MaxValue; DateTime maxDate = DateTime.MinValue; bool setupAxis = false; foreach (string name in data.Names) { Series series = new Series(name) { IsXValueIndexed = true }; SetupSeries(series, configuration, seriesIndex++); series.ChartType = SeriesChartType.Line; this.chart.Series.Add(series); foreach (KeyValuePair<string, List<PlainItem>> items in data.PlainData) { List<PlainItem> namedItems = items.Value.Where(el => el.Name == name).ToList(); if (namedItems.Any()) { List<DateTime> d = namedItems.SelectMany(it => new[] { it.DateTime }).ToList(); DateTime minCurrentNamedItem = d.Min(); DateTime maxCurrentNamedItem = d.Max(); // minDate = new DateTime(Math.Min(minCurrentNamedItem.Ticks, minDate.Ticks)); // maxDate = new DateTime(Math.Max(maxCurrentNamedItem.Ticks, maxDate.Ticks)); if (minDate > minCurrentNamedItem) { minDate = minCurrentNamedItem; } if (maxDate < maxCurrentNamedItem) { maxDate = maxCurrentNamedItem; } if (!setupAxis) { setupAxis = true; } this.chart.FormatNumber += chart_FormatNumber; series.IsXValueIndexed = false; foreach (PlainItem item in namedItems) { double y = GraphData.FormatNumericValue( configuration.ItemsConfiguration.Unit, item.YValue ); series.Points.AddXY(item.DateTime, y); } } } } ChartArea chartArea = this.chart.ChartAreas[0]; if (setupAxis) { chartArea.AxisX.Minimum = minDate.ToOADate(); chartArea.AxisX.Maximum = maxDate.ToOADate(); chartArea.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; chartArea.AxisX.IntervalType = DateTimeIntervalType.Auto; chartArea.AxisX.Interval = 0.0d; chartArea.AxisX.IsStartedFromZero = false; } }
protected void Page_Load(object sender, EventArgs e) { string cstring = Request["Configuration"]; if (cstring == null) Response.End(); _config = new GraphConfiguration(cstring); }
public void ExecuteTestAuto( int iTest, GraphConfiguration<HierarchicalEntity> configuration, string expressionIn, string expressionOut, List<dynamic> descendentsTest, List<dynamic> ancestorsTest ) { dynamic combinations = new[] { new { usePlus = true, useParenthesis = true }, new { usePlus = false, useParenthesis = false }, new { usePlus = true, useParenthesis = false }, new { usePlus = false, useParenthesis = true } }; foreach(var comb in combinations) { IEnumerable<HierarchicalEntity> entities; Expression<HierarchicalEntity> expression = this.GetExpression(expressionIn, out entities, comb.usePlus, comb.useParenthesis); var testNumberDesc = "Test " + iTest.ToString() + ": "; //var expressionTests = new List<dynamic>(); //var level = 1; //var levelInExpression = 1; //var parent = "-"; //var parentOrder = new Dictionary<int, string>(); //for(var i = 0; i < expressionOut.Length; i++) //{ // var previous = default(string); // var next = default(string); // var current = expressionOut[i].ToString(); // if (i + 1 < expressionOut.Length) // next = expressionOut[i + 1].ToString(); // if (i - 1 >= 0) // previous = expressionOut[i - 1].ToString(); // if (current == "(" && i > 0) // { // levelInExpression++; // level++; // } // if (i == 1) // { // parentOrder.Add(level, expressionOut[0].ToString()); // parent = expressionOut[0].ToString(); // } // if (current == ")") // { // parent = parentOrder[level-1]; // } // var dynTest = new // { // Name = current, // Index = i, // Level = (expressionTests.Count > 0 && (current == "(" || current == ")" || previous == "(")) ? level - 1 : level, // LevelInExpression = levelInExpression, // Previous = previous, // Next = next, // Parent = parent, // Root = expressionOut[0].ToString() // }; // if (current == ")") // { // levelInExpression--; // level--; // } // if (previous == "(") // { // if (parentOrder.ContainsKey(level)) // parentOrder[level] = current; // else // parentOrder.Add(level, current); // parent = current; // } // if (i == 0) // { // level++; // } // expressionTests.Add(dynTest); //} //var debug1 = ""; //var debug2 = ""; //var debug3 = ""; //var debug4 = ""; //var debug5 = ""; //foreach (var itemDebug in expressionTests) //{ // debug1 += itemDebug.Name + " "; // debug2 += itemDebug.LevelInExpression + " "; // debug3 += itemDebug.Level + " "; // debug4 += itemDebug.Parent + " "; // debug5 += itemDebug.Root + " "; //} //var outputDebugTest = debug1 + "\r\n" + debug2 + "\r\n" + debug3 + "\r\n" + debug4 + "\r\n" + debug5; //var outputDebugExpression = expression.ToDebug(); //Assert.IsTrue(outputDebugTest == outputDebugExpression, testNumberDesc + "ToDebug function test"); //Assert.IsTrue(debug1.Replace(" ", "") == expression.ToString().Replace(" ", ""), "ToString function test"); //foreach (var test in expressionTests) //{ // var debugIndex = string.Format("Expected Index[{0}] == Index[{1}]; ", test.Index, expression[test.Index].Index); // var debugName = string.Format("Expected Name[{0}] == Name[{1}]; ", test.Name, expression[test.Index].ToString().Trim()); // var debugParent = string.Format("Expected Parent[{0}] == Parent[{1}]; ", test.Parent, (expression[test.Index].Parent == null ? "" : expression[test.Index].Parent.ToString().Trim())); // var debugRoot = string.Format("Expected Root[{0}] == Root[{1}]; ", test.Root, expression[test.Index].Root.ToString().Trim()); // var debugLevel = string.Format("Expected Level[{0}] == Level[{1}]; ", test.Level, expression[test.Index].Level); // var debugLevelExpression = string.Format("Expected LevelExpression[{0}] == LevelExpression[{1}]; ", test.LevelInExpression, expression[test.Index].LevelInExpression); // Assert.IsTrue(test.Index == expression[test.Index].Index, testNumberDesc + debugIndex); // Assert.IsTrue(test.Name == expression[test.Index].ToString().Trim(), testNumberDesc + debugName); // Assert.IsTrue(test.Level == expression[test.Index].Level, testNumberDesc + ":" + debugLevel); // Assert.IsTrue(test.LevelInExpression == expression[test.Index].LevelInExpression, testNumberDesc + debugLevelExpression); // Assert.IsTrue(test.Parent == (expression[test.Index].Parent == null ? "-" : expression[test.Index].Parent.ToString().Trim()), testNumberDesc + ":" + debugParent); // Assert.IsTrue(test.Root == expression[test.Index].Root.ToString().Trim(), "Output test:" + debugRoot); // Assert.IsTrue(test.Previous == (expression[test.Index].PrevInExpression == null ? null : expression[test.Index].PrevInExpression.ToString().Trim()), testNumberDesc + ":" + debugName); // Assert.IsTrue(test.Next == (expression[test.Index].NextInExpression == null ? null : expression[test.Index].NextInExpression.ToString().Trim()), testNumberDesc + debugName); //} Assert.IsTrue(expression.ToString().Replace(" ", "") == expressionOut.Trim(), testNumberDesc + " check toString()"); for (var e = 0; e < entities.Count(); e++) { var test = descendentsTest[e]; var descendants = expression.Find(entities.ElementAt(e)).Descendants().ToEntities().ToList(); var descendantsExpected = string.IsNullOrWhiteSpace(test.Items) ? new string[0] : test.Items.Split(','); var children = expression.Find(entities.ElementAt(e)).Children().ToEntities().ToList(); var childrenExpected = string.IsNullOrWhiteSpace(test.Children) ? new string[0] : test.Children.Split(','); Assert.IsTrue(descendants.Count == descendantsExpected.Length, testNumberDesc + string.Format("Descendants of '{0}': Count of descendants not match for entity.", test.EntityTest)); for (var i = 0; i < descendants.Count; i++) Assert.IsTrue(descendants[i].ToString() == descendantsExpected[i].Trim(), testNumberDesc + string.Format("Descendants of '{0}': Item {1} and {2} not match.", test.EntityTest, descendants[i].ToString(), descendantsExpected[i].Trim())); Assert.IsTrue(children.Count == childrenExpected.Length, testNumberDesc + string.Format("Children of '{0}': Count of children not match for entity.", test.EntityTest)); for (var i = 0; i < children.Count; i++) Assert.IsTrue(children[i].ToString() == childrenExpected[i].Trim(), testNumberDesc + string.Format("Children of '{0}': Item {1} and {2} not match.", test.EntityTest, children[i].ToString(), childrenExpected[i].Trim())); } for (var e = 0; e < entities.Count(); e++) { var test = ancestorsTest[e]; var ancestors = expression.Find(entities.ElementAt(e)).Ancestors().ToEntities().ToList(); var ancestorsExpected = string.IsNullOrWhiteSpace(test.Items) ? new string[0] : test.Items.Split(','); var parents = expression.Find(entities.ElementAt(e)).Parents().ToEntities().ToList(); var parentsExpected = string.IsNullOrWhiteSpace(test.Parents) ? new string[0] : test.Parents.Split(','); Assert.IsTrue(ancestors.Count == ancestorsExpected.Length, testNumberDesc + string.Format("Ancestors of '{0}': Count of ancestors not match.", test.EntityTest)); for (var i = 0; i < ancestors.Count; i++) Assert.IsTrue(ancestors[i].ToString() == ancestorsExpected[i].Trim(), testNumberDesc + string.Format("Ancestors of '{0}': Item {1} and {2} not match.", test.EntityTest, ancestors[i].ToString(), ancestorsExpected[i].Trim())); Assert.IsTrue(parents.Count == parentsExpected.Length, testNumberDesc + string.Format("Parents of '{0}': Count of ancestors not match.", test.EntityTest)); for (var i = 0; i < parents.Count; i++) Assert.IsTrue(parents[i].ToString() == parentsExpected[i].Trim(), testNumberDesc + string.Format("Parents of '{0}': Item {1} and {2} not match.", test.EntityTest, parents[i].ToString(), parentsExpected[i].Trim())); } } }
private void DrawSimpleGraph(GraphData data, GraphConfiguration configuration) { var dt = data.PlainData.FirstOrDefault(d => d.Value.Where(p => p.XValue.HasValue).Count() > 0); if (dt.Value != null) { DrawSimpleXYGraph(dt.Value, configuration); } else { DrawSimpleDateTimeGraph(data, configuration); } }
void initLinkGraph() { if (WAFMaster.EditModule.Menu.IsItemChecked("View_LinkGraph") && _linkGraph == null) { pnlGraphView.Visible = true; _linkGraph = new LinkGraph(); _linkGraph.Height = Unit.Percentage(100); _linkGraph.Width = Unit.Percentage(100); _linkGraph.Open += new EventHandler(_linkGraph_Open); GraphConfiguration config = new GraphConfiguration(); config.RelationIds.Add(RelHierarchical.RelationId); config.InverseSelectionRelation = true; config.Depth = 2; config.Spacing = 60; config.Zoom = 0.9; _linkGraph.Configuration = config; pnlGraphView.Controls.Add(_linkGraph); } else { _linkGraph = null; pnlGraphView.Visible = false; } }
private void DrawSimpleDateTimeGraph(GraphData data, GraphConfiguration configuration) { int i = 0; this.chart.FormatNumber -= chart_FormatNumber; foreach (var items in data.PlainData) { var series = new Series(); SetupSeries(series, configuration, i++); series.IsXValueIndexed = true; switch (configuration.GraphType.Value) { case GraphTypeEnum.Line: series.ChartType = SeriesChartType.Line; break; case GraphTypeEnum.Pie: series.ChartType = SeriesChartType.Pie; break; case GraphTypeEnum.Column: series.ChartType = SeriesChartType.Column; break; case GraphTypeEnum.StackedColumn: series.ChartType = SeriesChartType.StackedColumn; break; } series.Name = items.Key; this.chart.Series.Add(series); foreach (var item in items.Value) { if (String.IsNullOrEmpty(item.Name) && configuration.GraphType.Value != GraphTypeEnum.Pie && items.Value[items.Value.Count - 1].DateTime - items.Value[0].DateTime <= new TimeSpan(2, 0, 0, 0) ) { var d = items.Value.SelectMany(it => new[] { it.DateTime }).ToList(); var min = d.Min(); var max = d.Max(); this.chart.ChartAreas[0].AxisX.Minimum = min.ToOADate(); this.chart.ChartAreas[0].AxisX.Maximum = max.ToOADate(); if (item.Equals(items.Value[0])) { this.chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount; this.chart.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Auto; this.chart.ChartAreas[0].AxisX.Interval = 0.0; this.chart.FormatNumber += chart_FormatNumber; series.IsXValueIndexed = false; } var y = GraphData.FormatNumericValue(configuration.ItemsConfiguration.Unit, item.YValue); series.Points.AddXY(item.DateTime, y); } else { var x = item.Name != null ? (object)item.Name : item.DateTime; var y = GraphData.FormatNumericValue(configuration.ItemsConfiguration.Unit, item.YValue); var index = series.Points.AddXY(x, y); var point = series.Points[index]; if (configuration.GraphType.Value == GraphTypeEnum.Pie) { SetupPoint(point, configuration, index); } } } } this.chart.ChartAreas[0].AxisX.IsStartedFromZero = false; }