Set the origin (cross at) property for a bar chart in SharePoint

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

How to set the origin (cross at) property for a bar chart in SharePoint?

You can set the bar origin property so the bars will display either upward or downward, depending if the values are above or under the custom origin.



Use the following code in the Code tab of the Chart designer to modify the origin:

[C#]
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) 
        
            if (context.Document.Charts.Count == 0) 
                return
                    
            NChart chart = context.Document.Charts[0]; 
            NBarSeries bar = chart.Series[0] as NBarSeries; 
                
            if (bar != null
            
                bar.OriginMode = SeriesOriginMode.CustomOrigin; 
                bar.Origin = 20; 
            
        
    
}

[VB.NET]
Imports System 
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) 
            If context.Document.Charts.Count = 0 Then
                Return
            End If
    
            Dim chart As NChart = context.Document.Charts(0) 
            Dim bar As NBarSeries = TryCast(chart.Series(0), NBarSeries) 
    
            If bar IsNot Nothing Then
                bar.OriginMode = SeriesOriginMode.CustomOrigin 
                bar.Origin = 20 
            End If
        End Sub
    End Class
End Namespace

Article ID: 101, Created On: 10/27/2010, Modified: 1/29/2013