.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 Themes

Click here to get sample solution.
Themes in the Manco.Chart are the real building blocks of the chart layout. Using themes you or your users can create desirable view of the chart during a few seconds. Theme is an XML document that contains ready to use part of the chart layout. The root element of this document could be one of the following: <Charts>, <ComponentLayout> or <Layout>. It could contain any or all parts of the chart layout (see content of the files are located in the subfolders of the Art\Themes folder for theme’s examples). There is one additional attribute that manages theme element loading. This is "Manco.Chart.LoadMode". You can insert this attribute to any node of theme. It can have following values:
  1. Overload – attributes with same names obtain value from the theme's element (default value).
  2. Override – all attributes and child nodes of the layout element will be removed. Theme's attributes and child nodes are copied into the layout element.
  3. OverrideAttributes – all attributes of the layout element will be removed. Theme's attributes are copied into the layout element.
  4. Delete - remove corresponding node from the layout element.
To load theme you could use static method: Manco.Chart.Layouts.Layout.LoadTheme. Another way is to store theme somewhere in the other XML file. In this case you can use Manco.Chart.Layouts.Layout.CopyTheme to copy layout from theme to your chart. It’s possible to load number of themes sequentially. With this ability themes become real building blocks of the chart layout. You can provide your users with themes they will use to decorate charts.
Let see how it could be used on practice.
At the first we should create simple chart desktop application.
  1. Create new windows application.
  2. Add System.Web.dll to the project references.
  3. Open Windows Form, where you would like to add control.
  4. Drag and drop control from the toolbar to your form.
  5. Position and size control according to your needs.

Prepare simple XML chart document and put it to the folder near the application executable (bin\Debug or bin\Release). The chart XML could looks like the following:

<?xml version="1.0" encoding="utf-8" ?>
<Charts>
	<ComponentLayout>
	</ComponentLayout>
	<Chart>
		<Layout Type="Pie">
		</Layout>
		<Data>
			<Value Series="Ser1" Category="Cat1" Value="15" />
			<Value Series="Ser2" Category="Cat1" Value="19" />
			<Value Series="Ser3" Category="Cat1" Value="17" />
		</Data>
	</Chart>
</Charts>

You see, that this document doesn't contain any decoration elements. So the chart you will see will have only default colors.

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;
	chartControl.Draw();
}

Now we need a code to load theme.

Drag and drop OpenFileDialog control to your form. Change its Name to something like that: ofdLoadTheme. Set Filter property to the “Theme (*.xml)|*.xml|All Files (*.*)|*.*” value.

Drag and drop Button control somewhere on your form. Change its Text and Name properties if you’d like. Double click on it to add On Click event handler for this button. Add code to load theme from the file:

private void cmdLoadTheme_Click(object sender, System.EventArgs e)
{
	ofdLoadTheme.InitialDirectory = 
		Path.Combine(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Art"), "Themes");
	if(ofdLoadTheme.ShowDialog() == DialogResult.OK)
	{
		// Load theme to the chart document
		Manco.Chart.Layouts.Layout.LoadTheme(ofdLoadTheme.FileName, xmlChart.DocumentElement);

		// Regenerate layout and draw chart
		chartControl.RegenerateLayout();
		chartControl.Draw();
	}
}
Copy Art folder from the Chart Component .NET installation folder to the folder where your executable is located (bin\Debug or bin\Release).

Run your application. You will see the chart with defult colors.

Click button you've added to load theme. You will see standard file dialog with few directories:

Click here to get sample solution.

These directories contains themes that are provided with Chart Component .NET. Try to load different thems and see result.

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