Profile Picture

Bar Chart Labels

Posted By Bhumi Patel 12 Years Ago
Author
Message
Bhumi Patel
Posted 12 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 for your reply. It worked perfectly!!

Nevron Support
Posted 12 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: Last Week
Posts: 3,054, Visits: 4,009

Hi Bhumi,

Yes - you need to assign a per data point label in this case - for example:

   NChart chart = nChartControl1.Charts[0];
   NBarSeries bar = new NBarSeries();

   
   bar.Values.Add(30);
   bar.Values.Add(31);
   bar.Values.Add(0);
   bar.Values.Add(33);
   bar.Values.Add(34);
   bar.Values.Add(35);
   bar.Values.Add(40);

   bar.DataLabelStyle.Format = "<label>";
   bar.DataLabelStyle.Visible = true;

   for (int i = 0; i < bar.Values.Count; i++)
   {
    if ((double)bar.Values[i] == 0)
    {
     bar.Labels.Add("Zero");
    }
    else
    {
     bar.Labels.Add(string.Empty);
    }
    
   }

   chart.Series.Add(bar);

Applies "Zero" to all data points with value 0 and empty string otherwise.



Best Regards,
Nevron Support Team



Bhumi Patel
Posted 12 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,

Is it possible to display Label for a bar when value is 0 else hide them?? Please review attached image to understand my point.

Thanks in advance!!

-Bhumi


Attachments
Untitled.png (63 views, 11.00 KB)


Similar Topics


Reading This Topic