Profile Picture

Display Message when Data Source for Line Chart is empty

Posted By Bhumi Patel 13 Years Ago

Display Message when Data Source for Line Chart is empty

Author
Message
Bhumi Patel
Posted 13 Years Ago
View Quick Profile
Forum Member

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
Last Active: 11 Years Ago
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 (54 views, 7.00 KB)
Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

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
Posted 13 Years Ago
View Quick Profile
Forum Member

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
Last Active: 11 Years Ago
Posts: 33, Visits: 1
Thank you. Its working perfectly!!

-Bhumi



Similar Topics


Reading This Topic