Profile Picture

Cummulative line chart

Posted By Shawn Haggett 14 Years Ago
Author
Message
Shawn Haggett
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 6, Visits: 1
Hi, I'm trying to build a chart and I'm not sure if it will be possible in Nevron Chart for Sharepoint. My data consists of a set of values and dates, i.e.:

1: Jan, 2
2: Jan, 1
3: Jan, 4
4: Feb, 2
5: Mar, 5
6: Mar, 2

Currently I am grouping my month, so I have month on the X-axis and total for that month on the Y axis (so the line goes up and down for each month, depending on the total for that month). What I would like to do is still have months on the X-axis, but have the line showing the cummulative total up until that point (i.e. the line will only ever go up).

Thanks

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Shawn,

Currently you can do that with code injection. Go to the Code - Code Editor Page and paste this code:

using System;
using System.Drawing;

using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
///
/// Sample class
///

public class MyClass
{
///
/// Main entry point
///

///
public static void RSMain(NRSChartCodeContext context)
{
if (context.Document.Charts.Count == 0)
return;

// get the first chart in the document
NChart chart = context.Document.Charts[0];
if (chart.Series.Count == 0)
return;

// get the first line series in the chart
NSeries series = chart.Series[0] as NSeries;
if (series == null)
return;

// make the totals
int count = series.Values.Count;
double total = 0;

for (int i = 0; i < count; i++)
{
double value = (double)series.Values[i];
if (Double.IsNaN(value))
continue;

total = total + value;
series.Values[i] = total;
}
}
}
}

It will implemented the total calculation for first series in almost all charting types (Bar, Line, Area etc.)

Best Regards,
Nevron Support Team



Shawn Haggett
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 6, Visits: 1
Thanks for that. We're currently using the 2009 version, before code injection was added. We were already looking at moving up to the 2010 version, so looks like we are going to need to do that.

Shawn Haggett
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 6, Visits: 1
The above code worked, but only for the first series, below is my modification to accumulate all the series:

using System;
using System.Drawing;

using Nevron.GraphicsCode;
using Nevron.Chart;
using Nevron.ReportingServices;

namespace MyNamespace
{
public class MyClass
{
public static void RSMain(NRChartCodeContext context)
{
if(context.Document.Charts.Count == 0)
return;
NChart chart = context.Document.Charts[0];
if(chart.Series.Count == 0)
return;

for (int i = 0; i < chart.Series.Count; i++)
{
NSeries series = chart.Series[i] as NSeries;
if (series == null)
continue;
int count = series.Values.Count;
double total = 0;

for (int j = 0; j < count; j++)
{
double value = (double)series.Values[j];
if (Double.isNaN(value))
continue;

total = total + value;
series.Values[j] = total;
}
}
}
}
}



Similar Topics


Reading This Topic