Profile Picture

Data Driven Bar Width

Posted By Martyn Bullerwell 12 Years Ago
Author
Message
Martyn Bullerwell
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 3, Visits: 1
Hi,

I am currently evaluating the SSRS add-ins as I am looking for something that will give the same output as follows:

http://demos4.dundas.com/AddOn/VariableWidth/VariableWidth.aspx

Sadly, this is no longer available, and Microsoft did not port this functionality across when they integrated Dundas into SSRS. I need each column to be a different width based on a measure, and need the gaps between the columns to be equal. I am trying to avoid having to hack the data set to create a time series.

Any help with this would be greatly appreciated.

Cheers

Martyn



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 3,054, Visits: 4,009

Hi Martyn,

You can easily achieve this chart using the range chart - check out the ChartTypes_Range2D.rdl example shipped with the control. Let us know if you meet any problems or have any questions.



Best Regards,
Nevron Support Team



Martyn Bullerwell
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 3, Visits: 1

Hi,

Thanks for your response, but sadly this does not give me what I need, With this I would need to heavily maipulate the data I retrive, which is not Ideal. My Data set is as follows:

Category, % for Height, % for Width.

I would like the Cateogry to be along the X Axis, with the %Width dictating the Width of the bar, where the % Height is the Y axis.  It is very simple, but no one seems to support it, it is not a range.

Many thanks

Martyn



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 3,054, Visits: 4,009

Hi Martyn,

It can certainly be done with custom code (that modifies the chart appearance after the data has been loaded). If you send us sample data we can create a sample report showing how to achieve it...



Best Regards,
Nevron Support Team



Martyn Bullerwell
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 3, Visits: 1

Hi,

That would be great, I have send some sample data as an Email. 

Thanks so much for your help.

Kind regards

Martyn

 



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 3,054, Visits: 4,009

Hi Martyn,

Please find attached the sample report that shows a chart as percentages on the x axis. To replicate the report on your end you can follow these steps:

1. Create a table called [SampleTable] in the sample database (NRSVisionExamplesDB) distrubted with Nevron Chart for SSRS. Fill the following data in it:

AgeBandBarWidthMeasure
Under 160.032155911549
16 to 200.151817552440
21 to 240.18388157004
25 to 340.331508585570
35 to 440.169562546703
45 to 540.0873976825066
55 to 640.027729798421
65 +0.0081255792061

2. Add the SampleReport1.rdl file to the examples solution shipped with the control and run it - you should get the following result:

Variable Width Bars Chart SSRS

A few explanations:
1. To achieve this chart we used the range series. It accepts four values x1, x2, y1, y2 definining a rectangle in scale space. Those four values map to the table as follows:

X1 = percentage
X2 = nothing
Y1 = 0
Y2 = Measure

In addition we also import the label value.

2. Then to assign X2 values we 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)
                                {
                                                if (context.Document.Charts.Count == 0)
                                                                return;
                                                NChart chart = context.Document.Charts[0];
                                               
                                                if (chart.Series.Count == 0)
                                                                return;
                                               
                                                NRangeSeries rangeSeries = chart.Series[0] as NRangeSeries;
                               
                                                if (rangeSeries == null)
                                                                return;
                                               
                                                // compute total percentage
                                                int count = rangeSeries.XValues.Count;
                                                double total = 0;
                                               
                                                for (int i = 0; i < count; i++)
                                                {
                                                                total += (double)rangeSeries.XValues[i];
                                                }

                                                // then assign a value to x and x2
                                                double xStart = 0;
                                                double xEnd = 0;
                                                rangeSeries.X2Values.Clear();

                                                if (total <= 0)
                                                                return;

                                                for (int i =0; i < count; i++)
                                                {
                                                                xEnd = xStart + ((double)rangeSeries.XValues[i] / total);
                                                               
                                                                rangeSeries.XValues[i] = xStart;
                                                                rangeSeries.X2Values.Add(xEnd);

                                                                xStart = xEnd;
                                                }

                                                // create a linear axis with custom labels to annotate the range series
                                                NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();

                                                scaleX.AutoLabels = false;
                                                scaleX.MajorTickMode = MajorTickMode.CustomTicks;

                                                for (int i = 0; i < count; i++)
                                                {
                                                                NCustomValueLabel label = new NCustomValueLabel();
                                                                label.Text = (string)rangeSeries.Labels[i];
                                                                label.Value = ((double)rangeSeries.XValues[i] + (double)rangeSeries.X2Values[i]) / 2;
                                                                scaleX.CustomLabels.Add(label);
                                                                scaleX.CustomMajorTicks.Add((double)rangeSeries.X2Values[i]);
                                                }
                                               
                                                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;
                                }
                }
}

In a nutshell it does the following:

1. Compute the total for all percentages.
2. Assign X1, X2 for each bar in the series depending on it’s percentage and the total.
3. Create a custom value labels for the x axis to annotate those bars.

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



Best Regards,
Nevron Support Team



Attachments
SampleReport1.rdl (439 views, 17.00 KB)


Similar Topics


Reading This Topic