logo
small logo
  • Produkte
  • Shop
  • Support
  • Articles
  • Customer panel Support
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to draw a chart based on custom variables
  • Toilettenpapier drucken

    30. März 2020

    Meine Herren, Scherz beiseite! Heute sprechen wir über Toilettenpapier. Dieses unverzichtbare Hygieneprodukt wurde erst im

    read more
  • MS Word versus Open Document Text. Was ist besser?

    19. Oktober 2020

    Wenn wir von Texteditoren sprechen, stellen wir uns die Leuchte sofort als Microsoft Word vor,

    read more
  • Starten der Anwendung aus FastReport .NET heraus in Docker für Linux

    17. November 2021

    Docker ist eine Software-Plattform für eine schnelle Entwicklung, Prüfung und Bereitstellung von Anwendungen. Es ermöglicht

    read more
  • Wollten Sie Tabellen für den Benutzer generieren - Excel oder OpenOffice Calc?

    8. Oktober 2020

    Tabellen. Seit Jahrhunderten werden sie verwendet, um dieselbe Art von Daten für Buchhaltungszwecke, Zählbeträge und

    read more
  • Wahl der Top-Werte in einer Matrix

    22. April 2021

    Der Artikel ist aktuell bis Version 2022.1. FastReport.NET verfügt über ein großartiges Tool für die Anzeige

    read more

How to draw a chart based on custom variables

8. Januar 2020

An important part of the report is a graphical component, namely graphs and charts. They allow you to quickly analyse the data to assess the trend of growth or fall, or just quickly read information. That is how human perception works, that the graphic information is received more quickly. Therefore, on the road signs, you can see the images that are immediately understood and interpreted by the brain immediately.

Charts and graphs are based on statistical data. As a rule, they are taken from the database. But there are situations when it is necessary to build schedules based on the converted data. For example, using the initial data calculations performed. Some report generators allow only ready source of data. It is not convenient, because the conversion of the data necessary to carry out the report.

Let's look at the problem that the List & Label report generator user raised in his question:

Hi, I have a report where I have declared a bunch of user variables with various calculations. I am trying to display these variables in a Pie Chart, is this possible? I can’t seem to figure out how to do this?

To implement this in List & Label, you will have to create an intermediate table and write data from variables into it. The thing is that a pie type chart only works with a tabular data source. Chart segments are calculated by aggregating data.

Generator FastReport.Net reports can be used in the charts the data from the source, and the data manually added in the editor. However, the FastReport reports have built-in script that "unties our hands" and provides the ability to customize graphics in the code. This means that we can "slip" any data in the graph. For example, you perform calculations in a report, and save the results in the report variables, and then want to build on them graph. It is quite easy to implement.

 

You can also add MSChart object on the report page and create event handler BeforePrint:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
private void MSChart1_BeforePrint(object sender, EventArgs e)
 {
 MSChart1.DeleteSeries(0); //Delete default series
 MSChart1.AddSeries(SeriesChartType.Pie); //Add new series with pie-chart
 MSChart1.Series[0].SeriesSettings.Points.Clear(); //Wipe series data
 //Look through all parameters in the report
 foreach (Parameter param in Report.Parameters)
 {
 //Add to a series a point on Y axis. For the pie-chart Y axis are enough
 MSChart1.Series[0].SeriesSettings.Points.AddY(param.Value);
 }
 //Enable the legend
 MSChart1.Chart.Legends[0].Enabled = false;
 //Set series labels of the pie-chart
 MSChart1.Series[0].SeriesSettings.Label = "#VALY";
 //Set height of the MSChart object
 MSChart1.Height = 500;
 //Set width of the MSChart object
 MSChart1.Width = 500;
 }

 As a result, we will have such pie-chart:

 

In this example, we used the parameters of the report as a data source, but you can also use variables in the script of the report, arrays, collections.

Unfortunately, in the official documentation to FastReport.Net there is no description of the properties and methods of MSChart object. This component is very complex with a lot of settings, so you'll have to spend some time finding the right properties experimentally. In this example I have shown the simplest way of quickly creating graphics with the minimum settings.

about product download buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Shop
  • Download
  • Dokumentation
  • Referenzen
  • Informationen zur Deinstallation unserer Produkte
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Unsere Nachrichten
  • Presse über uns
  • Partner
  • Kontakte

© 1998-2022 by Fast Reports Inc.

  • Datenschutz