示例#1
0
    public void AddSeries(DatedDataCollectionGen<double> series_, string heading_, Color color_, int extent_, string yLabelFormat_)
    {
      DataTable table = series_.ToDataTable();

      NumericTimeSeries nts = new NumericTimeSeries();
      nts.Key = string.Format("Series{0}", heading_);
      nts.Label = heading_;
      nts.PEs.Add(new PaintElement(color_));

      ultraChart.CompositeChart.Series.Add(nts);

      nts.Data.TimeValueColumn = "Date";
      nts.Data.ValueColumn = "Value";

      LineChartAppearance lca = new LineChartAppearance();
      ChartLayerAppearance cla = new ChartLayerAppearance();

      int j = ultraChart.CompositeChart.ChartLayers.Count;

      cla.AxisXKey = "axis1";
      cla.AxisY = findYAxis(extent_, yLabelFormat_);
      //cla.AxisYKey = "axis2";
      cla.ChartAreaKey = "area1";
      cla.ChartType = ChartType.LineChart;
      lca.EndStyle = m_capStyle;
      lca.StartStyle = m_capStyle;
      lca.NullHandling = NullHandling.DontPlot;
      lca.Thickness = LineThickness;
      cla.ChartTypeAppearance = lca;
      cla.Key = string.Format("chartLayer{0}", j.ToString());
      cla.SeriesList = nts.Key;

      ultraChart.CompositeChart.ChartLayers.Add(cla);

      nts.Data.DataSource = table;
      nts.DataBind();

      System.Windows.Forms.CheckBox cb = new System.Windows.Forms.CheckBox();
      cb.Text = heading_;
      cb.AutoSize = true;
      cb.Margin = new Padding(1, 1, 1, 1);
      cb.Tag = j;
      flp.Controls.Add(cb);
      cb.Checked = true;
      cb.CheckedChanged += handleCheckedChanged;
      cb.ForeColor = color_;
      cb.BackColor = Color.FromArgb(15, 15, 15);

      ultraChart.CompositeChart.Legends[0].ChartLayers.Add(cla);

      ultraChart.InvalidateLayers();

    }
    private void setup(ReturnsEval.DataSeriesEvaluator eval_)
    {
      if (doneSetup)
        return;
      doneSetup = true;

      setuptooltip();

      // add the columns

      dt.Columns.Add("Date", typeof(DateTime));
      dt.Columns.Add(eval_.Name, typeof(double));
      for (int i = 0; i < eval_.InnerSeries.Count; ++i)
        dt.Columns.Add(eval_.InnerSeries[i].Name, typeof(double));

      ChartLayerAppearance chart;
      NumericTimeSeries series;
      LineChartAppearance lcApp;

      // example of adding layer in code

      // add numeric series for top
      series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = eval_.Name;
      series.Key = eval_.Name;
      series.Label = eval_.Name;
      ultraChart.CompositeChart.Series.Add(series);

      // add a layer for the overall cumulative at the top
      chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart;
      chart.ChartArea = ultraChart.CompositeChart.ChartAreas.FromKey("areaTop");
      chart.AxisX = chart.ChartArea.Axes.FromKey("areaTopX");
      chart.AxisY = chart.ChartArea.Axes.FromKey("areaTopY");
      chart.ChartType = ChartType.LineChart;
      lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      lcApp.Thickness = 1;
      lcApp.MidPointAnchors = false;
      
      chart.Key = string.Concat("chart_", eval_.Name);
      ultraChart.CompositeChart.ChartLayers.Add(chart);

      // link them all up
      chart.Series.Add(series);
      series.Data.DataSource = dt;
      chart.SeriesList = eval_.Name;
      series.DataBind();

      for (int i = 0; i < eval_.InnerSeries.Count; ++i)
      {

        series = new NumericTimeSeries();
        series.Data.TimeValueColumn = "Date";
        series.Data.ValueColumn = eval_.InnerSeries[i].Name;
        series.Key = eval_.InnerSeries[i].Name;
        series.Label = eval_.InnerSeries[i].Name;
        ultraChart.CompositeChart.Series.Add(series);

        chart = new ChartLayerAppearance();
        chart.ChartComponent = ultraChart;
        chart.ChartArea = ultraChart.CompositeChart.ChartAreas.FromKey("areaBottom");
        chart.AxisX = chart.ChartArea.Axes.FromKey("areaBottomX");
        chart.AxisY = chart.ChartArea.Axes.FromKey("areaBottomY");
        chart.ChartType = ChartType.LineChart;
        lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
        lcApp.Thickness = 1;
        lcApp.MidPointAnchors = false;
        chart.Key = string.Concat("chart_", eval_.InnerSeries[i].Name);
        ultraChart.CompositeChart.ChartLayers.Add(chart);

        // link them all up
        chart.Series.Add(series);
        chart.SeriesList = eval_.InnerSeries[i].Name;
        series.Data.DataSource = dt;
        series.DataBind();

        if (i < COLOURS.Length)
          series.PEs.Add(new PaintElement(COLOURS[i]));

        ultraChart.CompositeChart.Legends[0].ChartLayers.Add(chart);
      }
    }
示例#3
0
    public void Create(DatedDataCollectionGen<double> values_, DatedDataCollectionGen<double> zoneLookup_, IList<ZoneDefinition> zones_)
    {
      while (ultraChart.CompositeChart.ChartAreas.Count > 1)
        ultraChart.CompositeChart.ChartAreas.RemoveAt(1);

      ultraChart.Dock = DockStyle.None;
      ultraChart.Anchor=AnchorStyles.Bottom|AnchorStyles.Top|AnchorStyles.Right|AnchorStyles.Left;
      ultraChart.Location=new Point(0,0);
      ultraChart.Size=new Size(Size.Width,Size.Height-40);

      if (flp == null)
      {
        flp = new FlowLayoutPanel();
        flp.Size = new Size(Width, 40);
        flp.Dock = DockStyle.Bottom;
        Controls.Add(flp);
      }

      flp.Controls.Clear();

      ultraChart.CompositeChart.ChartLayers.Clear();
      ultraChart.CompositeChart.Series.Clear();
      ultraChart.CompositeChart.Legends[0].ChartLayers.Clear();
      dt.Rows.Clear();
      dt.Columns.Clear();

      // add columns into datatable
      dt.Columns.Add("Date", typeof(DateTime));
      for (int i = 0; i < zones_.Count; ++i)
      {
        dt.Columns.Add(zones_[i].Name, typeof(double));
        zones_[i].Index = i;
      }

      // add first row
      DataRow row = dt.NewRow();
      row[0] = zoneLookup_.Dates[0];
      dt.Rows.Add(row);

      double prevPrice = values_.ValueOnDate(zoneLookup_.Dates[0]);
      double low = double.MaxValue;
      double high = double.MinValue;

      for (int d = 1; d < zoneLookup_.Length; ++d)
      {
        DateTime date = zoneLookup_.Dates[d];
        DataRow newRow = dt.NewRow();
        newRow[0] = date;
        double px = values_.ValueOnDate(date);
        double score = zoneLookup_.ValueOnDate(date);

        low = Math.Min(low, px);
        high = Math.Max(high, px);

        for (int i = 0; i < zones_.Count; ++i)
        {
          if (zones_[i].Matches(score))
          {
            newRow[i + 1] = px;
            dt.Rows[dt.Rows.Count - 1][i + 1] = prevPrice;
            break;
          }
        }
        prevPrice = px;
        dt.Rows.Add(newRow);
      }
      


      // create the layers for each heading

      for(int j=0;j<zones_.Count;++j)
      {
        string heading = zones_[j].Name;
        NumericTimeSeries nts = new NumericTimeSeries();
        nts.Key = string.Format("Series{0}",heading);
        nts.Label = heading;
        nts.PEs.Add(new PaintElement(zones_[j].LineColour));

        ultraChart.CompositeChart.Series.Add(nts);

        nts.Data.TimeValueColumn = "Date";
        nts.Data.ValueColumn = heading;

        LineChartAppearance lca = new LineChartAppearance();
        ChartLayerAppearance cla = new ChartLayerAppearance();

        cla.AxisXKey = "axis1";
        cla.AxisYKey = "axis2";
        cla.ChartAreaKey = "area1";
        cla.ChartType = ChartType.LineChart;
        lca.EndStyle = m_capStyle;
        lca.StartStyle = m_capStyle;
        lca.NullHandling=NullHandling.DontPlot;
        lca.Thickness = LineThickness;
        cla.ChartTypeAppearance = lca;
        cla.Key = string.Format("chartLayer{0}",j.ToString());
        cla.SeriesList = nts.Key;
        

        ultraChart.CompositeChart.ChartLayers.Add(cla);

        AxisItem ai = ultraChart.CompositeChart.ChartAreas[0].Axes.FromKey("axis2");
        {
          ai.RangeType = AxisRangeType.Custom;
          ai.RangeMin = low;
          ai.RangeMax = high;
        }

        nts.Data.DataSource = dt;
        nts.DataBind();

        System.Windows.Forms.CheckBox cb = new System.Windows.Forms.CheckBox();
        cb.Text = heading;
        cb.AutoSize = true;
        cb.Margin = new Padding(1, 1, 1, 1);
        cb.Tag = j;
        flp.Controls.Add(cb);
        cb.Checked = true;
        cb.CheckedChanged += handleCheckedChanged;
        cb.ForeColor = zones_[j].LineColour;
        cb.BackColor = Color.FromArgb(15,15,15);

        //ultraChart.CompositeChart.ChartLayers.Add(cla);
        ultraChart.CompositeChart.Legends[0].ChartLayers.Add(cla);
      }

      ultraChart.InvalidateLayers();
    }
示例#4
0
        private void GetAllSeriesFromRecord(List <SnapshotRecordNew> Record, out NumericTimeSeries PriceSeries,
                                            out NumericTimeSeries BuyerVolumeSeries, out NumericTimeSeries SellerVolumeSeries,
                                            out NumericTimeSeries VolumeSeries, out NumericTimeSeries BuyerSellerRatioSeries)
        {
            NumericTimeSeries PS  = new NumericTimeSeries();
            NumericTimeSeries BVS = new NumericTimeSeries();
            NumericTimeSeries SVS = new NumericTimeSeries();
            NumericTimeSeries VS  = new NumericTimeSeries();
            NumericTimeSeries BSR = new NumericTimeSeries();

            PS.Label  = "Price";
            BVS.Label = "Buyer Volume";
            SVS.Label = "Seller Volume";
            VS.Label  = "Volume";
            BSR.Label = "Buyer Seller Ratio";

            List <EODSnapshotAggregateNew> Aggregates = UIUtils.ProcessingInst.GetAggregateSnapshotNew(Record);

            double PP, VP;
            float  TBVP, TSVP;
            float  BSRatio;

            for (ushort i = 0; i < Aggregates.Count; i++)
            {
                try
                {
                    PP = (Aggregates[i].LastTradePrice == 0)
                        ? (Aggregates[i - 1].LastTradePrice)
                        : Aggregates[i].LastTradePrice;

                    VP = (Aggregates[i].TotalVolume == 0)
                        ? (Aggregates[i - 1].TotalVolume)
                        : Aggregates[i].TotalVolume;

                    TBVP = (Aggregates[i].TotalBuyerVolume == 0)
                        ? (Aggregates[i - 1].TotalBuyerVolume)
                        : Aggregates[i].TotalBuyerVolume;

                    TSVP = (Aggregates[i].TotalSellerVolume == 0)
                        ? (Aggregates[i - 1].TotalSellerVolume)
                        : Aggregates[i].TotalSellerVolume;

                    BSRatio = (Aggregates[i].BuyerSellerRatio == 0) || (Aggregates[i].BuyerSellerRatio > 100)
                        ? (Aggregates[i - 1].BuyerSellerRatio)
                        : Aggregates[i].BuyerSellerRatio;

                    PS.Points.Add(new NumericTimeDataPoint(DateTime.Parse(Aggregates[i].Date), PP, "", false));
                    BVS.Points.Add(new NumericTimeDataPoint(DateTime.Parse(Aggregates[i].Date), double.Parse(TBVP.ToString()), "", false));
                    SVS.Points.Add(new NumericTimeDataPoint(DateTime.Parse(Aggregates[i].Date), double.Parse(TSVP.ToString()), "", false));
                    VS.Points.Add(new NumericTimeDataPoint(DateTime.Parse(Aggregates[i].Date), VP, "", false));
                    BSR.Points.Add(new NumericTimeDataPoint(DateTime.Parse(Aggregates[i].Date), BSRatio, "", false));
                }
                catch (Exception)
                {
                }
            }

            PS.PEs.Add(new PaintElement(Color.LawnGreen));
            BVS.PEs.Add(new PaintElement(Color.Indigo));
            SVS.PEs.Add(new PaintElement(Color.OrangeRed));
            VS.PEs.Add(new PaintElement(Color.Blue));
            BSR.PEs.Add(new PaintElement(Color.Coral));

            PriceSeries            = PS;
            BuyerVolumeSeries      = BVS;
            SellerVolumeSeries     = SVS;
            VolumeSeries           = VS;
            BuyerSellerRatioSeries = BSR;
        }
    public ChartLayerAppearance AddBottomSeries(DateTime[] dates_, double[] values_, string desc_, Color lineColor_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero)
    {
      if (dates_ == null || dates_.Length == 0) return null;
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
      {
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);
      }

      var series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = desc_;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(lineColor_));
      ultraChart1.CompositeChart.Series.Add(series);

      var chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart1;
      chart.ChartArea = ultraChart1.CompositeChart.ChartAreas.FromKey("areaBottom");
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = chart.ChartArea.Axes[1];
      chart.ChartType = ChartType.LineChart;
      var lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      lcApp.Thickness = 2;
      lcApp.MidPointAnchors = false;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_chart", desc_);
      ultraChart1.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      series.DataBind();

      m_datatables.Add(desc_, d);

      return chart;
    }
    public ChartLayerAppearance AddSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, object nanReplaceValue = null, NullHandling nullHandling_ = NullHandling.Zero, int yAxisExtent_=15, string yAxisFormat_=null)
    {
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
      {
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanReplaceValue }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);
      }

      ChartLayerAppearance chart;
      NumericTimeSeries series;
      LineChartAppearance lcApp;

      series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = desc_;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(ColorAttribute.GetColor(ultraChart.CompositeChart.Series.Count)));
      ultraChart.CompositeChart.Series.Add(series);

      chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart;
      chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_];
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = findYAxis(areaIndex_, yAxisExtent_, yAxisFormat_ == null ? m_yAxisLabelFormatString : yAxisFormat_);
      chart.ChartType = ChartType.LineChart;
      lcApp = (LineChartAppearance)chart.ChartTypeAppearance;
      lcApp.Thickness = 2;
      lcApp.MidPointAnchors = false;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_{1}_chart_l",areaIndex_, desc_);
      ultraChart.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      chart.Series.Add(series);
      series.DataBind();


      return chart;
    }
    public ChartLayerAppearance AddScatterSeries(int areaIndex_, DateTime[] dates_, double[] values_, string desc_, Color color_, object nanREplaceValue_ = null, NullHandling nullHandling_ = NullHandling.Zero)
    {
      DataTable d = new DataTable();
      d.Columns.Add("Date", typeof(DateTime));
      d.Columns.Add(desc_, typeof(double));

      for (int i = 0; i < dates_.Length; ++i)
        if (double.IsNaN(values_[i]))
          d.LoadDataRow(new object[] { dates_[i], nanREplaceValue_ }, true);
        else
          d.LoadDataRow(new object[] { dates_[i], values_[i] }, true);

      ChartLayerAppearance chart;
      NumericTimeSeries series;
      ScatterChartAppearance lcApp;

      series = new NumericTimeSeries();
      series.Data.TimeValueColumn = "Date";
      series.Data.ValueColumn = desc_;
      series.Key = string.Format("{0}_{1}_sc", areaIndex_, desc_); ;
      series.Label = desc_;
      series.PEs.Add(new PaintElement(color_));
      ultraChart.CompositeChart.Series.Add(series);

      chart = new ChartLayerAppearance();
      chart.ChartComponent = ultraChart;
      chart.ChartArea = ultraChart.CompositeChart.ChartAreas[areaIndex_];
      chart.AxisX = chart.ChartArea.Axes[0];
      chart.AxisY = chart.ChartArea.Axes[1];
      chart.ChartType = ChartType.ScatterChart;
      lcApp = (ScatterChartAppearance)chart.ChartTypeAppearance;
      lcApp.ConnectWithLines = false;
      lcApp.Icon = SymbolIcon.Circle;
      lcApp.IconSize = SymbolIconSize.Medium;
      lcApp.NullHandling = nullHandling_;

      chart.Key = string.Format("{0}_{1}_sc_chart", areaIndex_, desc_);
      ultraChart.CompositeChart.ChartLayers.Add(chart);

      chart.Series.Add(series);
      series.Data.DataSource = d;
      chart.Series.Add(series);
      series.DataBind();

      dts.Add(d);
      //m_yAxisDescriptionToFormat[desc_] = yLabelFormat_;

      return chart;
    }
    private void addAreas()
    {

      if (ultraChart.CompositeChart.ChartAreas.Count > 2)
        return;

      ultraChart.CompositeChart.ChartAreas.Clear();

      int areaWidth = (int)100 / m_cols;
      int areaHeight = (int)100 / m_rows;

      for (int i = 0; i < m_data.Count(); ++i)
      {
        Label l = new Label();
        l.Font = new Font("Tahoma", 5.75F, FontStyle.Regular);
        l.Text = m_data[i].Item1;
        l.ForeColor = Color.White;
        Controls.Add(l);
        l.BringToFront();
        l.BackColor = Color.White;
        l.AutoSize = true;
        lbls.Add(l);

        ChartArea area = new ChartArea();
        AxisItem xAxis = new AxisItem();
        AxisItem yAxis = new AxisItem();

        xAxis.Key = string.Format("xAxis_{0}", i.ToString());
        xAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Time;
        xAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.VerticalLeftFacing;
        xAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom;
        xAxis.Labels.ItemFormatString = string.Format("<ITEM_LABEL:{0}>",m_xAxisLabelFormatString);
        xAxis.Labels.Font = new Font("Tahoma", 5.75F);
        xAxis.MajorGridLines.Visible = true;
        xAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.X_Axis;
        xAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries;
        xAxis.Extent = 20;

        yAxis.Key = string.Format("yAxis_{0}", i.ToString());
        yAxis.DataType = Infragistics.UltraChart.Shared.Styles.AxisDataType.Numeric;
        yAxis.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal;
        yAxis.Labels.ItemFormat = Infragistics.UltraChart.Shared.Styles.AxisItemLabelFormat.Custom;
        yAxis.Labels.HorizontalAlign = StringAlignment.Near;
        yAxis.Labels.Font = new Font("Tahoma", 5.75F);
        yAxis.Labels.ItemFormatString = string.Format("<DATA_VALUE:{0}>", m_yAxisLabelFormatString);
        yAxis.MajorGridLines.Visible = true;
        yAxis.OrientationType = Infragistics.UltraChart.Shared.Styles.AxisNumber.Y_Axis;
        yAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.SetLabelAxisType.GroupBySeries;
        yAxis.Extent = 15;

        area.Axes.Add(xAxis);
        area.Axes.Add(yAxis);
        area.Key = string.Format("area_{0}", i.ToString());

        int x = i, y = 0;

        while (x > (m_cols-1))
        {
          ++y;
          x -= m_cols;
        }

        area.Bounds = new Rectangle(areaWidth * x, areaHeight * y, areaWidth, areaHeight);
        area.BoundsMeasureType = Infragistics.UltraChart.Shared.Styles.MeasureType.Percentage;

        ultraChart.CompositeChart.ChartAreas.Add(area);

        for (int j = 0; j < 1; ++j)
        {
          DataTable d = new DataTable();
          d.Columns.Add("Date", typeof(DateTime));
          d.Columns.Add("Px", typeof(double));

          NumericTimeSeries ns = new NumericTimeSeries();
          ns.Data.TimeValueColumn = "Date";
          ns.Data.ValueColumn = "Px";
          ns.Key = string.Format("series_{0}_{1}", i.ToString(), j.ToString());
          ultraChart.CompositeChart.Series.Add(ns);

          ChartLayerAppearance chart = new ChartLayerAppearance();
          chart.ChartComponent = ultraChart;
          chart.ChartArea = area;
          chart.AxisX = area.Axes[0];
          chart.AxisY = area.Axes[1];
          chart.ChartType = ChartType.LineChart;
          chart.Key = string.Format("chart_{0}_{1}", i.ToString(), j.ToString());

          LineChartAppearance lca = (LineChartAppearance)chart.ChartTypeAppearance;
          lca.Thickness = 1;
          lca.MidPointAnchors = false;
          lca.EndStyle = LineCapStyle.NoAnchor;

          ultraChart.CompositeChart.ChartLayers.Add(chart);
          chart.Series.Add(ns);
          ns.Data.DataSource = d;
          chart.SeriesList = ns.Key;
          ns.DataBind();
          ns.PEs.Add(new PaintElement(Color.LightGray));

          dts.Add(d);
        }
      }

    }