Area Chart Legend with Series


https://www.nevron.com/Forum/Topic12193.aspx
Print Topic | Close Window

By Vahid Mesri - 7 Years Ago
hi,
Hi,

I have got an area chart with a series value which is a field in my dataset.

The legend for the chart is set to show the label of the series plus the label field of the value, seperated by a dash line, in the form of Group1 - Value1.

What I want is to only show the series label in the legend - only show Group1 - but if I leave the label field of the value empty, Nevron component still shows the dash (it shows Group1 - )  Is there a way around the issue?

Many thanks,
Vahid
By Nevron Support - 7 Years Ago
Hi Vahid,

Currently the only workaround for this issue is to use custom code to remove the trailing dash - you can use the following code:

using System;
using System.Drawing;
using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
 /// <summary>
 /// Sample class
 /// </summary>
 public class MyClass
 {
  /// <summary>
  /// Main entry point
  /// </summary>
  /// <param name="context"></param>
  public static void RSMain(NRSChartCodeContext context)
  {
   NChart chart = context.document.Charts[0];
   
   foreach (NSeriesBase series in chart.Series)
   {
    series.Name = series.Name.Trim();
    if (series.Name.EndsWith("-"))
    {
     series.Name = series.Name.Substring(0, series.Name.Length - 1);
     series.Name = series.Name.Trim();
    }
   }
  }
 }
}
(just copy paste the above code in the code tab of the SSRS designer)

Hope this helps let us know if you meet any problems or have any questions.
By Vahid Mesri - 7 Years Ago
Thank you very much. This did the trick!