/// <summary> /// draws the nodes onto the graph for the supplied dataset /// </summary> /// <param name="xdatamax">the largest x value</param> /// <param name="ydatamax">the largest y value</param> /// <param name="data">the dataset to draw the nodes for</param> private void DrawNodesForDataset(double xdatamax, double ydatamax, GraphDataset data) { PointCollection points = new PointCollection(); foreach (GraphNode node in data.Nodes) { points.Add(SetupNodePosition(xdatamax, ydatamax, node)); } Polyline polyline = GenerateGraphLine(data.Colour, points); Children.Add(polyline); }
/// <summary> /// Adds the supplied dataset to the list of datasets /// </summary> /// <param name="data">the dataset to be added</param> /// <returns>true if dataset is successfully added</returns> public bool AddDataset(GraphDataset data) { if (datasets == null) { datasets = new List <GraphDataset>(); } if (!datasets.Contains(data) && datasets.Count < 5) { datasets.Add(data); return(true); } return(false); }
/// <summary> /// adds a dataset to the graph key /// </summary> /// <param name="keyOffset">the vertical offset of the current key</param> /// <param name="data">the data to add</param> /// <returns>the offset of the next dataset if another was to be added</returns> private int AddDataToKey(int keyOffset, GraphDataset data) { Rectangle rect = GenerateRectangle(KEY_ICONSIZE, KEY_ICONSIZE, data.Colour, ""); Label lab = new Label(); lab.Content = data.DatasetName; SetTop(rect, Height - ymin - keyOffset); SetTop(lab, Height - ymin - keyOffset); SetLeft(lab, KEY_ICONSIZE); Children.Add(rect); Children.Add(lab); return(keyOffset + KEY_ICONSIZE + KEY_GAP); }
/// <summary> /// Draws the data points in the summarizer /// </summary> /// <param name="itemsNotInOther">the item names of the items that are not in the other section</param> /// <param name="datasets">the datasets to be added</param> /// <param name="xdatamax">the largest horizontal number on the graph</param> private void DrawSummariserData(List <string> itemsNotInOther, List <GraphDataset> datasets, double xdatamax, int countOfNames) { List <string> orderOfOther = new List <string>(); double datasetHeight = YMIN_INCREMENTSIZE / datasets.Count(); double smallestIncrement = (Width - XMIN) / xdatamax; for (int e = 0; e < datasets.Count(); e++) { GraphDataset dataset = datasets[e]; for (int i = 0; i < dataset.Nodes.Count(); i++) { double[] value = ((SummariserNode)dataset.Nodes[i]).Value(); double xpoint1 = smallestIncrement * value[0] + XMIN; double xpoint2 = smallestIncrement * value[1] + XMIN; string itemName = dataset.Nodes[i].NodeName; Rectangle rect = GenerateSummariserDatapoint(itemsNotInOther, orderOfOther, datasetHeight, e, itemName, ((SummariserNode)dataset.Nodes[i]).Colour, xpoint1, xpoint2, countOfNames); Children.Add(rect); } } }
/// <summary> /// Creates a rectangle that represents a single data point in the summarizer /// </summary> /// <param name="notInOther">the names of the data points that are not in the other classification</param> /// <param name="orderOfOther">the order of appearance of items in other, used to choose colour</param> /// <param name="itemHeight">the height of the data point</param> /// <param name="verticalIndex">the vertical index inside of the row of the data point</param> /// <param name="itemName">the name of the item</param> /// <param name="parent">the parent dataset of the item</param> /// <param name="start">the starting x position of the data point</param> /// <param name="end">the ending x position of the data point</param> /// <param name="countOfNames">the number of names that are being used for points</param> /// <returns>a rectangle that represents a single data point in the summarizer</returns> private Rectangle GenerateSummariserDatapoint(List <string> notInOther, List <string> orderOfOther, double itemHeight, int verticalIndex, string itemName, GraphDataset parent, double start, double end, int countOfNames) { Rectangle rect = GenerateRectangle(itemHeight, end - start, parent.Colour, itemName); if (notInOther.Contains(itemName)) { int startingPosition = TEXT_HEIGHT * 2; if (notInOther.Count() == NUMBEROFYMININCREMENTS) { startingPosition = TEXT_HEIGHT; } double v = Height - startingPosition - (TEXT_HEIGHT * notInOther.IndexOf(itemName)) + (itemHeight * verticalIndex); if (countOfNames < 4) { v += TEXT_HEIGHT; } SetTop(rect, v); } else { if (!orderOfOther.Contains(itemName)) { orderOfOther.Add(itemName); } rect.Fill = otherBrushes[orderOfOther.IndexOf(itemName) % otherBrushes.Length]; SetTop(rect, Height - TEXT_HEIGHT + (itemHeight * verticalIndex)); } SetLeft(rect, start); return(rect); }