Exemplo n.º 1
0
        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 <SizeLegendItemDto> Execute(GetSizeLegendItemsQuery query)
        {
            var scatterPlot = _repository.Get <ScatterPlot>();

            var layout = scatterPlot.GetLayout();

            var column = layout.SizeColumn;

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

            var type = column.DataType;

            var map = _mapFactory.CreateSizeMap(column, layout.LowerSize, layout.UpperSize, layout.SizeSortOrder);

            var items = _legendFactory.Create(type, map, column.Values, layout.LowerSize, layout.UpperSize);

            return(items.ToList());
        }