/// <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); }
/// <summary> /// Plots a density image of the selected columns. /// </summary> /// <param name="dg"></param> /// <param name="bLine"></param> /// <param name="bScatter"></param> public static void PlotDensityImage(GUI.WorksheetController dg, bool bLine, bool bScatter) { DensityImagePlotStyle plotStyle = new DensityImagePlotStyle(); // if nothing is selected, assume that the whole table should be plotted int len = dg.SelectedDataColumns.Count; XYZMeshedColumnPlotData assoc = new XYZMeshedColumnPlotData(dg.Doc.DataColumns, len == 0 ? null : dg.SelectedDataColumns); // now create a new Graph with this plot associations Altaxo.Graph.GUI.IGraphController gc = Current.ProjectService.CreateNewGraph(); IGPlotItem pi = new DensityImagePlotItem(assoc, plotStyle); gc.Doc.Layers[0].PlotItems.Add(pi); }