예제 #1
0
        // ������� ����� �� ��������
        private void UpdateSummary(ReportPart part, ref int row, params BookColumns[] Book�olumnsArray)
        {
            BookColumns columns = BookColumns.Merge(Book�olumnsArray);
              int MaxRowOffset = 0;
              bool ContainsSummary = false;
              bool ContainsMinMaxAvg = false;
              foreach (BookColumn column in columns)
            if (column.formulatype != FormulaType.None && column.column1 == column.column2 && !column.isgroup)
              switch (column.formulatype)
              {
            case FormulaType.Summary:
              DataResult = GetResultForColumn(part, cMass);
              if (DataResult == null)
                break;
              FM.DrawCell(row, cMass.column1 - 1, "�����", AlignmentEnum.RightCenter);
              FM.DrawCell(row, cMass.column1, DataResult.Calculate(DataResult.Columns[0].ColumnName, new SummaryCalculation()), AlignmentEnum.RightCenter);
              MaxRowOffset = Math.Max(MaxRowOffset, 1);
              ContainsSummary = true;
              break;
            case FormulaType.MinMaxAvg:
              DataResult = GetResultForColumn(part, cMass, column);
              if (DataResult == null)
                break;
              part.RowMin = row;
              part.RowMax = row + 1;
              part.RowAvg = row + 2;
              FM.DrawCell(part.RowMin, StaticColumns.LastColumn, "�������", AlignmentEnum.RightCenter);
              FM.DrawCell(part.RowMax, StaticColumns.LastColumn, "��������", AlignmentEnum.RightCenter);
              FM.DrawCell(part.RowAvg, StaticColumns.LastColumn, "��.�����.", AlignmentEnum.RightCenter);

              FM.DrawCell(part.RowMin, column.column1, DataResult.Calculate(DataResult.Columns[1].ColumnName, new MininumCalculation()), AlignmentEnum.RightCenter);
              FM.DrawCell(part.RowMax, column.column1, DataResult.Calculate(DataResult.Columns[1].ColumnName, new MaximumCalculation()), AlignmentEnum.RightCenter);

              object avg = DataResult.Calculate(new string[] { DataResult.Columns[0].ColumnName, DataResult.Columns[1].ColumnName }, new AverageWeightCalculation());
              if (Functions.IsNull(avg))
                avg = DataResult.Calculate(new string[] { DataResult.Columns[1].ColumnName }, new AverageCalculation());
              FM.DrawCell(part.RowAvg, column.column1, avg, AlignmentEnum.RightCenter);

              MaxRowOffset = Math.Max(MaxRowOffset, 3);
              ContainsMinMaxAvg = true;
              break;
            default:
              throw new Exception("Unknown formula type for column "+column.header);
              }
              if (ContainsSummary)
            FM.SetBorder(row, cMass.column1 - 1, row, cMass.column1, LineStyleEnum.Thin).BackColor = Color.LightGray;
              if (ContainsMinMaxAvg)
            FM.SetBorder(row, StaticColumns.LastColumn, row + 2, columns.LastColumn, LineStyleEnum.Thin).BackColor = Color.LightGray;

              part.SummaryRow1 = row;
              part.SummaryRow2 = row + MaxRowOffset - 1;
              row = row + MaxRowOffset;
        }
예제 #2
0
        // сводный график
        private void DisplaySingleChart()
        {
            Charts = new TChart[1];
              Charts[0] = new TChart();
              TChart chart = Charts[0];
              InitializeChart(chart);

              chart.Legend.Visible = true;
              chart.Legend.CheckBoxes = true;
              chart.Legend.Alignment = LegendAlignments.Bottom;
              chart.Header.Text = FilledDatas[0][0, "Module"].ToString() + ", " + FilledDatas[0][0, "Norm"].ToString();
              chart.Axes.Bottom.Title.Text = "Дата";

              Line lower = NewChartLine(chart, 0, 2, Color.Red, "Нижний предел", false);
              Line upper = NewChartLine(chart, 0, 2, Color.Red, "Верхний предел", false);
              Line avg = null;
              object avgvalue = 0;
              if (IsOneAverage)
              {
            avg = NewChartLine(chart, 0, 2, Color.Lime, "Средневзвешенное значение", false);
            QueryResult avgdata = new QueryResult();
            avgdata.Columns.Add("Average");
            foreach (QueryResult ChartData in FilledDatas)
              if (ChartData.Columns.Contains("Average"))
            avgdata.Rows.Add(ChartData[0, "Average"]);
            avgvalue = avgdata.Calculate("Average", new AverageCalculation()); // вычисляем
              }

              for (int i = 0; i < FilledDatas.Count; i++)
              {
            QueryResult ChartData = FilledDatas[i];

            Line line = NewChartLine(chart, 0, 2, PlantColors[i%PlantColors.Count], ChartData[0, "PlantName"].ToString(), true);
            line.Function = new Steema.TeeChart.Functions.Average(false);

            line.DataSource = ChartData;

            if (!IsOneAverage)
              avg = NewChartLine(chart, 0, 2, line.Color, ChartData[0, "PlantName"].ToString()+": Средневзвешенное значение", false);

            AddDataToChart(ChartData, line, avg, lower, upper, IsOneAverage?avgvalue:null);

            //avg.Function = new Steema.TeeChart.Functions.Average(false);
              }
        }