public IEnumerable <Timed <object[]> > EnumTimed(ITimedObject range = null) { var ci = new ColumnStack[allFields.Length]; int n = srcInfos.Length; for (int i = 0; i < ci.Length; i++) { ci[i] = new ColumnStack() { name = allFields[i], values = new Stack <ColData>(n) } } ; TimeRange rng; if (range == null) { rng = new TimeRange(TimedObject.NonZeroTime, DateTime.MaxValue); } else { rng = new TimeRange(range.Time, range.EndTime); } return(EnumerateTimed(ci, 0, rng)); }
void IRequireEnterLeave.Enter(IChartEnterLeaveContext icelc) { EnsureAxes(icelc as IChartComponentContext); Layer = icelc.CreateLayer(); _trace.Verbose($"{Name} enter v:{ValueAxisName} {ValueAxis} c:{CategoryAxisName} {CategoryAxis} d:{DataSourceName}"); BindPaths = new Evaluators(CategoryPath, ValueLabelPath, ColumnStack.Select(cs => cs.ValuePath)); if (!BindPaths.IsValid) { for (int ix = 0; ix < ColumnStack.Count; ix++) { if (String.IsNullOrEmpty(ColumnStack[ix].ValuePath)) { if (icelc is IChartErrorInfo icei) { icei.Report(new ChartValidationResult(NameOrType(), $"ValuePath[{ix}] was not set, NO values are generated", new[] { $"ValuePath[{ix}]" })); } } } } }
public IEnumerable <object[]> EnumNonTimed() { var ci = new ColumnStack[allFields.Length]; int n = srcInfos.Length; for (int i = 0; i < ci.Length; i++) { ci[i] = new ColumnStack() { name = allFields[i], values = new Stack <ColData>(n) } } ; return(EnumerateNonTimed(ci, 0)); } IEnumerable <object[]> EnumerateNonTimed(ColumnStack[] colInfos, int iSrc) { if (iSrc == srcInfos.Length) #region Return result of enumeration { // only return one result var res = new object[resColumns.Length]; bool allNulls = true; for (int i = 0; i < res.Length; i++) { int j = resColumns[i]; int ndx = (j < 0) ? -j - 1 : j; var cd = colInfos[ndx].First().Value; if (Utils.IsEmpty(cd)) { res[i] = cd; } else if (j >= 0) // nonnegative j for data field (output value) { allNulls = false; res[i] = cd; } else // negative j for key field (not output value) { res[i] = cd; // keys } } if (!allNulls) { yield return(res); yield break; } else { yield break; } } #endregion var si = srcInfos[iSrc]; #region Skip inactive source if (!si.active) { // values of iSrc-th source don't affects results // just process remaining sources foreach (var res in EnumerateNonTimed(colInfos, iSrc + 1)) { yield return(res); } yield break; } #endregion // values of iSrc-th source affects results IEnumerable <int> rows; int[] outNdxs = null; int nRowsFound = 0; if (iSrc == 0) #region Rows of first source (not filtered) { rows = Enumerable.Range(0, si.data.Count); outNdxs = si.outputs; } #endregion else if (si.inOuts.Length > 0) #region like SelectMany { // rows filtered by key field ( 'SelectMany'-like function) outNdxs = si.pureOuts; var inOuts = si.inOuts; var keyVals = new object[inOuts.Length]; for (int i = 0; i < keyVals.Length; i++) { int iGlb = si.loc2glb[inOuts[i]]; var we = colInfos[iGlb].Peek().Value; keyVals[i] = we; } rows = si.data.BinarySearchAll(inOuts, keyVals); } #endregion else if (si.pureInsGlb.Length > 0) #region like Select { // row is result of 'Select'-like function ( one result for one input) var iMax = -1; foreach (int glb in si.pureInsGlb) { var cd = colInfos[glb].First(); if (cd.iRow > iMax) { iMax = cd.iRow; } else if (cd.iRow < 0) { iMax = -1; break; } } if (iMax >= 0) { rows = Enumerable.Range(iMax, 1); } else { rows = null; } outNdxs = si.pureOuts; } #endregion else { // "Input" function = independent value(s) rows = Enumerable.Range(0, si.data.Count); outNdxs = si.outputs; } if (rows != null) { foreach (var iRow in rows) { nRowsFound++; var rowVals = si.data[iRow].ValuesList; // push found values foreach (int i in outNdxs) { var rv = rowVals[i]; var col = colInfos[si.loc2glb[i]]; col.Push(iRow, rv); } // process remained sources foreach (var res in EnumerateNonTimed(colInfos, iSrc + 1)) { yield return(res); } // restore values foreach (int i in outNdxs) { colInfos[si.loc2glb[i]].values.Pop(); } } } //SkipRows: if (nRowsFound == 0) { // push null values foreach (int i in outNdxs) { //colInfos[si.loc2glb[i]].Push(-1, TimedObject.EmptyI); colInfos[si.loc2glb[i]].Push(-1, null); } // process remained sources foreach (var res in EnumerateNonTimed(colInfos, iSrc + 1)) { yield return(res); } // restore values foreach (int i in outNdxs) { colInfos[si.loc2glb[i]].values.Pop(); } } } }