public List <Plot> RenderPlots(List <Row> rows, ScatterPlotLayout layout) { var xAxisMap = layout.XAxisColumn != null ? _factory.CreateAxisMap(layout.XAxisColumn, 0d, 1d, layout.XAxisSortOrder) : null; var yAxisMap = layout.YAxisColumn != null ? _factory.CreateAxisMap(layout.YAxisColumn, 0d, 1d, layout.YAxisSortOrder) : null; var colorMap = layout.ColorColumn != null ? _factory.CreateColorMap(layout.ColorColumn, layout.ColorPalette, layout.ColorSortOrder) : null; var sizeMap = layout.SizeColumn != null ? _factory.CreateSizeMap(layout.SizeColumn, layout.LowerSize, layout.UpperSize, layout.SizeSortOrder) : null; var labelMap = layout.LabelColumn != null ? _factory.CreateLabelMap(layout.LabelColumn) : null; var plots = new List <Plot>(); foreach (var row in rows) { var plot = new Plot(); plot.Id = row.Id; plot.X = layout.XAxisColumn != null ? xAxisMap.Map(row[layout.XAxisColumn.Index]) ?? 0.0 : 0.0; plot.Y = layout.YAxisColumn != null ? yAxisMap.Map(row[layout.YAxisColumn.Index]) ?? 0.0 : 0.0; plot.Color = layout.ColorColumn != null ? colorMap.Map(row[layout.ColorColumn.Index]) : DefaultColor; plot.Size = layout.SizeColumn != null ? sizeMap.Map(row[layout.SizeColumn.Index]) ?? 0.0 : layout.UpperSize; plot.Image = layout.ShapeColumn != null ? (BitmapImage)row[layout.ShapeColumn.Index] : null; plot.Label = layout.LabelColumn != null ? labelMap.Map(row[layout.LabelColumn.Index]) : null; plots.Add(plot); } return(plots); }
public List <ColorLegendItemDto> Execute(GetColorLegendItemsQuery query) { var scatterPlot = _viewRepository.Get <ScatterPlot>(); var layout = scatterPlot.GetLayout(); var column = layout.ColorColumn; if (column == null) { return(new List <ColorLegendItemDto>()); } var type = column.DataType; var palette = layout.ColorPalette; var map = _mapFactory.CreateColorMap(column, palette, layout.ColorSortOrder); var items = _legendFactory.Create(type, map, column.Values, palette); return(items.ToList()); }