为什么此RadHTMLChart中的系列会停止加载?

时间:2017-01-24 14:26:56

标签: c# asp.net telerik series radhtmlchart

我试图在Telerik Web项目中与Telerik一起做RadHtmlChart,到目前为止它正在工作,但由于某种原因,系列点的加载不再发生,并且为了所有诚实,我不会&#39 ;知道在哪里看。

以下是代码(包含RadHTMLChart的所有配置和加载的方法):

private void LoadChartG1()
    {
        chartEjercicios.Appearance.FillStyle.BackgroundColor = Color.White;

        List<ItemEmbalseCota> newListCota = new List<ItemEmbalseCota>();
        List<ItemAbstract> newListPeriodosBaseXAxis = new List<ItemAbstract>();

        if (rcbxEjercicioMultiple.CheckedItems.Count() <= 0)
        {
            rcbxEjercicioMultiple.Items.Where(c => c.Value == /*DateTime.Now.ToString("yyyy")*/"2016").FirstOrDefault().Checked = true;
        }

        newListCota.Clear();
        foreach (var item in rcbxEjercicioMultiple.CheckedItems)
        {
            if (!(rcbxEjercicioMultiple.CheckedItems.Count <= 0))
            {
                //This method load the info from a Web-Server database from the year that correspond
                newListCota = new ExcelInfo().OBT_R06_EmbalseCorrespondienteConCotasAnno(Convert.ToInt32(rcbxEmbalse.SelectedValue), Convert.ToInt32(item.Value));
            }
        }

        //set up chart title
        var chartTitle = chartEjercicios.ChartTitle;
        chartTitle.Text = "Server CPU Load by Days";
        chartTitle.Appearance.Align = ChartTitleAlign.Center;
        chartTitle.Appearance.BackgroundColor = Color.White;
        chartTitle.Appearance.Position = ChartTitlePosition.Top;

        //set up chart legend
        var legend = chartEjercicios.Legend;
        legend.Appearance.BackgroundColor = Color.White;
        legend.Appearance.Position = ChartLegendPosition.Bottom;

        //set up plot area
        var plotArea = chartEjercicios.PlotArea;
        plotArea.Appearance.FillStyle.BackgroundColor = Color.YellowGreen;

        //set up x-axis
        var xAxis = plotArea.XAxis;
        xAxis.AxisCrossingValue = 0;
        xAxis.Color = Color.Black;
        xAxis.MajorTickType = TickType.Outside;
        xAxis.MinorTickType = TickType.None;
        xAxis.Reversed = false;
        var axisItemCollection = xAxis.Items;

        //Loader of days in X axis by appearance (Not really dates)
        axisItemCollection.Clear();
        for (decimal i = radSliderVisualizadorG1DesdeHasta.SelectionStart ; i <= radSliderVisualizadorG1DesdeHasta.SelectionEnd; i++)
        {
            axisItemCollection.Add(new AxisItem(i.ToString()));
        }

        int FechaInicio = new ExcelInfo().OBT_R06_FechakeyPorNumerodiaAnnoViceVersa((int)radSliderVisualizadorG1DesdeHasta.SelectionStart, false).ID;
        int FechaTermino = new ExcelInfo().OBT_R06_FechakeyPorNumerodiaAnnoViceVersa((int)radSliderVisualizadorG1DesdeHasta.SelectionEnd, false).ID;
        xAxis.MinDateValue = DateTime.ParseExact(FechaInicio.ToString(), "yyyyMMdd",null);
        xAxis.MaxDateValue = DateTime.ParseExact(FechaTermino.ToString(), "yyyyMMdd", null);

        xAxis.MaxDateGroups=25;
        xAxis.EnableBaseUnitStepAuto = true; 

        xAxis.Type = AxisType.Date;
        xAxis.DataLabelsField = "OrderDate";
        xAxis.LabelsAppearance.DataFormatString = "dd-MM";
        xAxis.LabelsAppearance.RotationAngle = 0;
        xAxis.TitleAppearance.Text = "Days of the Year";
        xAxis.TitleAppearance.Position = AxisTitlePosition.Center;
        xAxis.MajorGridLines.Visible = true;
        xAxis.MinorGridLines.Visible = true;
        xAxis.MajorGridLines.Width = 1;
        xAxis.MinorGridLines.Width = 1;


        //set up y-axis
        var yAxis = plotArea.YAxis;
        yAxis.LabelsAppearance.RotationAngle = -35;
        yAxis.Color = Color.Black;
        yAxis.MajorTickType = TickType.Outside;
        yAxis.MinorTickType = TickType.None;

        decimal? MaxComparitor = 0;
        decimal? MinComparitor = 99999999;

        decimal? MaxInList = 0;
        decimal? MinInList = 0;

        foreach (var item in newListCota)
        {
            var someString = item.ID_FechaKey.ToString().Substring(0, 6);
            if (item.CotaValor < MinComparitor)
            {
                MinComparitor = MinInList = (decimal?)item.CotaValor;
            }

            if (item.CotaValor > MaxComparitor)
            {
                MaxComparitor = MaxInList = (decimal?)item.CotaValor;
            }

        }

        yAxis.MaxValue = MaxInList+((MaxInList*10)/100)+15;
        yAxis.MinValue = ((MinInList * 10) / 100);

        #region No Use Code for assign Y Axis
        //This is the old min-max values of the Y side
        //yAxis.MaxValue = 100;
        //yAxis.MinValue = 0;
        #endregion

        yAxis.Step = ((MinInList * 15) / 100);
        yAxis.LabelsAppearance.DataFormatString = "{0}";
        yAxis.MajorGridLines.Width = 1;
        yAxis.MinorGridLines.Width = 1;
        yAxis.TitleAppearance.Text = "CPU Load";
        yAxis.TitleAppearance.Position = AxisTitlePosition.Center;

        //set up series
        var series = plotArea.Series;

        series.Clear();

        //Here i take the number from certain range of date to another, this used to work fine before I add the MaxDateGroups and EnableAuto
        newListCota = newListCota.Where(c => c.DiasEnAnno >= ((Int32)radSliderVisualizadorG1DesdeHasta.SelectionStart) && c.DiasEnAnno <= ((Int32)radSliderVisualizadorG1DesdeHasta.SelectionEnd)).ToList();
        foreach (var itemEM in rcbxEjercicioMultiple.CheckedItems)
        {
            var barSeries = new AreaSeries();
            barSeries.LabelsAppearance.Visible = false;
            barSeries.LabelsAppearance.DataFormatString = "{0}";
            barSeries.MarkersAppearance.Visible = false;
            barSeries.Appearance.FillStyle.BackgroundColor = ColorTranslator.FromHtml(ColorRandomizer());
            //barSeries.LineAppearance.LineStyle = Telerik.Web.UI.HtmlChart.Enums.ExtendedLineStyle.Normal;
            barSeries.Name = "Año "+ itemEM.Value;
            foreach (var item in newListCota)
            {
                barSeries.Items.Add(new SeriesItem(item.CotaValor));
            }
            series.Add(barSeries);
        }

    }

其他相关信息

  • 我怀疑问题可能是我选择的系列的属性,而不是我必须激活或更改,因为当我添加时,这个问题开始发生 这个代码是为了以更合适的方式加载X轴, 但不确定地知道:

    xAxis.MaxDateGroups=25;
    xAxis.EnableBaseUnitStepAuto = true; 
    
  • 我从中消耗数据以及调用该数据的数据库完全正常,我验证了它。

任何建议,问题,澄清或回答请求都有助于找到解决方案,我们也非常感激。

0 个答案:

没有答案