Increase the Line Chart width via code in SharePoint

Applies to: Nevron Chart for SharePoint (WSS3.0, SharePoint 2007/2010/2013)

How to increase the Line Chart width via code in SharePoint?

In Nevron Chart for SharePoint you can control the width of Line Charts directly through the Chart Web Part designer. However, sometimes you may have to configure the Line Chart width by using custom code. The following code example demonstrates how to set the Line Series Stroke Style (border style) to 2 points.


using System;
using System.Collections.Generic;
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)
                NLineSeries line = series as NLineSeries;
                if (line != null)
                    line.BorderStyle.Width = new NLength(2);


Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports Nevron.GraphicsCore
Imports Nevron.Chart
Imports Nevron.ReportingServices
Namespace MyNamespace
    ''' <summary>
    ''' Sample class
    ''' </summary>
    Public Class [MyClass]
        ''' <summary>
        ''' Main entry point
        ''' </summary>
        ''' <param name="context"></param>
        Public Shared Sub RSMain(context As NRSChartCodeContext)
            Dim chart As NChart = context.Document.Charts(0)
            For Each series As NSeriesBase In chart.Series
                Dim line As NLineSeries = TryCast(series, NLineSeries)
                If line IsNot Nothing Then
                    line.BorderStyle.Width = New NLength(2)
                End If
        End Sub
    End Class
End Namespace

Article ID: 218, Created On: 5/7/2012, Modified: 1/29/2013