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);
        }
Beispiel #2
0
        public List <AxisGridLine> Execute(GetXAxisGridLinesQuery query)
        {
            var view = _viewRepository.Get <ScatterPlot>();

            var viewExtent = view.GetViewExtent();

            var layout = view.GetLayout();

            var column = layout.XAxisColumn;

            if (column == null)
            {
                return(new List <AxisGridLine>());
            }

            var map = _mapFactory.CreateAxisMap(column, 0d, 1d, layout.XAxisSortOrder);

            var values = column.Values
                         .Distinct()
                         .ToList();

            var axisLines = _gridLineFactory.Create(column.DataType, map, values, viewExtent.Left, viewExtent.Right);

            return(axisLines.ToList());
        }