public static List<IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G3DPlotStyleCollection templatePlotStyle) { var selColumns = new List<DataColumn>(selectedColumns.Count); foreach (int i in selectedColumns) selColumns.Add(table[i]); return CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext()); }
protected override IEnumerable<Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName() { if (null != _plotStyles) yield return new Main.DocumentNodeAndName(_plotStyles, () => _plotStyles = null, "Style"); if (null != _localGroups) yield return new Main.DocumentNodeAndName(_localGroups, () => _localGroups = null, "LocalPlotGroupStyles"); }
public static G3DPlotStyleCollection PlotStyle_Symbol(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var result = new G3DPlotStyleCollection { new ScatterPlotStyle(context) }; return(result); }
protected override IEnumerable <Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName() { if (null != _plotStyles) { yield return(new Main.DocumentNodeAndName(_plotStyles, () => _plotStyles = null, "Style")); } if (null != _localGroups) { yield return(new Main.DocumentNodeAndName(_localGroups, () => _localGroups = null, "LocalPlotGroupStyles")); } }
/// <summary> /// Creates a plot style collection for a bar graph. /// </summary> /// <param name="context">The context.</param> /// <param name="isStacked">If set to <c>true</c>, the bar should be stacked.</param> /// <returns></returns> public static G3DPlotStyleCollection PlotStyle_Bar(Altaxo.Main.Properties.IReadOnlyPropertyBag context, bool isStacked) { var result = new G3DPlotStyleCollection(); var ps1 = new BarGraphPlotStyle(context); if (isStacked) { ps1.StartAtPreviousItem = true; } result.Add(ps1); return(result); }
public override bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) { return(true); } var copied = base.CopyFrom(obj); if (copied) { var from = obj as G3DPlotItem; if (from != null) { Style = from.Style.Clone(); } } return(copied); }
/// <summary> /// Creates a plot style collection for a bar graph. /// </summary> /// <param name="context">The context.</param> /// <param name="isStacked">If set to <c>true</c>, the bar should be stacked.</param> /// <returns></returns> public static G3DPlotStyleCollection PlotStyle_Bar(Altaxo.Main.Properties.IReadOnlyPropertyBag context, bool isStacked) { var result = new G3DPlotStyleCollection(); BarGraphPlotStyle ps1 = new BarGraphPlotStyle(context); if (isStacked) { ps1.StartAtPreviousItem = true; } result.Add(ps1); return result; }
public override bool CopyFrom(object obj) { if (object.ReferenceEquals(this, obj)) return true; var copied = base.CopyFrom(obj); if (copied) { var from = obj as G3DPlotItem; if (from != null) { this.Style = from.Style.Clone(); } } return copied; }
private static TypeArray GetTypeArray(G3DPlotStyleCollection coll) { System.Type[] types = new Type[coll.Count]; for (int i = 0; i < types.Length; i++) types[i] = coll[i].GetType(); return new TypeArray(types); }
public XYZColumnPlotItem(XYZColumnPlotData pa, G3DPlotStyleCollection ps) { Data = pa; Style = ps; }
public static G3DPlotStyleCollection PlotStyle_Line_Symbol(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var result = new G3DPlotStyleCollection(); result.Add(new ScatterPlotStyle(context)); result.Add(new LinePlotStyle(context) { UseSymbolGap = true }); return result; }
public static string GetName(G3DPlotStyleCollection coll) { return (string)_NamesByTypeArray[GetTypeArray(coll)]; }
/// <summary> /// Creates a list of plot items from data columns, using a template plot style. /// </summary> /// <param name="selectedColumns">Columns for which to create plot items.</param> /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param> /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like /// labels, yerr, and so on.</param> /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param> /// <returns>List of plot items created.</returns> public static List <IGPlotItem> CreatePlotItems(IEnumerable <DataColumn> selectedColumns, G3DPlotStyleCollection templatePlotStyle, HashSet <DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context) { return(CreatePlotItems(selectedColumns, null, null, templatePlotStyle, processedColumns, context)); }
/// <summary> /// Plots selected data columns of a table. /// </summary> /// <param name="table">The source table.</param> /// <param name="selectedColumns">The data columns of the table that should be plotted.</param> /// <param name="graph">The graph document to plot into.</param> /// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param> /// <param name="groupStyles">The group styles for the newly built plot item collection.</param> public static IGraphController Plot( DataTable table, IAscendingIntegerCollection selectedColumns, GraphDocument graph, G3DPlotStyleCollection templatePlotStyle, PlotGroupStyleCollection groupStyles) { List <IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle); // now create a new Graph with this plot associations var gc = Current.ProjectService.CreateNewGraph3D(graph); var layer = gc.Doc.RootLayer.Layers.OfType <XYZPlotLayer>().First(); // Set x and y axes according to the first plot item in the list if (pilist.Count > 0 && (pilist[0] is XYZColumnPlotItem)) { var firstitem = (XYZColumnPlotItem)pilist[0]; if (firstitem.Data.XColumn is TextColumn) { layer.Scales[0] = new TextScale(); } else if (firstitem.Data.XColumn is DateTimeColumn) { layer.Scales[0] = new DateTimeScale(); } if (firstitem.Data.YColumn is TextColumn) { layer.Scales[1] = new TextScale(); } else if (firstitem.Data.YColumn is DateTimeColumn) { layer.Scales[1] = new DateTimeScale(); } if (firstitem.Data.ZColumn is TextColumn) { layer.Scales[2] = new TextScale(); } else if (firstitem.Data.ZColumn is DateTimeColumn) { layer.Scales[2] = new DateTimeScale(); } } var newPlotGroup = new PlotItemCollection(layer.PlotItems); foreach (IGPlotItem pi in pilist) { newPlotGroup.Add(pi); } if (groupStyles != null) { newPlotGroup.GroupStyles = groupStyles; } else { newPlotGroup.CollectStyles(newPlotGroup.GroupStyles); } layer.PlotItems.Add(newPlotGroup); return(gc); }
/// <summary> /// Plots selected data columns of a table. /// </summary> /// <param name="table">The source table.</param> /// <param name="selectedColumns">The data columns of the table that should be plotted.</param> /// <param name="graph">The graph document to plot into.</param> /// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param> /// <param name="groupStyles">The group styles for the newly built plot item collection.</param> public static IGraphController Plot( DataTable table, IAscendingIntegerCollection selectedColumns, GraphDocument graph, G3DPlotStyleCollection templatePlotStyle, PlotGroupStyleCollection groupStyles) { List<IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle); // now create a new Graph with this plot associations var gc = Current.ProjectService.CreateNewGraph3D(graph); var layer = gc.Doc.RootLayer.Layers.OfType<XYZPlotLayer>().First(); // Set x and y axes according to the first plot item in the list if (pilist.Count > 0 && (pilist[0] is XYZColumnPlotItem)) { var firstitem = (XYZColumnPlotItem)pilist[0]; if (firstitem.Data.XColumn is TextColumn) layer.Scales[0] = new TextScale(); else if (firstitem.Data.XColumn is DateTimeColumn) layer.Scales[0] = new DateTimeScale(); if (firstitem.Data.YColumn is TextColumn) layer.Scales[1] = new TextScale(); else if (firstitem.Data.YColumn is DateTimeColumn) layer.Scales[1] = new DateTimeScale(); if (firstitem.Data.ZColumn is TextColumn) layer.Scales[2] = new TextScale(); else if (firstitem.Data.ZColumn is DateTimeColumn) layer.Scales[2] = new DateTimeScale(); } PlotItemCollection newPlotGroup = new PlotItemCollection(layer.PlotItems); foreach (IGPlotItem pi in pilist) { newPlotGroup.Add(pi); } if (groupStyles != null) newPlotGroup.GroupStyles = groupStyles; else newPlotGroup.CollectStyles(newPlotGroup.GroupStyles); layer.PlotItems.Add(newPlotGroup); return gc; }
/// <summary> /// Creates a list of plot items from data columns, using a template plot style. /// </summary> /// <param name="selectedColumns">Columns for which to create plot items.</param> /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param> /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like /// labels, yerr, and so on.</param> /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param> /// <returns>List of plot items created.</returns> public static List<IGPlotItem> CreatePlotItems(IEnumerable<DataColumn> selectedColumns, G3DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context) { return CreatePlotItems(selectedColumns, null, null, templatePlotStyle, processedColumns, context); }
/// <summary> /// Creates a list of plot items from data columns, using a template plot style. /// </summary> /// <param name="selectedColumns">Columns for which to create plot items.</param> /// <param name="xColumnName">Name of the x column. If it is null or empty, or that column is not found in the table, the current assigned x column is used.</param> /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param> /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like /// labels, yerr, and so on.</param> /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param> /// <returns>List of plot items created.</returns> public static List<IGPlotItem> CreatePlotItems(IEnumerable<DataColumn> selectedColumns, string xColumnName, string yColumnName, G3DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var result = new List<IGPlotItem>(); foreach (DataColumn vcol in selectedColumns) { if (processedColumns.Contains(vcol)) continue; else processedColumns.Add(vcol); var table = DataTable.GetParentDataTableOf(vcol); var tablecoll = DataColumnCollection.GetParentDataColumnCollectionOf(vcol); int groupNumber = tablecoll.GetColumnGroup(vcol); Altaxo.Data.DataColumn xcol, ycol; if (!string.IsNullOrEmpty(xColumnName) && null != table && table.ContainsColumn(xColumnName)) xcol = table[xColumnName]; else xcol = null == table ? null : tablecoll.FindXColumnOf(vcol); if (!string.IsNullOrEmpty(yColumnName) && null != table && table.ContainsColumn(yColumnName)) ycol = table[yColumnName]; else ycol = null == table ? null : tablecoll.FindYColumnOf(vcol); var pa = new XYZColumnPlotData( table, groupNumber, (IReadableColumn)xcol ?? (IReadableColumn)new IndexerColumn(), (IReadableColumn)ycol ?? (IReadableColumn)new ConstantDoubleColumn(0), vcol); var ps = templatePlotStyle != null ? (G3DPlotStyleCollection)templatePlotStyle.Clone() : new G3DPlotStyleCollection(); if (null == table) continue; ErrorBarPlotStyle unpairedPositiveError = null; ErrorBarPlotStyle unpairedNegativeError = null; bool foundMoreColumns = true; for (int idx = 1 + tablecoll.GetColumnNumber(vcol); foundMoreColumns && idx < tablecoll.ColumnCount; idx++) { DataColumn col = table[idx]; switch (tablecoll.GetColumnKind(idx)) { case ColumnKind.Label: var labelStyle = new LabelPlotStyle(col, context); ps.Insert(0, labelStyle); break; case ColumnKind.Err: var errStyle = new ErrorBarZPlotStyle(context); errStyle.UseCommonErrorColumn = true; errStyle.CommonErrorColumn = col as INumericColumn; ps.Add(errStyle); break; case ColumnKind.pErr: if (null != unpairedNegativeError) { unpairedNegativeError.PositiveErrorColumn = col as INumericColumn; ; unpairedNegativeError = null; } else { unpairedPositiveError = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false }; unpairedPositiveError.PositiveErrorColumn = col as INumericColumn; ps.Add(unpairedPositiveError); } break; case ColumnKind.mErr: if (null != unpairedPositiveError) { unpairedPositiveError.NegativeErrorColumn = col as INumericColumn; unpairedPositiveError = null; } else { unpairedNegativeError = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false }; unpairedNegativeError.NegativeErrorColumn = col as INumericColumn; ps.Add(unpairedNegativeError); } break; default: foundMoreColumns = false; break; } if (foundMoreColumns) processedColumns.Add(table[idx]); } result.Add(new XYZColumnPlotItem(pa, ps)); } return result; }
public XYZColumnPlotItem(XYZColumnPlotData pa, G3DPlotStyleCollection ps) { this.Data = pa; this.Style = ps; }
public static int GetIndexOfAvailableNamesPlusCustom(G3DPlotStyleCollection coll) { string name = GetName(coll); if (null == name) return 0; int result = _NamesInOrder.IndexOf(name); return result < 0 ? 0 : result + 1; }
public static List <IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G3DPlotStyleCollection templatePlotStyle) { var selColumns = new List <DataColumn>(selectedColumns.Count); foreach (int i in selectedColumns) { selColumns.Add(table[i]); } return(CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext())); }
private static G3DPlotStyleCollection CreateScatterStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var coll = new G3DPlotStyleCollection(); coll.Add(new ScatterPlotStyle(context)); return coll; }
/// <summary> /// Creates a list of plot items from data columns, using a template plot style. /// </summary> /// <param name="selectedColumns">Columns for which to create plot items.</param> /// <param name="xColumnName">Name of the x column. If it is null or empty, or that column is not found in the table, the current assigned x column is used.</param> /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param> /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like /// labels, yerr, and so on.</param> /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param> /// <returns>List of plot items created.</returns> public static List <IGPlotItem> CreatePlotItems(IEnumerable <DataColumn> selectedColumns, string xColumnName, string yColumnName, G3DPlotStyleCollection templatePlotStyle, HashSet <DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var result = new List <IGPlotItem>(); foreach (DataColumn vcol in selectedColumns) { if (processedColumns.Contains(vcol)) { continue; } else { processedColumns.Add(vcol); } var table = DataTable.GetParentDataTableOf(vcol); var tablecoll = DataColumnCollection.GetParentDataColumnCollectionOf(vcol); int groupNumber = tablecoll.GetColumnGroup(vcol); Altaxo.Data.DataColumn xcol, ycol; if (!string.IsNullOrEmpty(xColumnName) && null != table && table.ContainsColumn(xColumnName)) { xcol = table[xColumnName]; } else { xcol = null == table ? null : tablecoll.FindXColumnOf(vcol); } if (!string.IsNullOrEmpty(yColumnName) && null != table && table.ContainsColumn(yColumnName)) { ycol = table[yColumnName]; } else { ycol = null == table ? null : tablecoll.FindYColumnOf(vcol); } var pa = new XYZColumnPlotData( table, groupNumber, xcol ?? (IReadableColumn) new IndexerColumn(), ycol ?? (IReadableColumn) new ConstantDoubleColumn(0), vcol); var ps = templatePlotStyle != null?templatePlotStyle.Clone() : new G3DPlotStyleCollection(); if (null == table) { continue; } ErrorBarPlotStyle unpairedPositiveError = null; ErrorBarPlotStyle unpairedNegativeError = null; bool foundMoreColumns = true; for (int idx = 1 + tablecoll.GetColumnNumber(vcol); foundMoreColumns && idx < tablecoll.ColumnCount; idx++) { DataColumn col = table[idx]; switch (tablecoll.GetColumnKind(idx)) { case ColumnKind.Label: var labelStyle = new LabelPlotStyle(col, context); ps.Insert(0, labelStyle); break; case ColumnKind.Err: var errStyle = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = true, CommonErrorColumn = col as INumericColumn }; ps.Add(errStyle); break; case ColumnKind.pErr: if (null != unpairedNegativeError) { unpairedNegativeError.PositiveErrorColumn = col as INumericColumn; ; unpairedNegativeError = null; } else { unpairedPositiveError = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false }; unpairedPositiveError.PositiveErrorColumn = col as INumericColumn; ps.Add(unpairedPositiveError); } break; case ColumnKind.mErr: if (null != unpairedPositiveError) { unpairedPositiveError.NegativeErrorColumn = col as INumericColumn; unpairedPositiveError = null; } else { unpairedNegativeError = new ErrorBarZPlotStyle(context) { UseCommonErrorColumn = false }; unpairedNegativeError.NegativeErrorColumn = col as INumericColumn; ps.Add(unpairedNegativeError); } break; default: foundMoreColumns = false; break; } if (foundMoreColumns) { processedColumns.Add(table[idx]); } } result.Add(new XYZColumnPlotItem(pa, ps)); } return(result); }
public static G3DPlotStyleCollection PlotStyle_Line(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { var result = new G3DPlotStyleCollection(); result.Add(new LinePlotStyle(context)); return result; }