.Net Chart Control     A powerful component for convenient charting. 

More convenience more functionality in Ver. 3.5

Home

Chart Gallery

Chart Decoration

Download

Pricing

How To

FAQ

Using Chart Toolbar

Click here to get sample solution.

Chart Toolbar allows quickly change chart type and legend location, print and save chart, reloads chart data, load and apply themes, rotate 3D charts and call chart parameters form

Toolbar appearance is configured with simple XML document, so you can change its appearance and number of the toolbar buttons in any time. With toolbar abilities to reload data and execute commands you can easy create dynamically changed chart.

At the first we should prepare XML document with toolbar structure. The schema of the chart toolbar XML document is easy.
<ChartToolbar DropDownImage="Art\Toolbar\Arr.png">
	<Band></Band>
	<Button .../>
	<ButtonDropDown Image="Art\Toolbar\ChartType.png" Command="cmdPrepareDropDown" Tooltip="cmdChartType"></ButtonDropDown>
	<Separator/>
</ChartToolbar>
					
<Band> element describe toolbar appearance. It has the same structure as Band type elements in the chart XML. You can find detailed description of the Band type in the user manual.
The <Button> element represents single button in the toolbar. It allows execution of the single command supported by the toolbar. This element has following structure:
<Button
	Image="Name of the image file will be used to show image on the button"
	Command="Command will be executed when button clicked" 
	Tooltip="Name of the predefined tool tip or text will be used as a button tool tip" 
	ChartType="Type of the chart will be shown (should be used with cmdChangeChartType command)" 
	Legend="Legend location (should be used with cmdChangeLegend command)" 
	Theme="Name of the file that contains chart theme (could be used with cmdLoadTheme command)." 
	SplitType="Horizontal | Vertical – Allows create button that consist from 2 ones." 
	Image1="Name of the image file will be used to show image on the button"
	Command1="Command will be executed when button clicked" 
	Tooltip1="Name of the predefined tool tip or text will be used as a button tool tip" 
	Param1="" 
	Param2="" 
	Param3=""/>
					
The <ButtonDropDown> represents the dropdown toolbar button. Click on this button results another panel with buttons appears on the screen. Content of this panel is given as child elements of the <ButtonDropDown> element. This element has following structure:
<ButtonDropDown 
	Image="Name of the image file will be used to show image on the button" 
	Command="Command will be executed when button clicked. 
		Only cmdPrepareDropDown is currently allowed for this button." 
	Tooltip="Name of the predefined tool tip or text will be used as a button tool tip" >
	<Button/><Button/>
</ButtonDropDown>
					
The <Separator/> allows separate one group of the toolbar buttons from another.
Currently chart toolbar supports following commands:
  1. cmdPrint – call standard print dialog. Allows chart printing.
  2. cmdPrintPreview – Allows chart print preview. Call standard .NET print preview dialog.
  3. cmdReloadData – Allows to reload chart data on the fly. Using this command suppose that you provide chart toolbar component with Reload Data delegate where real data reloading will be implemented.
  4. cmdSaveImage – Allows saving chart image to the file.
  5. cmdPrepareDropDown – Prepare and show toolbar dropdown panel.
  6. cmdChangeChartType – Allows changing of the chart type. Suppose that you have specified type of the chart in the “ChartType” attribute of the <Button> element.
  7. cmdChangeLegend – Allows changing of the legend location. Suppose that you have specified legend location in the “Legend” attribute of the <Button> element.
  8. cmdLoadTheme – Perform load chart them from the specified location. Suppose that you have specified location of the theme in the “Theme” attribute of the <Button> element. Theme also could be inserted to the <Button> element as a child. In this case <Button> element will look like the following:
  9. <Button ...>
    	<Layout …></Layout>
    </Button>
  10. cmdLoadThemeFromFile – Allows load of theme from file. Call standard .NET Open File Dialog.
  11. cmdParameters – Call Chart Parameters form.
  12. cmdChangeUp – Increase specified attribute in the given element by the given value. Element is specified by it’s XPath given in the “Param1” attribute of the <Button>. Attribute is specified in the “Param2”. Increment specified in the “Param3”.
  13. cmdChangeDown – Decrease specified attribute in the given element by the given value. Element is specified by it’s XPath given in the “Param1” attribute of the <Button>. Attribute is specified in the “Param2”. Decrement specified in the “Param3”.
  14. cmdChangeAppearance – Call form to change toolbar appearance.
  15. cmdSwitch3D – Switch between 2D and 3D mode.
  16. cmdChangeValueUp – Increase specified property in the given layout element by the given value. Property is specified by its calling path given in the “Param1” attribute of the <Button>. The calling path is relative to the Layout. It could look like the following: “Parameters3D.Transformation.RotationX” – we’d like to change value of the RotationX property that could be accessed normally by the following code: ((Manco.Chart.Layouts.Layout)m_ChartControl.ComponentLayout.LayoutList[liLayoutIdx]). Parameters3D.Transformation.RotationX Index of the Layout (liLayoutIdx in the previous code) is specified in the “Param2”. Increment specified in the “Param3”.
  17. cmdChangeValueDown – Decrease specified property in the given layout element by the given value. Property is specified by its calling path given in the “Param1” attribute of the <Button>. The calling path is relative to the Layout. It could look like the following: “Parameters3D.Transformation.RotationX” – we’d like to change value of the RotationX property that could be accessed normally by the following code: ((Manco.Chart.Layouts.Layout)m_ChartControl.ComponentLayout.LayoutList[liLayoutIdx]). Parameters3D.Transformation.RotationX Index of the Layout (liLayoutIdx in the previous code) is specified in the “Param2”. Increment specified in the “Param3”.
You can find sample of the chart toolbar XML file in the sample solution.
To add toolbar to your form:
  1. Drag and Drop ChartToolbar control on your form.
  2. Position and size it properly.
  3. Create XmlDocument object and load XML from file, or prepare XML with XSLT, or use some other technique to prepare XML document that describe structure of the toolbar (you can find structure of the toolbar XML bellow in this document).
    Stream stream = ResourceLoader.GetFileStream("ChartToolbar.xml"); 
    m_xmlToolbar = new XmlDocument(); 
    m_xmlToolbar.Load(stream); 
    stream.Close();
    							
  4. Use control’s SetStructure method to create toolbar structure:
     
    chartToolbar.SetStructure(xmlToolbar.DocumentElement);
    							
  5. Assign chart control and chart document to the toolbar:
    chartToolbar.Chart = chartControl; 
    chartToolbar.ChartDocument = m_xmlChart;
  6. Assign toolbar events if you need.
You can easy change toolbar appearance just changing The element of the toolbar XML and redraw toolbar. Another way to change toolbar appearance is executing toolbar command “cmdChangeAppearance” either with toolbar button or programmatically.
The code of the constructor of your form could looks like the following:
public Form1()
{
	//
	// Required for Windows Form Designer support
	//
	InitializeComponent();
	
	Stream stream = Manco.Chart.ResourceLoader.GetFileStream("ChartToolbar.xml");
	xmlToolbar = new XmlDocument();
	xmlToolbar.Load(stream);
	stream.Close();
	chartToolbar.SetStructure(xmlToolbar.DocumentElement);
}
				
Add code to load chart XML document and draw chart to the form’s On Load event handler. It could looks like the following:
private XmlDocument xmlChart;
		
private void Form1_Load(object sender, System.EventArgs e)
{
	xmlChart = new XmlDocument();
	xmlChart.Load(Path.GetDirectoryName(Application.ExecutablePath) + "\\IntroChart.xml");
	chartControl.ChartDocument = xmlChart;
	chartToolbar.ChartDocument = xmlChart; 
	chartControl.Draw();
}

Run your application. You will see the chart and toolbar that looks as it was specified in the toolbar XML document.

Click here to get sample solution
Our another product: .Net Licensing System                                                                                                                                    Back to main page of .Net Chart
Copyright © 1994-2005 .Net Charting Software Inc. | Division of ASE         |  contact us  |  about us  |  clients  |  privacy policy  |  Add link   |  .Net resources |  Free services