This is a migrated thread and some comments may be shown as answers.

Problem when YValue is below 1

2 Answers 56 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Rita
Top achievements
Rank 1
Rita asked on 13 Oct 2011, 08:29 PM
I am very new to Telerik so excuse me if I am leaving something out, but I'll try to be as accurate as possible. I have a RadChart (line chart) with a linqdatasource. The chart renders accurately when all YValues are above 1. However, for any YValue between 0 and 1 (e.g. 0.2, 0.6, etc.), the chart runs directly into the XAxis with no label displayed. In fact, it does not even display a label at 0. For those charts where all YValues are below 1, the chart renders blank, with no datapoints, or labels shown. I have went through the code, and the data is being picked up accurately. I have also tried setting the PlotArea range for the YAxis in steps of .5, rather than 1. The results are still the same.

I'm attaching 4 files:
The following is my codebehind:
    protected void trcBehaviorData_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
    {
        RethinkAutismDataContext ctx = new RethinkAutismDataContext();
 
        NameValueCollection nvcNotes = (NameValueCollection)Session["nvcNotes"];
 
        int index = e.SeriesItem.Index;
        var key = nvcNotes[(index + 1).ToString()];
 
        var r = ctx.viewBehaviorPlanDataInfos.Where(rr => rr.dataSetId == Convert.ToInt32(key)).FirstOrDefault();
        if (r != null)
        {
            String bNotes = "";
            if (!String.IsNullOrEmpty(r.notes))
                bNotes = ":<br /> " + r.notes;
            e.SeriesItem.ActiveRegion.Tooltip = "<b>" + r.dateCreated.ToString("MM/dd/yyyy") + " " + r.uName + "</b>" + bNotes;
            e.SeriesItem.YValue = (double)r.result;
 
        }
    }
 
    protected void buildChartXAxis()
    {
 
        int idx = 0;
        int planCount = 1;
 
        RethinkAutismDataContext ctx = new RethinkAutismDataContext();
        var behavior = (from b in ctx.BehaviorTrackings
                        where b.Id == behaviorId
                        select b).SingleOrDefault();
        trackingMethod = behavior.MethodTypeLU.Name;
        int resultCount = 0;
 
        List<dataReportForBehaviorPlanResult> result = ctx.dataReportForBehaviorPlan(ChildProfileId, behaviorId, Plan).ToList();
        intervalMinutes = (int)behavior.IntervalsofMinutes;
        resultCount = result.Count();
        if (resultCount > 0)
        {
            if (resultCount < 21)
            {
                IEnumerator ieResult = result.GetEnumerator();
                ieResult.MoveNext();
                dataReportForBehaviorPlanResult resultSummary = (dataReportForBehaviorPlanResult)ieResult.Current;
 
                trcBehaviorData.PlotArea.XAxis.AutoScale = false;
                trcBehaviorData.PlotArea.XAxis.AddRange(1, 21, 1);
                for (int i = 0; i < 21; i++)
                {
                    trcBehaviorData.PlotArea.XAxis[i].TextBlock.Text = (i + 1).ToString();
                }
            }
 
            if (resultCount > 20)
            {
                trcBehaviorData.PlotArea.XAxis.AutoScale = false;
                trcBehaviorData.PlotArea.XAxis.AddRange(1, resultCount + 1, 1);
 
                IEnumerator ieResult = result.GetEnumerator();
                while (ieResult.MoveNext())
                {
                    dataReportForBehaviorPlanResult resultSummary = (dataReportForBehaviorPlanResult)ieResult.Current;
 
                    trcBehaviorData.PlotArea.XAxis[idx].TextBlock.Text = planCount.ToString();
                    idx++;
                    planCount++;
                }
            }
        }
}
 
    protected void buildChartYAxis()
    {
        RethinkAutismDataContext ctx = new RethinkAutismDataContext();
        var behavior = (from b in ctx.BehaviorTrackings
                        where b.Id == behaviorId
                        select b).SingleOrDefault();
        trackingMethod = behavior.MethodTypeLU.Name;
        double yAxisLabel = 0;
 
        switch (trackingMethod)
        {
            case "Intervals":
                trcBehaviorData.PlotArea.YAxis.AutoScale = false;
                trcBehaviorData.PlotArea.YAxis.AddRange(1, 120, 10);
 
                for (int i = 0; i < 11; i++)
                {
                    trcBehaviorData.PlotArea.YAxis[i].TextBlock.Text = yAxisLabel.ToString() + "%";
                    yAxisLabel += 10;
                }
                trcBehaviorData.PlotArea.YAxis[11].TextBlock.Text = "Intervals";
                trcBehaviorData.PlotArea.YAxis[12].TextBlock.Text = "% of";
                break;
            case "Frequency":
                trcBehaviorData.PlotArea.YAxis.AutoScale = false;
                trcBehaviorData.PlotArea.YAxis.AddRange(1, 23, 1);
                for (int i = 0; i < 21; i++)
                {
                    trcBehaviorData.PlotArea.YAxis[i].TextBlock.Text = yAxisLabel.ToString();
                    yAxisLabel +=1; // yAxisLabel + Convert.ToDouble(0.5);
                }
                trcBehaviorData.PlotArea.YAxis[21].TextBlock.Text = "/ day";
                trcBehaviorData.PlotArea.YAxis[22].TextBlock.Text = "times";
                break;
                //trcBehaviorData.PlotArea.YAxis.AutoScale = false;
                //double maxValue = Convert.ToDouble(trcBehaviorData.PlotArea.YAxis.MaxValue);
                //trcBehaviorData.PlotArea.YAxis.AddRange(1, maxValue, .1);
                //maxValue -= 1;
                //for (int i = 0; i < maxValue; i++)
                //{
                //    trcBehaviorData.PlotArea.YAxis[i].TextBlock.Text = yAxisLabel.ToString();
                //    yAxisLabel = yAxisLabel + Convert.ToDouble(0.1);
                //}
                ////maxValue = Convert.ToInt32(trcBehaviorData.PlotArea.YAxis.MaxValue);
                //trcBehaviorData.PlotArea.YAxis[Convert.ToInt32(maxValue)].TextBlock.Text = "/ hour";
                //maxValue += Convert.ToDouble(0.5);
                //trcBehaviorData.PlotArea.YAxis[Convert.ToInt32(maxValue)].TextBlock.Text = "times";
                //break;
            case "Duration":
                trcBehaviorData.PlotArea.YAxis.AutoScale = false;
                trcBehaviorData.PlotArea.YAxis.AddRange(1, 60, 5);
                for (int i = 0; i < 12; i++)
                {
                    trcBehaviorData.PlotArea.YAxis[i].TextBlock.Text = yAxisLabel.ToString();
                    yAxisLabel += 5;
                }
                trcBehaviorData.PlotArea.YAxis[12].TextBlock.Text = "Min";
                break;
        }
 
    }
And here's my asp:
<telerik:RadChart ID="trcBehaviorPlanData" runat="server" DataSourceID="behaviorPlanSummary"
    DefaultType="Line" Width="810px" Height="350px">
    <Series>
        <cc1:ChartSeries Name="dataMeasurement" DataYColumn="result" Type="Line" DataLabelsColumn="date"
            >
            <Appearance ShowLabels="true" PointDimentions-AutoSize="False" PointDimentions-Height="10px"
                PointDimentions-Width="30px">
                <%--graph line color--%>
                <FillStyle FillType="Solid" MainColor="47, 127, 172">
                </FillStyle>
                <PointMark Dimensions-AutoSize="False" Dimensions-Height="8px" Dimensions-Width="40px"
                    Visible="True">
                </PointMark>
                <TextAppearance TextProperties-Color="78, 168, 188">
                </TextAppearance>
                <Border Color="177, 215, 250" />
            </Appearance>
        </cc1:ChartSeries>
    </Series>
    <PlotArea>
        <XAxis>
            <Appearance Color="226, 218, 202" MajorTick-Color="221, 235, 244">
                <MajorGridLines Color="221, 235, 244" />
                <TextAppearance TextProperties-Color="81, 99, 100">
                </TextAppearance>
            </Appearance>
            <AxisLabel>
                <TextBlock>
                    <Appearance TextProperties-Color="78, 168, 188">
                    </Appearance>
                </TextBlock>
            </AxisLabel>
        </XAxis>
        <YAxis AxisMode="Normal" Appearance-LabelAppearance-Position-AlignedPosition="Center">
            <Appearance Color="226, 218, 202" MajorTick-Color="221, 235, 244" MinorTick-Color="221, 235, 244">
                <MajorGridLines Color="247, 251, 252" />
                <MinorGridLines Color="247, 251, 252" />
                <TextAppearance TextProperties-Color="81, 99, 100">
                </TextAppearance>
            </Appearance>
            <AxisLabel>
                <TextBlock>
                    <Appearance TextProperties-Color="247, 251, 252">
                    </Appearance>
                </TextBlock>
            </AxisLabel>
        </YAxis>
        <Appearance Dimensions-Width="30" Dimensions-Margins="40px, 30px, 15%, 9%">
            <%--graph background color--%>
            <FillStyle MainColor="247, 251, 252" SecondColor="Transparent">
            </FillStyle>
            <Border Color="221, 235, 244" />
        </Appearance>
    </PlotArea>
    <Appearance BarWidthPercent="20" Corners="Round, Round, Round, Round, 5">
        <FillStyle MainColor="247, 251, 252">
        </FillStyle>
        <Border Color="188, 229, 231" Width="1" />
    </Appearance>
    <ChartTitle>
        <Appearance Dimensions-Margins="4%, 10px, 10px, 7%">
            <FillStyle MainColor="">
            </FillStyle>
        </Appearance>
        <TextBlock Text="">
            <Appearance TextProperties-Color="232, 140, 0" TextProperties-Font="Verdana, 20pt, style=Bold">
            </Appearance>
        </TextBlock>
    </ChartTitle>
    <Legend>
        <Appearance Visible="false" Position-AlignedPosition="TopLeft">
            <ItemTextAppearance TextProperties-Color="81, 99, 100">
            </ItemTextAppearance>
            <Border Color="247, 251, 252" />
        </Appearance>
        <TextBlock Visible="true">
        </TextBlock>
    </Legend>
</telerik:RadChart>
I'm also attaching images of how some of these charts render, with the behavior described.

Any help would be greatly appreciated!

Rita

2 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 18 Oct 2011, 02:28 PM
Hello Rita,
I reviewed your code and the only problem that I could find in it, was that you are trying to change the YValue of the series items in the ItemDataBound handler. However, this would not work in all cases, not only in the case with lass than 1 values.

Unfortunately, I could not run your code without removing most of it and once I was able to run it, I could not reproduce the problem with it. That is why, could you please open a formal support ticket and send me a simple running project that demonstrates the problem?

Best wishes,
Tsvetie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rita
Top achievements
Rank 1
answered on 18 Oct 2011, 05:33 PM
Tsvetie, the problem is actually rectified, and was in the following code snippets:
trcBehaviorData.PlotArea.YAxis.AddRange(1, 120, 10);
trcBehaviorData.PlotArea.YAxis.AddRange(1, 23, 1);
trcBehaviorData.PlotArea.YAxis.AddRange(1, 60, 5);
I was setting the minimum value to 1 - therefore all data points rendered 1 less than the data I was receiving back from the dataObject (i.e. 5 rendered as a 4). For datapoints below 1, the data did not show up altogether.

Thank you for your help in any case. I will definitely look into the ItemDataBound Handler.
Rita
Tags
Chart (Obsolete)
Asked by
Rita
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Rita
Top achievements
Rank 1
Share this question
or