Facing issue in Stacked bar

Thread is closed for posting
4 posts, 1 answers
  1. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 05 Sep 2011 Link to this post

    Hi

    I have 2 radchart in my page. I am differentiating these two charts based on the two column. There are Dispensation and Discretion. using the above two columns, i am setting as DataManager.ValuesYColumns for each chart.  I am applying group by "Type" which is another column.  This code is working perfect  for Discretion. The same one is not working for Dispensation. In Dispensation, i have values for December and march month. But it is appearing in the December month. I did sample application application. it is working exactly how i need. When i copy and paste the same code in my project it is behaving differently.  I have spent 2 days to fix this. I tried all possible ways.

    chart.PlotArea.XAxis.DataLabelsColumn = "MonthYear";
            chart.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate;
            chart.PlotArea.XAxis.Appearance.CustomFormat = "MMM-yy";
      
      
            chart.PlotArea.XAxis.AutoScale = false;
            chart.PlotArea.YAxis.AutoScale = false;
      
            chart.ChartTitle.Visible = true;
            chart.ChartTitle.TextBlock.Appearance.Visible = true;
            chart.ChartTitle.Appearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.TopLeft;
      
              
      
            if (chart.ID == "radChart")
            {
                chart.PlotArea.YAxis.AutoScale = true;
                chart.DataManager.ValuesYColumns = new string[] { "Discretion" };
                //chart.PlotArea.YAxis.MinValue = start;
                //chart.PlotArea.YAxis.MaxValue = end;
                //chart.PlotArea.YAxis.LabelStep = diff;
                if (strCrewType == "FD")
                    chart.ChartTitle.TextBlock.Text = "Incidents of Flight Deck Operating into Discretion";
                else
                    chart.ChartTitle.TextBlock.Text = "Incidents of Crew Operating into Discretion";
            }
            else
            {
                chart.PlotArea.YAxis.AutoScale = false;
                //chart.PlotArea.YAxis.MinValue = start;
                //chart.PlotArea.YAxis.MaxValue = end;
                chart.PlotArea.YAxis.LabelStep = diff;
                chart.DataManager.ValuesYColumns = new string[] { "Dispensations" };
      
                chart.ChartTitle.TextBlock.Text = "QCAA Dispensations";
            }
      
            chart.DefaultType = Telerik.Charting.ChartSeriesType.StackedBar;
      
    chart.DataGroupColumn = "Type";
    var obj = (from c in listCrewMetricsOut
                               where c.CrewType == strCrewType
                               select c);
                    chart.DataSource = obj;
                    chart.DataBind();
  2. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 06 Sep 2011 Link to this post

    Hi

    I found the issue. I have written code to remove the 0 value in the item databound event.
    protected void radChart_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
        {
            if (e.SeriesItem.YValue == 0)
            {
                e.SeriesItem.Parent.Items.Remove(e.SeriesItem);         }
            e.ChartSeries.Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside;
        }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Arima
    Arima avatar
    25 posts
    Member since:
    Mar 2011

    Posted 13 Sep 2011 Link to this post

    Hi All,

    I thought have found solution for my issue. But still not found the solution. In my page, on top of that i have dropdown in which i am populating last 5 months. Based on the selection of month, i have display the stacked bar chart with the data. The problem is, the chart is working as per the result for the perticular month. Let's say have selected May. The chart is displaying perfect. When i select April, it is wrongly displaying the data.It means for the month of Feb, i don't have value.It is displaying march month data into the feb month. What could be the issue?
  5. Answer
    Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 14 Sep 2011 Link to this post

    Hello Arima,

    RadChart groups the items correctly and the chart series contain the correct items with their corresponding values. The ChartSeriesItems however do not have their XValue property set, so all the series start from the very left position. You can force the position of an item by specifying its XValue. In this case, you can do this by introducing a fake column with incremental numeric values, which will serve as XValue. Then set the RadChart.DataManager.ValuesXColumn property with its name and that's it.

    All the best,
    Yavor Ivanov
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Back to Top