コード例 #1
0
    public void Create(ConstructGen<double> wts_, FXGroup[] groups_)
    {
      ConstructGen<double> groupConv = new ConstructGen<double>(groups_.Length);
      groupConv.ColumnHeadings = groups_.Select(x => x.ToString()).ToArray();
      Currency[] ccys = wts_.ColumnHeadings.Select(x => Singleton<FXIDs>.Instance[x]).ToArray();

      List<int[]> indicies =new List<int[]>();

      foreach(FXGroup group in groups_)
      {
        List<int> groupIndicies=new List<int>();
        for(int i=0;i<ccys.Length;++i)
          if(ccys[i].IsGroup(group))
            groupIndicies.Add(i);
        
        indicies.Add(groupIndicies.ToArray());
      }

      foreach (DateTime date in wts_.Dates)
      {
        double[] dateWeights = wts_.GetValues(date);
        double[] buckets = new double[groups_.Length];

        for(int g=0;g<groups_.Length;++g)
          foreach (int index in indicies[g])
            buckets[g] += dateWeights[index];

        groupConv.SetValues(date, buckets);
      }

      DataTable dt1 = groupConv.ToDataTable(groupConv.ColumnHeadings, "Date", "dd-MMM-yyyy");

      Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.Composite;

      ChartArea area = new ChartArea();
      Chart.CompositeChart.ChartAreas.Add(area);

      AxisItem axisY = new AxisItem();
      axisY.Extent = 50;
      axisY.DataType = AxisDataType.Numeric;
      axisY.OrientationType = AxisNumber.Y_Axis;
      axisY.LineColor = Color.Blue;
      axisY.Labels.Visible = true;
      area.Axes.Add(axisY);

      AxisItem axisX = new AxisItem();
      axisX.DataType = AxisDataType.String;
      axisX.Extent = 80;
      axisX.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries;
      axisX.OrientationType = AxisNumber.X_Axis;
      axisX.LineColor = Color.Blue;
      axisX.Labels.Orientation = TextOrientation.VerticalLeftFacing;
      axisX.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing;
      area.Axes.Add(axisX);

      AxisItem axisX2 = new AxisItem();
      axisX2.DataType = AxisDataType.String;
      axisX2.Extent = 80;
      axisX2.OrientationType = AxisNumber.X_Axis;
      axisX2.LineColor = Color.Blue;
      axisX2.Labels.Orientation = TextOrientation.VerticalLeftFacing;
      axisX2.Labels.SeriesLabels.Orientation = TextOrientation.VerticalLeftFacing;
      axisX2.SetLabelAxisType = SetLabelAxisType.ContinuousData;
      area.Axes.Add(axisX2);

      ChartLayerAppearance myColumnLayer = new ChartLayerAppearance();
      myColumnLayer.ChartType = ChartType.StackColumnChart;
      myColumnLayer.ChartArea = area;

      foreach (FXGroup group in groups_)
      {
        NumericSeries series1 = new NumericSeries();
        series1.Key = group.ToString();
        series1.DataBind(dt1, group.ToString(), "Date");
        series1.PEs.Add(new PaintElement(ColorAttribute.GetAttribute(group).Color));
        myColumnLayer.Series.Add(series1);
        Chart.CompositeChart.Series.Add(series1);
      }

      DataTable dt2 = wts_.SumRows().ToDataTable(format_:"dd-MMM-yyyy");

      ChartLayerAppearance myColumnLayer2 = new ChartLayerAppearance();
      myColumnLayer2.ChartType = ChartType.LineChart;
      myColumnLayer2.ChartArea = area;

      NumericSeries seriesA = new NumericSeries();
      seriesA.Key = "Sum of Wts";
      seriesA.DataBind(dt2, "Value", "Date");
      seriesA.PEs.Add(new PaintElement(Color.Orange));
      myColumnLayer2.Series.Add(seriesA);
      Chart.CompositeChart.Series.Add(seriesA);


      LineChartAppearance la = new LineChartAppearance();
      la.Thickness = 4;
      myColumnLayer2.ChartTypeAppearance = la;


      myColumnLayer.AxisX = axisX;
      myColumnLayer.AxisY = axisY;

      myColumnLayer2.AxisX = axisX2;
      myColumnLayer2.AxisY = axisY;

      myColumnLayer.SwapRowsAndColumns = true;
      this.Chart.CompositeChart.ChartLayers.Add(myColumnLayer);
      this.Chart.CompositeChart.ChartLayers.Add(myColumnLayer2);

      EstablishDefaultTooltip();
      m_wts = wts_;
      m_groups = groups_;
      pbSplitIntoYears.BringToFront();
    }