Class MSChartObject
Represents the chart object based on Microsoft Chart control.
Inheritance
Inherited Members
Namespace: FastReport.MSChart
Assembly: FastReport.dll
Syntax
public class MSChartObject : ReportComponentBase, IComponent, IDisposable, IFRSerializable, IHasEditor, IParent
Remarks
FastReport uses the System.Windows.Forms.DataVisualization library to build diagrams.
To access Microsoft Chart object, use the Chart property. It allows you to set up chart appearance. For more information on available properties, refer to the MS Chart documentation.
Chart object may contain one or several series. Each series is represented by two objects:
- the Series that is handled by MS Chart. It is stored in the Chart.Series collection;
- the MSChartSeries object that provides data for MS Chart series. It is stored in the Series collection.
Do not operate series objects directly. To add or remove series, use the AddSeries(SeriesChartType) and DeleteSeries(Int32) methods. These methods handle Series and MSChartSeries in sync.
If you have a chart object on your Form and want to print it in FastReport, use the AssignChart(Chart) method.
Constructors
MSChartObject()
Initializes a new instance of the MSChartObject with default settings.
Declaration
public MSChartObject()
Properties
AlignXValues
Gets or sets a value indicating that all series' data point should be aligned by its X value.
Declaration
public bool AlignXValues { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Using this property is necessary to print stacked type series. These series must have equal number of data points, and the order of data points must be the same for all series.
AutoSeriesColor
Gets or set the color for auto-series.
Declaration
public string AutoSeriesColor { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
If no color is specified, the new series will use the palette defined in the chart.
AutoSeriesColumn
Gets or set the data column or expression for automatically created series.
Declaration
public string AutoSeriesColumn { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
In order to create auto-series, you need to define one series that will be used as a template for new series, and set up the AutoSeriesColumn property. The value of this property will be a name of new series. If there is no series with such name yet, the new series will be added.
AutoSeriesForce
Gets or set Force automatically created series.
Declaration
public bool AutoSeriesForce { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
AutoSeriesSortOrder
Gets or sets sort order for auto-series.
Declaration
public SortOrder AutoSeriesSortOrder { get; set; }
Property Value
Type | Description |
---|---|
SortOrder |
Chart
Gets a reference to the MS Chart object.
Declaration
public Chart Chart { get; }
Property Value
Type | Description |
---|---|
FastReport.DataVisualization.Charting.Chart |
DataSource
Gets or sets the data source.
Declaration
public DataSourceBase DataSource { get; set; }
Property Value
Type | Description |
---|---|
DataSourceBase |
EvenStyle
This property is not relevant to this class.
Declaration
[Browsable(false)]
public string EvenStyle { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Filter
Gets or sets the filter expression.
Declaration
public string Filter { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This filter will be applied to all series in chart. You may also use the series' Filter property to filter each series individually.
HoverStyle
This property is not relevant to this class.
Declaration
[Browsable(false)]
public string HoverStyle { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Series
Gets the collection of MSChartSeries objects.
Declaration
[Browsable(false)]
public SeriesCollection Series { get; }
Property Value
Type | Description |
---|---|
SeriesCollection |
Style
This property is not relevant to this class.
Declaration
[Browsable(false)]
public string Style { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AddChild(Base)
Adds a child object to this object's childs.
Declaration
public void AddChild(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Object to add. |
AddSeries(SeriesChartType)
Adds a new series.
Declaration
public MSChartSeries AddSeries(SeriesChartType chartType)
Parameters
Type | Name | Description |
---|---|---|
FastReport.DataVisualization.Charting.SeriesChartType | chartType | The type of series. |
Returns
Type | Description |
---|---|
MSChartSeries | The new MSChartSeries object. |
Assign(Base)
Copies the contents of another, similar object.
Declaration
public override void Assign(Base source)
Parameters
Type | Name | Description |
---|---|---|
Base | source | Source object to copy the contents from. |
Overrides
Remarks
Call Assign to copy the properties from another object of the same type. The standard form of a call to Assign is
destination.Assign(source);
which tells the destination object to copy the contents of the source object to itself. In this method, all child objects are ignored. If you want to copy child objects, use the AssignAll method.
See Also
AssignChart(Chart)
Assigns chart appearance, series and data from the System.Windows.Forms.DataVisualization.Charting.Chart object.
Declaration
public void AssignChart(Chart sourceChart)
Parameters
Type | Name | Description |
---|---|---|
FastReport.DataVisualization.Charting.Chart | sourceChart | Chart object to assign data from. |
Remarks
Use this method if you have a chart in your application and want to print it in FastReport. To do this, put an empty MSChartObject in your report and execute the following code:
report.Load("...");
MSChartObject reportChart = report.FindObject("MSChart1") as MSChartObject;
reportChart.AssignChart(applicationChart);
report.Show();
CanContain(Base)
Gets a value indicating that this object can contain the specified child object.
Declaration
public bool CanContain(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Boolean | true if this object can contain the specified child object; otherwise, false. |
DeleteSeries(Int32)
Deletes a series at a specified index.
Declaration
public void DeleteSeries(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of series. |
Deserialize(FRReader)
Declaration
public override void Deserialize(FRReader reader)
Parameters
Type | Name | Description |
---|---|---|
FRReader | reader |
Overrides
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
Draw(FRPaintEventArgs)
Declaration
public override void Draw(FRPaintEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
FRPaintEventArgs | e |
Overrides
FinalizeComponent()
Performs a finalization after the report is finished.
Declaration
public override void FinalizeComponent()
Overrides
Remarks
This method is used by the report engine, do not call it directly.
GetChildObjects(ObjectCollection)
Gets a list of child objects.
Declaration
public void GetChildObjects(ObjectCollection list)
Parameters
Type | Name | Description |
---|---|---|
ObjectCollection | list | List to fill with values. |
GetChildOrder(Base)
Returns z-order of the specified child object.
Declaration
public int GetChildOrder(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
Returns
Type | Description |
---|---|
System.Int32 | Z-order of the specified object. |
Remarks
This method must return the index of a specified child object in the internal child list.
GetData()
Gets the data from a datasource that the object is connected to.
Declaration
public override void GetData()
Overrides
Remarks
This method is called by the report engine before processing the object.
Do not call it directly. You may override it if you are developing a new FastReport component. In this method you should get the data from a datasource that the object is connected to.
GetDataAsync(CancellationToken)
Declaration
public override async Task GetDataAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
GetExpressions()
Gets all expressions contained in the object.
Declaration
public override string[] GetExpressions()
Returns
Type | Description |
---|---|
System.String[] | Array of expressions or null if object contains no expressions. |
Overrides
Remarks
Do not call this method directly. You may override it if you are developing a new component for FastReport.
This method is called by FastReport each time before run a report. FastReport do this to collect all expressions and compile them. For example, GetExpressions method of the TextObject class parses the text and returns all expressions found in the text.
GetPreferredSize()
Gets the preferred size of an object.
Declaration
public override SizeF GetPreferredSize()
Returns
Type | Description |
---|---|
System.Drawing.SizeF | Preferred size. |
Overrides
Remarks
This method is called by the FastReport designer when you insert a new object.
InitializeComponent()
Initializes the object before running a report.
Declaration
public override void InitializeComponent()
Overrides
Remarks
This method is used by the report engine, do not call it directly.
InvokeEditor()
Invokes the object's editor.
Declaration
public bool InvokeEditor()
Returns
Type | Description |
---|---|
System.Boolean | true if object was succesfully edited. |
Remarks
This method is called by FastReport when the object is doubleclicked in the designer.
OnAfterInsert(InsertFrom)
Called after the new object was inserted in the designer.
Declaration
public override void OnAfterInsert(InsertFrom source)
Parameters
Type | Name | Description |
---|---|---|
InsertFrom | source | The insertion source. |
Overrides
Remarks
Do not call this method directly. You may override it if you are developing a new component for FastReport.
This method is called when new object is inserted, pasted from clipboard or dragged from "Dictionary" window. You may override this method if you need to perform some actions when object is inserted. Typical implementation invokes the object's editor if "Edit after insert" flag is set in the designer options.
OnBeforeInsert(Int32)
Called before inserting a new object in the designer.
Declaration
public override void OnBeforeInsert(int flags)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | flags | Object's flags. |
Overrides
Remarks
Do not call this method directly. You may override it if you are developing a new component for FastReport.
Some objects are registered in the designer several times with the same object type, but different flags. For example, the ShapeObject represents different shapes: rectangle, roundrect, ellipse and so on. All these shapes are registered in the designer using flags (the last parameter in this code):
RegisteredObjects.Add(typeof(ShapeObject), "ReportPage,Shapes", 108, "Objects,Shapes,Rectangle", 0);
RegisteredObjects.Add(typeof(ShapeObject), "ReportPage,Shapes", 109, "Objects,Shapes,RoundRectangle", 1);
RegisteredObjects.Add(typeof(ShapeObject), "ReportPage,Shapes", 110, "Objects,Shapes,Ellipse", 2);
When we put the "Ellipse" object on a band, the designer creates the ShapeObject instance and calls its OnBeforeInsert method with flags value set to 2. In turn, the OnBeforeInsert method converts the int value of the flags to the shape kind:
public override void OnBeforeInsert(int flags)
{
FShape = (ShapeKind)flags;
}
OnMouseLeave(EventArgs)
This method fires the MouseLeave event and the script code connected to the MouseLeaveEvent.
Declaration
public override void OnMouseLeave(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event data. |
Overrides
OnMouseMove(MouseEventArgs)
This method fires the MouseMove event and the script code connected to the MouseMoveEvent.
Declaration
public override void OnMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.MouseEventArgs | e | Event data. |
Overrides
RemoveChild(Base)
Removes a specified object from this object's childs.
Declaration
public void RemoveChild(Base child)
Parameters
Type | Name | Description |
---|---|---|
Base | child |
RestoreState()
Restores the object's state after printing it.
Declaration
public override void RestoreState()
Overrides
Remarks
This method is called by the report engine after processing the object.
Do not call it directly. You may override it if you are developing a new FastReport component. In this method you should restore the object properties that were saved by the SaveState() method.
SaveState()
Saves the object's state before printing it.
Declaration
public override void SaveState()
Overrides
Remarks
This method is called by the report engine before processing the object.
Do not call it directly. You may override it if you are developing a new FastReport component. In this method you should save any object properties that may be changed during the object printing. The standard implementation saves the object's bounds, visibility, bookmark and hyperlink.
Serialize(FRWriter)
Serializes the object.
Declaration
public override void Serialize(FRWriter writer)
Parameters
Type | Name | Description |
---|---|---|
FRWriter | writer | Writer object. |
Overrides
Remarks
Do not call this method directly. You should override it if you are developing a new component for FastReport.
This method is called when the object needs to save the state. It may happen when:
- saving the report to the file or stream;
- saving the report to the designer's undo buffer;
- assigning the object to another object using the Assign(Base) or AssignAll methods;
- saving the object to the designer's clipboard;
- saving the object to the preview (when run a report).
SetChildOrder(Base, Int32)
Sets the z-order of the specified object.
Declaration
public void SetChildOrder(Base child, int order)
Parameters
Type | Name | Description |
---|---|---|
Base | child | Child object. |
System.Int32 | order | New Z-order. |
Remarks
This method must place the specified child object at the specified position in the internal child list.
UpdateLayout(Single, Single)
Updates the children layout when the size of this object is changed by dx, dy values.
Declaration
public void UpdateLayout(float dx, float dy)
Parameters
Type | Name | Description |
---|---|---|
System.Single | dx | X delta. |
System.Single | dy | Y delta. |
Remarks
This method must update positions/sizes of child objects whose Dock or Anchor properties are set to non-default values.