Display Message when Data Source for Line Chart is empty


Author
Message
Bhumi Patel
Bhumi Patel
Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)
Group: Forum Members
Posts: 33, Visits: 1
Thank you. Its working perfectly!!

-Bhumi
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Bhumi,

Yes - you can conditionally add the chart to the control panels collection - the following code snippet shows how to achieve such behaviour:

  private void UpdateChart()
  {
   nChartControl1.Panels.Clear();

   // create a chart that is not added to the control
   NCartesianChart chart = new NCartesianChart();

   NBarSeries bar =new NBarSeries();

   // feed data (in this case the chart will have
   // some data points randomly)
   Random rand  = new Random();
   if ((rand.Next() % 2) == 1)
   {
    bar.Values.Add(10);
    bar.Values.Add(20);
    bar.Values.Add(30);
   }

   chart.Series.Add(bar);

   // check if there is data and add the chart panel
   if (bar.Values.Count == 0)
   {
    NLabel label = new NLabel("There is no data");
    label.ContentAlignment = ContentAlignment.MiddleCenter;
    label.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage));
    nChartControl1.Panels.Add(label);
   }
   else
   {
    nChartControl1.Panels.Add(chart);
   }

   nChartControl1.Refresh();
  }

Hope this helps - let us know if you meet any problems...



Best Regards,
Nevron Support Team


Bhumi Patel
Bhumi Patel
Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)
Group: Forum Members
Posts: 33, Visits: 1
Hi,

I am displaying a timely data in Line chart from database using dataset. So if data is not available at some point of time, my dataset is empty. Is there any way I can display a message instead of chart as shown in below image??


Thanks,
Bhumi

Attachments
graph.png (66 views, 7.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search