public PlotCollectionSet(PlotCollectionSet set, int nStart) { for (int i = nStart; i < set.Count; i++) { m_rgSet.Add(set[i]); } }
public PlotCollectionSet GetLastData(int nLookahead = 0, bool bRemove = false) { if (m_data.Count == 0) { return(null); } if (nLookahead > 0 && bRemove) { throw new Exception("Removing data is not supported when retrieving data with a lookahead."); } PlotCollectionSet lastData = new PlotCollectionSet(); List <PlotCollection> rgPlots = new List <PlotCollection>(); for (int i = 0; i < m_data.Count; i++) { PlotCollectionSet dataFrame = m_data[i]; if (dataFrame.Count == 0) { return(null); } PlotCollection plots = new PlotCollection("Frame " + i.ToString()); for (int j = 0; j < dataFrame.Count; j++) { PlotCollection framePlots = dataFrame[j]; if (framePlots.Count == 0) { return(null); } Plot last = framePlots[framePlots.Count - (1 + nLookahead)]; if (last.Name == null) { last.Name = framePlots.Name; } plots.Add(last); if (bRemove) { framePlots.RemoveAt(framePlots.Count - 1); } } lastData.Add(plots); } if (bRemove) { m_output = m_surface.BuildGraph(m_config, m_data); SimpleGraphingControl_Resize(this, EventArgs.Empty); ScrollToEnd(false); } return(lastData); }
public static Image QuickRender(PlotCollection plots, int nWidth = -1, int nHeight = -1, bool bConvertToEastern = false, ConfigurationAxis.VALUE_RESOLUTION?timeResolution = null, string strCfgXmlFile = null, bool bIncludeTitle = true, List <ConfigurationTargetLine> rgTargetLines = null, bool bUseTimeResolutionForValueType = false) { PlotCollectionSet set = new PlotCollectionSet(); set.Add(plots); return(QuickRender(set, nWidth, nHeight, bConvertToEastern, timeResolution, strCfgXmlFile, bIncludeTitle, rgTargetLines, bUseTimeResolutionForValueType)); }
public PlotCollectionSet BuildGraph(ConfigurationFrame config, PlotCollectionSet data, bool bAddToParams = false, bool bIndexData = false) { m_config = config; m_data = data; for (int i = 0; i < data.Count; i++) { if (bIndexData) { for (int j = 0; j < data[i].Count; j++) { data[i][j].Index = j; } } if (data[i].MinMaxTarget != config.MinMaxTarget) { data[i].MinMaxTarget = config.MinMaxTarget; } } setBounds(config, data); data = m_plotArea.BuildGraph(config, config.Plots, data, bAddToParams, GETDATAORDER.PRE); m_gx.BuildGraph(config.XAxis, data); m_gy.BuildGraph(config.YAxis, data); m_gy.SetGraphPlots(m_plotArea.Plots); m_gy.SetTargetLines(config.TargetLines); setMinMax(config, data); return(data); }
public PlotCollectionSet(PlotCollectionSet set, params string[] rgstrContains) { int nStart = findStart(set, rgstrContains); for (int i = nStart; i < set.Count; i++) { m_rgSet.Add(set[i]); } }
public List <PlotCollectionSet> GetLastOutput(int nSequenceLength = 1) { List <PlotCollectionSet> rgOutput = new List <PlotCollectionSet>(); if (m_output == null || m_output.Count == 0) { return(rgOutput); } int nCount = m_output[0][0].Count; int nStart = nCount - nSequenceLength; if (nStart < 0) { nStart = 0; nSequenceLength = nCount; } for (int k = nStart; k < nStart + nSequenceLength; k++) { PlotCollectionSet lastData = new PlotCollectionSet(); List <PlotCollection> rgPlots = new List <PlotCollection>(); for (int i = 0; i < m_output.Count; i++) { PlotCollectionSet dataFrame = m_output[i]; if (dataFrame.Count > 0) { PlotCollection plots = new PlotCollection("Frame " + i.ToString()); for (int j = 0; j < dataFrame.Count; j++) { PlotCollection framePlots = dataFrame[j]; if (framePlots.Count == nCount) { Plot last = framePlots[k]; last.Name = framePlots.Name; plots.Add(last); } } lastData.Add(plots); } } rgOutput.Add(lastData); } return(rgOutput); }
public PlotCollectionSet Clone() { PlotCollectionSet col = new PlotCollectionSet(); col.m_dfMarginPct = m_dfMarginPct; foreach (PlotCollection pc in m_rgSet) { col.Add(pc.Clone()); } return(col); }
public bool TryCustomBuild(PlotCollectionSet dataOut) { if (OnCustomBuild == null) { return(false); } CustomBuildArgs args = new CustomBuildArgs(dataOut); OnCustomBuild(this, args); return(true); }
public Tuple <PlotCollectionSet, PlotCollectionSet> Split(int nCount, bool bSetDateOnTag = false, bool bAppendSplitCountToName = false) { PlotCollectionSet p1 = new PlotCollectionSet(); PlotCollectionSet p2 = new PlotCollectionSet(); foreach (PlotCollection plots in m_rgSet) { Tuple <PlotCollection, PlotCollection> p = plots.Split(nCount, bSetDateOnTag, bAppendSplitCountToName); p1.Add(p.Item1); p2.Add(p.Item2); } return(new Tuple <PlotCollectionSet, PlotCollectionSet>(p1, p2)); }
public PlotCollectionSet BuildGraph(ConfigurationFrame config, List <ConfigurationPlot> plots, PlotCollectionSet data, bool bAddToParams = false, GETDATAORDER order = GETDATAORDER.PRE) { PlotCollectionSet data1 = new PlotCollectionSet(); if (order == GETDATAORDER.PRE) { if (!config.UseExistingDataMinMax) { data.SetMinMax(); } data.GetAbsMinMax(0, 0, out m_dfAbsMinY, out m_dfAbsMaxY); setMinMaxLines(config); m_rgPlots = new SimpleGraphing.GraphPlotCollection(); m_rgData = new PlotCollectionSet(); m_rgData.Add(data); } for (int i = 0; i < plots.Count; i++) { if ((plots[i].HasCustomBuild || plots[i].Visible) && plots[i].BuildOrder == order) { GraphPlot graphPlot = new SimpleGraphing.GraphPlot(m_cache, m_gx, m_gy); int nLookahead = Math.Max(config.PlotArea.Lookahead, config.PlotArea.CalculationLookahead); PlotCollectionSet set = graphPlot.BuildGraph(plots[i], m_rgData, plots[i].DataIndex, nLookahead, m_rgPlots, bAddToParams); if (set != null) { data1.Add(set, true); } if (graphPlot.Plots != null) { m_rgPlots.Add(graphPlot); m_rgData.Add(graphPlot.Plots, true); } } } if (order == GETDATAORDER.PRE) { m_style = createStyle(config); } return(data1); }
public List <PlotCollectionSet> BuildGraphPost(Configuration config, List <PlotCollectionSet> rgData) { List <PlotCollectionSet> rgOutput = new List <PlotCollectionSet>(); for (int i = 0; i < m_frames.Count; i++) { PlotCollectionSet set = m_frames[i].BuildGraphPost(rgData[i]); if (set != null) { rgOutput.Add(set); } } return(rgOutput); }
public PlotCollectionSet BuildGraph(ConfigurationPlot config, PlotCollectionSet data, int nDataIdx, int nLookahead, GraphPlotCollection plots, bool bAddToParams = false) { m_config = config; m_style = createStyle(m_config); PlotCollectionSet dataOut = data; if (!config.TryCustomBuild(data)) { if (m_idata != null) { string strRequiredDataName = m_idata.RequiredDataName; if (strRequiredDataName != null) { foreach (GraphPlot plot in plots) { if (plot.DataName == strRequiredDataName || (plot.DataName == null && plot.ToString() == strRequiredDataName)) { PlotCollectionSet data1 = new PlotCollectionSet(); if (data.Count > 1 || plot.Plots[0] != data[0]) { data1.Add(data); } data1.Add(plot.Plots, true); dataOut = data1; break; } } } dataOut = m_idata.GetData(data, nDataIdx, nLookahead, config.ID, bAddToParams); if (dataOut != null) { dataOut.ExcludeFromMinMax(config.ExcludeFromMinMax); dataOut.SetMarginPercent(config.MarginPercent); } } } m_rgPlots = dataOut; return(dataOut); }
public void AddData(PlotCollectionSet data, bool bMaintainCount, bool bRender = false) { if (data.Count != m_data.Count) { throw new Exception("The number of plot collections must match the number of plot sets used by the graph."); } List <string> rgUpdated = new List <string>(); for (int i = 0; i < data.Count; i++) { PlotCollectionSet dataFrame = m_data[i]; if (rgUpdated.Contains(dataFrame[0].Name)) { continue; } PlotCollection dataToAdd = data[i]; if (dataFrame.Count != dataToAdd.Count) { throw new Exception("The number of data items to add must match the number of plot collections in the frame!"); } for (int j = 0; j < dataFrame.Count; j++) { PlotCollection dataFrameItems = dataFrame[j]; Plot plot = dataToAdd[j]; dataFrameItems.Add(plot); if (bMaintainCount) { dataFrameItems.RemoveAt(0); } } rgUpdated.Add(dataFrame[0].Name); } m_output = m_surface.BuildGraph(m_config, m_data); SimpleGraphingControl_Resize(this, EventArgs.Empty); ScrollToEnd(bRender); }
public int Add(PlotCollectionSet set, bool bUniqueOnly = false, bool bCopyUserProperties = true) { if (!bUniqueOnly) { if (set.m_rgSet.Count == 0) { return(0); } m_rgSet.AddRange(set.m_rgSet); return(set.m_rgSet[0].Count); } int nCount = (m_rgSet.Count == 0) ? 0 : m_rgSet[0].Count; foreach (PlotCollection plots in set) { if (!m_rgSet.Contains(plots)) { m_rgSet.Add(plots); } } int nNewCount = m_rgSet[0].Count; if (bCopyUserProperties) { List <KeyValuePair <string, string> > rg = set.UserProperties.ToList(); foreach (KeyValuePair <string, string> kv in rg) { if (!UserProperties.ContainsKey(kv.Key)) { UserProperties.Add(kv.Key, kv.Value); } else { UserProperties[kv.Key] = kv.Value; } } } return(nNewCount - nCount); }
private int findStart(PlotCollectionSet set, params string[] rgstrContains) { for (int i = 0; i < set.Count; i++) { string strName = set.m_rgSet[i].Name; for (int j = 0; j < rgstrContains.Length; j++) { string strTarget = rgstrContains[j]; if (strName.IndexOf(strTarget) >= 0) { return(i); } } } return(0); }
public static List <PlotCollectionSet> LoadList(byte[] rgData, int nMaxList = int.MaxValue, int nMaxSet = int.MaxValue) { List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>(); using (MemoryStream ms = new MemoryStream(rgData)) using (BinaryReader br = new BinaryReader(ms)) { int nCount = br.ReadInt32(); if (nCount > nMaxList) { nCount = nMaxList; } for (int i = 0; i < nCount; i++) { int nLen = br.ReadInt32(); byte[] rgData1 = br.ReadBytes(nLen); rgSet.Add(PlotCollectionSet.Load(rgData1, nMaxSet)); } } return(rgSet); }
public static PlotCollectionSet Load(byte[] rgData, int nMax = int.MaxValue) { PlotCollectionSet set = new PlotCollectionSet(); using (MemoryStream ms = new MemoryStream(rgData)) using (BinaryReader br = new BinaryReader(ms)) { int nCount = br.ReadInt32(); if (nCount > nMax) { nCount = nMax; } for (int i = 0; i < nCount; i++) { int nLen = br.ReadInt32(); byte[] rgData1 = br.ReadBytes(nLen); set.Add(PlotCollection.Load(rgData1)); } } return(set); }
public void PreResize(PlotCollectionSet data) { data.GetAbsMinMax(0, 0, out m_dfAbsMinY, out m_dfAbsMaxY); setMinMaxLines(m_config); }
public PlotCollectionSet BuildGraphPost(PlotCollectionSet data) { return(m_plotArea.BuildGraph(m_config, m_config.Plots, data, false, GETDATAORDER.POST)); }
public CustomBuildArgs(PlotCollectionSet data) { m_data = data; }
private void setMinMax(ConfigurationFrame config, PlotCollectionSet data) { double dfMin = m_gx.MinimumY; double dfMax = m_gx.MaximumY; double dfLineMin = 0; double dfLineMax = 0; bool bMin = false; bool bMax = false; foreach (ConfigurationTargetLine line in config.TargetLines) { if (line.Enabled) { if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN) { dfLineMin = line.YValue; bMin = true; } else if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX) { dfLineMax = line.YValue; bMax = true; } } } double dfAbsMin; double dfAbsMax; data.GetAbsMinMax(0, 0, out dfAbsMin, out dfAbsMax); if (config.UseExistingDataMinMax) { dfMin = dfAbsMin; dfMax = dfAbsMax; } else { if (bMin || dfMin == double.MaxValue) { dfMin = Math.Min(dfMin, dfAbsMin); dfMin = Math.Min(dfMin, dfLineMin); } if (bMax || dfMax == -double.MaxValue) { dfMax = Math.Max(dfMax, dfAbsMax); dfMax = Math.Max(dfMax, dfLineMax); } } m_gx.SetMinMax(dfMin, dfMax); m_gy.SetMinMax(dfMin, dfMax); dfMin = m_gy.ActiveMin; dfMax = m_gy.ActiveMax; m_dfActiveMinY = dfMin; m_dfActiveMaxY = dfMax; m_dfDataMinY = dfAbsMin; m_dfDataMaxY = dfAbsMax; }
public List <PlotCollectionSet> BuildGraph(Configuration config, List <PlotCollectionSet> rgData, bool bAddToParams = false) { List <PlotCollectionSet> rgOutputData = new List <PlotCollectionSet>(); m_config = config.Surface; if (m_frames == null) { m_frames = new SimpleGraphing.GraphFrameCollection(); } if (rgData == null) { if (m_frames.Count > 0) { m_frames.Dispose(); m_frames = new GraphFrameCollection(); } return(rgOutputData); } int nMaxIdx = config.Frames.Max(p => p.DataIndex); if (nMaxIdx >= rgData.Count) { throw new Exception("The plot collection set count is less than the max data index of '" + nMaxIdx.ToString() + "'!"); } if (!m_frames.Compare(config.Frames)) { if (m_frames.Count > 0) { m_frames.Dispose(); m_frames = new GraphFrameCollection(); } } int nFrameIdx = 0; int nFrameCount = m_frames.Count; for (int i = 0; i < config.Frames.Count && i < rgData.Count; i++) { PlotCollectionSet dataOutput = null; if (config.Frames[i].Visible) { GraphFrame frame = null; if (nFrameIdx >= nFrameCount) { frame = new GraphFrame(m_cache); } else { frame = m_frames[nFrameIdx]; } if (frame.Configuration.Visible) { dataOutput = frame.BuildGraph(config.Frames[i], rgData[i], bAddToParams); } if (nFrameIdx >= nFrameCount) { m_frames.Add(frame); } nFrameIdx++; } rgOutputData.Add(dataOutput); } return(rgOutputData); }
public static Image QuickRenderEx(PlotCollectionSet set, Configuration cfg, int nWidth = -1, int nHeight = -1, bool bConvertToEastern = false, ConfigurationAxis.VALUE_RESOLUTION?timeResolution = null, bool bIncludeTitle = true, List <ConfigurationTargetLine> rgTargetLines = null, bool bUseTimeResolutionForValueType = false) { foreach (PlotCollection col in set) { if (col.AbsoluteMinYVal == double.MaxValue || col.AbsoluteMaxYVal == -double.MaxValue) { col.SetMinMax(); } } SimpleGraphingControl simpleGraphingControl1 = new SimpleGraphingControl(); simpleGraphingControl1.Name = "SimpleGraphing"; int nValCount = 1; if (set.Count > 0 && set[0].Count > 0) { nValCount = set[0][0].Y_values.Length; } simpleGraphingControl1.SetConfigurationToQuickRenderDefault(set[0].Name, (string)set[0].Tag, nValCount, bConvertToEastern, timeResolution, bUseTimeResolutionForValueType); if (set.Count > 1) { List <Color> rgColor = new List <Color>() { Color.Red, Color.Blue, Color.Green, Color.Purple, Color.Orange, Color.Aquamarine, Color.Fuchsia, Color.OrangeRed, Color.Lavender, Color.Navy, Color.Cyan, Color.DarkCyan }; for (int i = 0; i < set.Count; i++) { int nClrIdx = i % rgColor.Count; Color clr = rgColor[nClrIdx]; ConfigurationPlot plotConfig; if (i > 0) { plotConfig = new ConfigurationPlot(); simpleGraphingControl1.Configuration.Frames[0].Plots.Add(plotConfig); } plotConfig = simpleGraphingControl1.Configuration.Frames[0].Plots[i]; plotConfig.LineColor = clr; plotConfig.PlotLineColor = Color.Transparent; plotConfig.PlotFillColor = Color.Transparent; plotConfig.PlotType = ConfigurationPlot.PLOTTYPE.LINE; plotConfig.Visible = true; plotConfig.EnableLabel = true; plotConfig.EnableFlag = false; plotConfig.FlagColor = clr; plotConfig.Name = set[i].Name; plotConfig.DataIndexOnRender = i; } simpleGraphingControl1.Configuration.Frames[0].EnableRelativeScaling(true, true); } simpleGraphingControl1.LoadModuleCache(); simpleGraphingControl1.Configuration = cfg; List <PlotCollectionSet> rgSet = new List <PlotCollectionSet>() { set }; if (!bIncludeTitle) { simpleGraphingControl1.Configuration.Frames[0].Name = ""; } if (rgTargetLines != null && rgTargetLines.Count > 0) { simpleGraphingControl1.Configuration.Frames[0].TargetLines.AddRange(rgTargetLines); } simpleGraphingControl1.BuildGraph(rgSet, false, true); if (nWidth <= 0) { nWidth = 600; } if (nHeight <= 0) { nHeight = 300; } simpleGraphingControl1.ScrollToEnd(false); return(simpleGraphingControl1.Render(nWidth, nHeight)); }
public virtual void BuildGraph(ConfigurationAxis config, PlotCollectionSet data) { m_data = data; m_style = createStyle(config); }
public override void BuildGraph(ConfigurationAxis config, PlotCollectionSet data) { base.BuildGraph(config, data); Resize(m_rcBounds.X, m_rcBounds.Y, m_rcBounds.Width, m_rcBounds.Height); }
private void setBounds(ConfigurationFrame config, PlotCollectionSet data) { if (config.MinimumYRange != 0) { double dfAbsMinY; double dfAbsMaxY; if (!config.UseExistingDataMinMax) { data.SetMinMax(); } data.GetAbsMinMax(0, 0, out dfAbsMinY, out dfAbsMaxY); double dfRange = dfAbsMaxY - dfAbsMinY; if (dfRange < config.MinimumYRange) { double dfMid = dfAbsMinY + dfRange / 2; dfAbsMinY = dfMid - (config.MinimumYRange / 2); dfAbsMaxY = dfMid + (config.MinimumYRange / 2); ConfigurationTargetLine minLine = null; ConfigurationTargetLine maxLine = null; List <ConfigurationTargetLine> rgRemove = new List <ConfigurationTargetLine>(); foreach (ConfigurationTargetLine line in config.TargetLines) { if (line.Name == "bounds_min") { minLine = line; } if (line.Name == "bounds_max") { maxLine = line; } if (line.LineType == ConfigurationTargetLine.LINE_TYPE.MIN || line.LineType == ConfigurationTargetLine.LINE_TYPE.MAX) { rgRemove.Add(line); } if (minLine != null && maxLine != null) { break; } } foreach (ConfigurationTargetLine line in rgRemove) { config.TargetLines.Remove(line); } if (minLine == null) { minLine = new ConfigurationTargetLine(dfAbsMinY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE); minLine.Name = "bounds_min"; config.TargetLines.Add(minLine); } else { minLine.YValue = dfAbsMinY; } if (maxLine == null) { maxLine = new ConfigurationTargetLine(dfAbsMaxY, Color.FromArgb(2, Color.White), ConfigurationTargetLine.LINE_TYPE.VALUE); maxLine.Name = "bounds_max"; config.TargetLines.Add(maxLine); } else { maxLine.YValue = dfAbsMaxY; } } } }