烛台图表仅以绿色显示蜡烛

时间:2019-10-27 01:40:25

标签: mschart

enter image description here我正在使用MS图表显示烛台图表。该图表仅以绿色显示蜡烛,与蜡烛的关闭无关。我在下面的代码中做错了什么

        // Set the data
        using (StockContext ctx = new StockContext())
        {
            ohlc = (from stk in ctx.StockOHLCs
                    where stk.Stock.Symbol == symbol
                    orderby stk.OHLCDateTime
                    select stk).ToList();

            stockLow = ctx.StockOHLCs.Where(x => x.Stock.Symbol == symbol).Min(x => x.Low);
            stockHigh = ctx.StockOHLCs.Where(x => x.Stock.Symbol == symbol).Max(x => x.High);
        }

        Series oneMinutePrice = new Series("OneMinute");
        ChartCandleStick.Series.Add(oneMinutePrice);
        ChartCandleStick.Series["OneMinute"].ChartType = SeriesChartType.Candlestick;
        ChartCandleStick.Series["OneMinute"]["OpenCloseStyle"] = "Triangle";
        ChartCandleStick.Series["OneMinute"]["ShowOpenClose"] = "Both";
        ChartCandleStick.Series["OneMinute"]["PointWidth"] = "0.5";
        ChartCandleStick.Series["OneMinute"].CustomProperties = "PriceDownColor=Red,PriceUpColor=Green";
        ChartCandleStick.Series["OneMinute"].BorderColor = Color.Transparent;
        ChartCandleStick.Series["OneMinute"].XValueMember = "OHLCDateTime";
        ChartCandleStick.Series["OneMinute"].XValueType = ChartValueType.Time;
        ChartCandleStick.Series["OneMinute"].YValueMembers = "Open, High, Low, Close";
        ChartCandleStick.Series["OneMinute"].YValueType = ChartValueType.Double;

        ch = ChartCandleStick.ChartAreas[0];
        ch.AxisX.IntervalType = DateTimeIntervalType.Minutes;
        ch.AxisX.Interval = 1;
        ch.AxisX.MajorGrid.LineWidth = 0;
        ch.AxisY.MajorGrid.LineWidth = 0;
        ch.AxisY.Minimum = stockLow;
        ch.AxisY.Maximum = stockHigh;

        ChartCandleStick.DataManipulator.IsStartFromFirst = true;
        ChartCandleStick.DataSource = ohlc;
        ChartCandleStick.DataBind();

0 个答案:

没有答案