Custom Data Label alignment on y-axis


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

By Brian Dalwood - 8 Years Ago
Hi,
I have a Range Chart that I have configured to show time series data across the x-axis and have applied offsets to the y-axis values to plot data for each machine vertically up the scale.The y-axis scale values are numeric but I am using Custom Labels to replace the numbers with relevant text descriptions.
I cannot get the custom labels to Left Align. The NStringFormatStyle method I am using in the code below doesn’t appear to have any affect.
Can you please let me know how to left align the custom axis labels?

https://www.nevron.com/forum/uploads/images/6ed4e43c-6233-44b4-89bc-479b.jpg

            NChart chart = context.document.Charts[0];
            NRangeSeries range = chart.Series[0] as NRangeSeries;
           
            // add custom label to the Y axis
                  NAxis yAxis = chart.Axis(StandardAxis.PrimaryY);

                  for (int i=1; i < range.Values.Count; i++)
                  {
                        string machineName = (string)range.Labels[i];
                       
                        NCustomValueLabel valueLabel = new NCustomValueLabel(i, machineName);
                       if (valueLabel.Text == "Filler")
                       {
                              valueLabel.Style.TextStyle.FillStyle = new NColorFillStyle(Color.Red);
                              valueLabel.Style.TextStyle.BackplaneStyle.Visible = true;
                              valueLabel.Style.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.Yellow);
                              valueLabel.Style.TextStyle.BackplaneStyle.StandardFrameStyle.Visible = false;                        
                       }
                       valueLabel.Style.TextStyle.FontStyle.Name = "Tahoma";
                       valueLabel.Style.TextStyle.StringFormatStyle = new NStringFormatStyle(StringFormatType.GenericDefault, HorzAlign.Left, VertAlign.Center);
                       yAxis.ScaleConfigurator.CustomLabels.Add(valueLabel);
                  }


By Nevron Support - 8 Years Ago
You need to modify the label content alignment:
valueLabel.Style.ContentAlignment = ContentAlignment.BottomCenter;

Hope this helps – let us know if you meet any problems or have any questions.