Report with Widgets Assigned to Data Source

In order to visualize data in a report, you can use the Widget element.

The example of the report, which outputs data about average temperature in different cities, is represented in this article. The scale was added to visualize the temperature.

Download the sample application: <ссылка>

Step 1. Creation of a report in Report Designer

The DataBand band is used for output of data from the data source. Detail is added into it.

The TextBox elements are added inside Detail. These elements are used for output of the city name, maximal, minimal and average annual temperature in Celsius and Fahrenheit.

The report template at this stage:

The Widget element is added into Detail.

Double click on the Widget area opens Instrument Designer for Widget.

Step 2. Creation of Widget in Instrument Designer

Instrument Designer:

The Guide element is used for creation of the scale.

The EndPoint and StartPoint values are calculated subject to the instrument sizes.

The expressions for the Guide1 element:

The Scale element is used for setting the range of changing of the scale values.

The range of changing -35 to 35 is set to Scale1 for display of scale temperature values in Celsius (the Minimum and Maximum properties).

The range of changing -31 to 95 is set to Scale2 for display of scale temperature values in Fahrenheit.

At this stage the instrument structure looks as follows:

The Ticks element is used to output scales ticks.

The element position is set by the indent from the scale using the Distance property.

The ScaleLabels elements are used for output of numeric scale labels.

The Distance property sets the indents.

The Label elements, which output the measure units, are added to the left from numeric labels.

At this stage the instrument structure looks as follows:

Step 3. Data Visualization

The Slider element is used for visualization of the temperature values.

The Value property value is taken from the data source and is passed from the template. Slider – is non visual element, that’s why the LinearLevel element is placed inside it for the value display.

The LinearLevel.Value property is set by the expression and is equal to Slider1.Value.

The element position is set by the indent from the scale using the Distance property.

The temperature values are set in Celsius, that’s why the Slider elements should be added to Scale1.

We added three Slider elements with nested LinearLevel for output of maximal, minimal and average temperature.

At the final stage the instrument structure looks as follows:

Step 4. Passing the Data from the template to Widget.

To pass data to Widget, it is needed to write the script in widget1.GenerateScript.

//to the Slider1.Value property the “Min” field value of 
the current record is set 
(widget1.Instrument.GetByName("Slider1") as 
PerpetuumSoft.Instrumentation.Model.Slider).Value = 
Convert.ToDouble(dataBand1["Min"]); 

//to the Slider2.Value property the “Max” field value of 
the current record is set
(widget1.Instrument.GetByName("Slider2") as 
PerpetuumSoft.Instrumentation.Model.Slider).Value = 
Convert.ToDouble(dataBand1["Max"]);

// to the Slider3.Value property the “Avg” field value of 
the current record is set 
(widget1.Instrument.GetByName("Slider3") as 
PerpetuumSoft.Instrumentation.Model.Slider).Value = 
Convert.ToDouble(dataBand1["Avg"]);

Report template:

The generated report:

Add Feedback