/// <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 Altaxo.Gui.Graph.Gdi.Viewing.IGraphController Plot( DataTable table, IAscendingIntegerCollection selectedColumns, Graph.Gdi.GraphDocument graph, G2DPlotStyleCollection templatePlotStyle, PlotGroupStyleCollection groupStyles) { List <IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle); // now create a new Graph with this plot associations var gc = Current.ProjectService.CreateNewGraph(graph); var xylayer = gc.Doc.RootLayer.Layers.OfType <Altaxo.Graph.Gdi.XYPlotLayer>().First(); // Set x and y axes according to the first plot item in the list if (pilist.Count > 0 && (pilist[0] is XYColumnPlotItem)) { var firstitem = (XYColumnPlotItem)pilist[0]; if (firstitem.Data.XColumn is TextColumn) { xylayer.Scales[0] = new TextScale(); } else if (firstitem.Data.XColumn is DateTimeColumn) { xylayer.Scales[0] = new DateTimeScale(); } if (firstitem.Data.YColumn is TextColumn) { xylayer.Scales[1] = new TextScale(); } else if (firstitem.Data.YColumn is DateTimeColumn) { xylayer.Scales[1] = new DateTimeScale(); } } var newPlotGroup = new PlotItemCollection(xylayer.PlotItems); foreach (IGPlotItem pi in pilist) { newPlotGroup.Add(pi); } if (groupStyles != null) { newPlotGroup.GroupStyles = groupStyles; } else { newPlotGroup.CollectStyles(newPlotGroup.GroupStyles); } xylayer.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, Graph.Gdi.GraphDocument graph, G2DPlotStyleCollection templatePlotStyle, PlotGroupStyleCollection groupStyles) { List <IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle); // now create a new Graph with this plot associations Altaxo.Graph.GUI.IGraphController gc = Current.ProjectService.CreateNewGraph(graph); // Set x and y axes according to the first plot item in the list if (pilist.Count > 0 && (pilist[0] is XYColumnPlotItem)) { XYColumnPlotItem firstitem = (XYColumnPlotItem)pilist[0]; if (firstitem.Data.XColumn is TextColumn) { gc.Doc.Layers[0].LinkedScales.SetScale(0, new Graph.Scales.TextScale()); } else if (firstitem.Data.XColumn is DateTimeColumn) { gc.Doc.Layers[0].LinkedScales.SetScale(0, new Graph.Scales.DateTimeScale()); } if (firstitem.Data.YColumn is TextColumn) { gc.Doc.Layers[0].LinkedScales.SetScale(1, new Graph.Scales.TextScale()); } else if (firstitem.Data.YColumn is DateTimeColumn) { gc.Doc.Layers[0].LinkedScales.SetScale(1, new Graph.Scales.DateTimeScale()); } } PlotItemCollection newPlotGroup = new PlotItemCollection(gc.Doc.Layers[0].PlotItems); foreach (IGPlotItem pi in pilist) { newPlotGroup.Add(pi); } if (groupStyles != null) { newPlotGroup.GroupStyles = groupStyles; } else { newPlotGroup.CollectStyles(newPlotGroup.GroupStyles); } gc.Doc.Layers[0].PlotItems.Add(newPlotGroup); return(gc); }