Line Chart with a Single Data Point

Thread is closed for posting
6 posts, 1 answers
  1. Jason
    Jason avatar
    19 posts
    Member since:
    Feb 2008

    Posted 28 Sep 2012 Link to this post

    A couple of years ago I posted on the forums to get some help with a chart that needed to display both points and lines, and the help that I got there worked perfectly (My Old Post). Recently though, we've run into a bit of an issue with it as we've switched from using cataloged data to a live stream. 

    The chart monitors quality, so it checks how the item performed (point) against two levels of standards (the lines). The problem is that with a new run we'll have the single performance data in there which shows up fine, but the two lines don't show up at all. I assume that this is caused by the lack of multiple data points resulting in no line being drawn from A to B since B doesn't exist.

    So I need some help figuring out how I can make those lines show up if there's only one item to be displayed. There will be more than one point of data eventually, so I need to put it into an IF or Case statement of some kind I'm sure, but I don't know what the best way to do that is going to be.
  2. Jason
    Jason avatar
    19 posts
    Member since:
    Feb 2008

    Posted 01 Oct 2012 Link to this post

    Would I be better off dropping datasources and trying to feed all of the data points to the table via code and if I see a single datapoint then I toss in two more, or is there some way to make the chart show line values with only a single value?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 02 Oct 2012 Link to this post

    Hello Jason,

    I am not sure how you need this to be visualized. After all it is a single point and no line can be constructed out of it. Is it possible that you use PointMarks (check here) . In this case at least one point-mark will always be visible. Let us know if you need further assistance.

    Regards,
    Petar Marchev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Jason
    Jason avatar
    19 posts
    Member since:
    Feb 2008

    Posted 02 Oct 2012 Link to this post

    You can see what I'm doing in the attachment. We use the charts to display quality control information. The point represents the product's performance, and the two lines represent the quality control standards that it has to meet or beat in order to pass. I have to show the lines because these charts are displayed on a 60+ inch monitor for customers to see when they walk in the door, and they need to see that even on the very first test of the day whether it passed or failed. 

    So I need a way to force the lines to show up even with a single data point. Right now all of my charts are generated based off of SQL datasources. If I need to run a query to see how many total tests have happened and the set the source to SQL if it's > 1 and a custom query if it's only 1 then that's fine, but since I haven't done that with the charts yet then I could use some help doing that instead. Assuming that I can programmatically send it one set that has no test info, both quality numbers, then the actual test info and both quality numbers, and then another blank test with both quality numbers. so that the lines basically have 3 numbers but the point portion has only 1.

  6. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 04 Oct 2012 Link to this post

    Hi Jason,

    Thanks for the explanations! I think that what you really need is a grid-line annotation. Since these two lines (red and green) do not really show any data, but they are there for annotation purposes - they should preferably not be series. So my suggestion is to use MarkedZones.

    You can add a marked zone that behaves like a horizontal grid line that annotates this threshold. This you can do after the chart is populated with data (the DataBound event or the BeforeLayout event). Here is some code that will get you started
    if (this.RadChart1.Series[0].Items.Count == 1)
    {
     this.RadChart1.PlotArea.XAxis.AutoScale = false;
     this.RadChart1.PlotArea.XAxis.AddRange(0, 1, 1);
    }
     
    double failureTreshold = 1.5;
     
    ChartMarkedZone redLine = new ChartMarkedZone();
    redLine.ValueStartX = this.RadChart1.PlotArea.XAxis.MinValue - 0.5;
    redLine.ValueEndX = this.RadChart1.PlotArea.XAxis.MaxValue + 0.5;
    redLine.ValueStartY = failureTreshold;
    redLine.ValueEndY = failureTreshold;
    redLine.Appearance.Border.Color = Color.Red;
     
    this.RadChart1.PlotArea.MarkedZones.Add(redLine);

    I have also attached a simple project to demonstrate this. Let us know if you can adapt this to your current project.

    Greetings,
    Petar Marchev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Jason
    Jason avatar
    19 posts
    Member since:
    Feb 2008

    Posted 05 Oct 2012 Link to this post

    Thank you, Petar. I believe the marked zones are going to work for us perfectly.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017