public void AddValueToGraph(int val) { float nVal = (objs.Count > 0 && accumulative) ? val + objs[objs.Count - 1].value : val; highest = nVal > highest ? nVal : highest; float inp = Mathf.Abs(nVal); bool isPos = Mathf.Sign(nVal) == 1; max = inp > max ? (int)inp : max; GameObject gO = GameObject.Instantiate(Resources.Load <GameObject>("UI/Bar")); gO.transform.SetParent(self.GetComponentInChildren <Image>().transform); Color[] col = new Color[2]; ColorUtility.TryParseHtmlString("#b0ff8e", out col[0]); ColorUtility.TryParseHtmlString("#ff7e5a", out col[1]); Image thatBar = gO.GetComponent <Image>(); thatBar.rectTransform.localScale = Vector3.one; thatBar.color = isPos ? col[0] : col[1]; GraphObj nGraphObj = new GraphObj(thatBar, isPos, inp, nVal); objs.Add(nGraphObj); if (accumulative) { performance = nVal; } else { List <float> ret = new List <float>(); for (int i = 0; i < objs.Count; i++) { ret.Add(objs[i].value); } performance = ret.Average(); } }
private bool OnMouseUpEvent(ZedGraphControl sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int nIndex = 0; var oPos = new Point(e.X, e.Y); string sTag = null; if (sender.GraphPane.Legend.FindPoint(oPos, sender.GraphPane, sender.GraphPane.CalcScaleFactor(), out nIndex)) { sTag = sender.GraphPane.CurveList[nIndex].Label.Text; } if (sTag != null) { for (int i = 0; i < sender.GraphPane.CurveList.Count; i++) { if (sender.GraphPane.CurveList[i].Label.Text == sTag) { sender.GraphPane.CurveList[i].IsVisible = !sender.GraphPane.CurveList[i].IsVisible; } } for (int i = 0; i < sender.GraphPane.GraphObjList.Count; i++) { GraphObj current = sender.GraphPane.GraphObjList[i]; if (current.Tag is TagData) { var data = current.Tag as TagData; if (data.Label == sTag) { current.IsVisible = !current.IsVisible; } } } } sender.Refresh(); } return(false); }
private void RemovePreviousObjects() { try { if (chartVu != null) { ArrayList arrObjects = chartVu.GetChartObjectsArrayList(); int iCount = arrObjects.Count; if (arrObjects != null) { for (int iCtr = 0; iCtr < iCount; iCtr++) { GraphObj objObject = (GraphObj)arrObjects[0]; Type obj = objObject.GetType(); chartVu.DeleteChartObject(objObject); } } chartVu.UpdateDraw(); } } catch (Exception ex) { } }
private bool IsYChartFractionObject(GraphObj obj) { return(obj.Location.CoordinateFrame == CoordType.XPaneFractionYChartFraction || obj.Location.CoordinateFrame == CoordType.ChartFraction || obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction); }
/// <summary> /// Copy the properties of this <see cref="ZedGraphWebGraphObj"/> to the specified /// <see cref="ZedGraph.GraphObj"/> object. /// </summary> /// <param name="item">The destination <see cref="ZedGraph.GraphObj"/> object</param> internal void CopyTo( GraphObj item ) { item.ZOrder = this.ZOrder; item.IsVisible = this.IsVisible; this.Location.CopyTo( item.Location ); }
public void BackGroundChanges() { try { if (chartVu != null) { ArrayList arrObjects = chartVu.GetChartObjectsArrayList(); int iCount = arrObjects.Count; int iDel = 0; if (arrObjects != null) { for (int iCtr = 0; iCtr < iCount; iCtr++) { GraphObj objObject = (GraphObj)arrObjects[iDel]; Type obj = objObject.GetType(); if (obj.Name == "PolarLinePlot" || obj.Name == "PolarScatterPlot") { iDel++; } else { chartVu.DeleteChartObject(objObject); } } } plotbackground = new Background(pPolarTransform, ChartObj.PLOT_BACKGROUND, ChartBG1, ChartBG2, ChartBGDir); chartVu.AddChartObject(plotbackground); background = new Background(pPolarTransform, ChartObj.GRAPH_BACKGROUND, GraphBG1, GraphBG2, GraphBGDir); chartVu.AddChartObject(background); pPolarAxis = pPolarTransform.GetCompatibleAxes(); pPolarAxis.SetColor(_AxisColor); chartVu.AddChartObject(pPolarAxis); pPolarGrid = new PolarGrid(pPolarAxis, PolarGrid.GRID_MAJOR); pPolarGrid.SetColor(_AxisColor); pPolarGrid.LineColor = _AxisColor; chartVu.AddChartObject(pPolarGrid); pPolarAxisLabels = (PolarAxesLabels)pPolarAxis.GetCompatibleAxesLabels(); pPolarAxisLabels.SetColor(_AxisColor); chartVu.AddChartObject(pPolarAxisLabels); if (_ChartFooter != null) { ChartTitle footer = new ChartTitle(pPolarTransform, theFont, _ChartFooter); footer.SetColor(_AxisColor); footer.SetTitleType(ChartObj.CHART_FOOTER); footer.SetTitlePosition(ChartObj.CENTER_GRAPH); footer.SetTitleOffset(8); chartVu.AddChartObject(footer); } chartVu.Update(); } } catch (Exception ex) { } }