.NET Framework Bookmark and Share   
 index > Chart Controls for .NET Framework > Only background styling being applied from XML template
 

Only background styling being applied from XML template

I am using an XML file to style a line chart. It looks to me like only the background properties of the chart are being successfully loaded from this file -- the series, axis, legend, etc, seem to be ignoring the XML's styling.

I'm sure there's something horribly obvious and noobishI am missing here.

Here's my markup:

<asp:Chart ID="chartExamples" runat="server" Height="150px" Width="463px">



	<Legends>



		<asp:Legend>



		</asp:Legend>



	</Legends>



	<Series>



		<asp:Series Name="Example 1">



		</asp:Series>



		<asp:Series Name="Example 2">



		</asp:Series>



	</Series>



	<ChartAreas>



		<asp:ChartArea Name="ChartArea1">



		</asp:ChartArea>



	</ChartAreas>



</asp:Chart>




Here's the code-behind:
...







chartExamples.Series["Example 1"].Points.DataBindXY(xval1, yvalExample1OnDay);



chartExamples.Series["Example 2"].Points.DataBindXY(xval1, yvalExample2OnDay);



chartExamples.LoadTemplate("Timeline.xml");




And here's the XML template:
<Chart runat="server" PaletteCustomColors="#a771b0; #cfb4d6;" Height="150px" Palette="None" Width="463px" BackColor="#f7fafe" BorderlineColor="#c8d7eb" BorderlineDashStyle="Solid">



	<Series>



		<Series _Template_="All" ChartType="Spline" CustomProperties="LineTension=0.8, EmptyPointValue=Zero" BackImageTransparentColor="Transparent" BorderWidth="2">



		</Series>



	</Series>



	<Legends>



		<Legend _Template_="All" Alignment="Far" Docking="Top" IsDockedInsideChartArea="False" BackColor="#f7fafe" ForeColor="#1f437c">



		</Legend>



	</Legends>



	<ChartAreas>



		<ChartArea _Template_="All" BorderColor="Transparent" BorderWidth="0" IsSameFontSizeForAllAxes="True" BackColor="Transparent">



			<AxisY LabelAutoFitMaxFontSize="8" LineColor="#c8d7eb">



				<LabelStyle ForeColor="#1f437c" Font="Arial, 8pt" Interval="Auto" />



				<MajorGrid Enabled="True" LineColor="#e3e3e3" LineDashStyle="Dot" />



				<MajorTickMark Enabled="True" LineColor="#c8d7eb" />



				<LabelStyle ForeColor="#1f437c" Font="Arial, 8pt" />



			</AxisY>



			<AxisX LabelAutoFitMaxFontSize="8" LineColor="#c8d7eb" LabelAutoFitMinFontSize="8" IsLabelAutoFit="False" IsMarksNextToAxis="True" IntervalAutoMode="VariableCount" IntervalOffsetType="Days" IntervalType="Days" IsMarginVisible="False">



				<MajorGrid Enabled="False" LineColor="#e3e3e3" LineDashStyle="Dot" />



				<MajorTickMark Enabled="True" LineColor="#c8d7eb" />



				<MinorTickMark Enabled="False" LineColor="#c8d7eb" />



				<LabelStyle ForeColor="#1f437c" Font="Arial, 8pt" Interval="Auto" />



			</AxisX>



		</ChartArea>



	</ChartAreas>



</Chart>

  • Edited byDeak Monday, May 18, 2009 10:03 AM
  •  
Deak
Sorry, that's is a known issue and it is fixed in the next version. Please use Stream with disposing for Chart.Serializer.Load:

using ( Stream s = File.Open(MapPath(@"~\chartTempate.xml"), FileMode.Open) )
{
Chart1.Serializer.Load(s);
}


  • Marked As Answer byDeak Wednesday, May 27, 2009 8:44 AM
  •  
DelianT
Yes, the chart by default ignores all collections in template mode (actually inSerializationContents.Appearance).
You can use Chart.Serializer to setup what to be de-serialized. Replace chartExamples.LoadTemplate("Timeline.xml") with:

Chart1.Serializer.Content = SerializationContents.Appearance;
Chart1.Serializer.SerializableContent += ",Chart.Series, Chart.Legends, Chart.ChartAreas, *.ChartArea, ChartArea.Axis*, Axis.*";
Chart1.Serializer.IsTemplateMode = true;
Chart1.Serializer.IsResetWhenLoading = false;
Chart1.Serializer.Load(MapPath(@"~\chartTempate.xml"));

The code above generally will works for you. It is good to save and restore the state of Content, SerializableContent, IsTemplateMode, IsResetWhenLoading properties.

DelianT
Yes, the chart by default ignores all collections in template mode (actually inSerializationContents.Appearance).
You can use Chart.Serializer to setup what to be de-serialized. Replace chartExamples.LoadTemplate("Timeline.xml") with:

Chart1.Serializer.Content = SerializationContents.Appearance;
Chart1.Serializer.SerializableContent += ",Chart.Series, Chart.Legends, Chart.ChartAreas, *.ChartArea, ChartArea.Axis*, Axis.*";
Chart1.Serializer.IsTemplateMode = true;
Chart1.Serializer.IsResetWhenLoading = false;
Chart1.Serializer.Load(MapPath(@"~\chartTempate.xml"));

The code above generally will works for you. It is good to save and restore the state of Content, SerializableContent, IsTemplateMode, IsResetWhenLoading properties.

DelianT
Hi DelianT,

That's pretty much solved it for me, thanks a lot.

However, why does the XML template file then become "locked" and non-saveable in Visual Studio?
Deak
Sorry, that's is a known issue and it is fixed in the next version. Please use Stream with disposing for Chart.Serializer.Load:

using ( Stream s = File.Open(MapPath(@"~\chartTempate.xml"), FileMode.Open) )
{
Chart1.Serializer.Load(s);
}


  • Marked As Answer byDeak Wednesday, May 27, 2009 8:44 AM
  •  
DelianT
Unfortunately, the template stuff works partially and documentation on serializable properties is non-existent.


Major grid marks and axis label style won't work. I've tried numerous conotations of this property with no luck. Maybe if i knew what all the options were for setting the serilezer.serializablecontenet porperty I could get it work. Chart.Titles was a lucky guess.

Chart1.Serializer.Content =

SerializationContents.Appearance;

Chart1.Serializer.SerializableContent +=

",Chart.Titles,Chart.Series*, Series.*, Chart.Legends, Chart.ChartAreas, *.ChartArea, ChartAreas.AxisY*, AxisX.*, ChartAreas.AxisX*, ChartArea.AxisX, Axis.*";

sushi100
DelianT,
Thanks that fixed it and stopped the XML file from being locked.
/Deak
Deak
Aiseesoft DVD Ripper help you to rip your home-made DVDs, DVD Movies to all popular video formats, and works pergectly with all portable media players.

1. Rip DVDs to MP4, H.264, AVI, MP3, WMV, WMA, FLV, MKV, MPEG-1, MPEG-2, 3GP, 3GPP, VOB, DivX, Mov, RM, RMVB, M4A, AAC, WAV, etc

2. Work perfectly with PSP, iPod Classic, iPod Touch, iPod Nano, iPhone (3G), iPhone, Zune, Zune 2, Blackberry, Nokia, Creative Zen, Sony Walkman, iRiver PMP, Archos, PS3, Apple TV, Xbox, iPAQ, Pocket PC, Mobile Phone

3. Provide the fastest conversion speed (>300%), completely support dual core CPU.

4. Do trim, crop, merge and extract audio file from DVD movies.



Aiseesoft Total Video Converter help you to convert all your videos from internet, camera and so on to the right video format you want.

1. Convert MP4, H.264, AVI, MP3, WMV, WMA, FLV, MKV, MPEG-1, MPEG-2, 3GP, 3GPP, VOB, DivX, Mov, RM, RMVB, M4A, AAC, WAV

2. Work perfectly with PSP, iPod Classic, iPod Touch, iPod Nano, iPhone (3G), iPhone, Zune, Zune 2, Blackberry, Nokia, Creative Zen, Sony Walkman, iRiver PMP, Archos, PS3, Apple TV, Xbox, iPAQ, Pocket PC, Mobile Phone

3. Provide the fastest conversion speed (>300%), completely support dual core CPU
_________________
Best DVD Ripper
Total Video Converter
  •  
jinmindada
As the users of HD Camcorders like Sony, Canon, Panasonic, HD Video Converter is necessary to help us convert hd Video easily and quickly. The Converter for HD provides several practical editing functions to help you achieve ideal output effect. Trim function is to cut videos into clips which you can just convert and transfer to your player. Crop function helps you remove black bars around the movie. You could use Effect function to adjust video brightness, contrast, saturation and more parameters. More powerful and considerate functions are waiting for you to explore. M2TS Converter and MTS Converter

Key Features

1. Convert all HD video, general video and audio

HD Video: HD H.264, HD AVI, HD MPG, HD TS, HD WMV, HD MPEG 4, HD MOV, HD ASF

General Video: MPEG-4, H.264/MPEG-4 AVC, MOV, M4V, AVI, DivX, XviD, ASF, WMV, MPEG-1, MPEG-2, 3GP, 3GPP, MKV, FLV, SWF, VOB, DV, Super VCD, VCD, DVD

Audio: AAC, AC3, AIFF, AMR, AU, FLAC, MP3, M4V, MP2, OGG, WAV, WMA

2. Custom video or audio at will

Effect: Open this window where you could adjust video playing effect which will be shown in Output Preview screen. The parameters you can reset like Brightness, Contrast, Saturation, Volume and Deinterlacing.

Trim: Two scissors mean start point and end point which you could drag to default the clip length you want to convert. Besides, you can set time value to make it.

Crop: If you do not want black bars onto the movie, this function can help you realize. You could set Top, Bottom, Left and Right value or apply Zoom Mode (keep original, full screen, 16:9, 4:3).

Merge: You are allowed to load more than one file at a time and merge them into large one by checking "Merge into one file" option.

3. Create your own profile

Do not satisfied with all defaulted profiles? Emicsoft HD Video Converter lets you reset profile (video encoder, resolution, frame rate, bitrate, audio encoder, sample rate, channels, etc.) and save as new one for later use.

4. Take snapshot when previewing

You could watch added videos on a built-in screen. If there are pictures you like, a Snapshot button can be pressed to capture.

5. Easy to use for novices

Emicsoft HD Video Converter provides an explicit "Getting Started" tutorial to teach novices to use this best hd converter.

http://www.programmersheaven.com/user/stallare/blog/


HD Video Converter and DVD Ripper
  •  
videoconverter

You can use google to search for other answers

Custom Search

More Threads

• Gaps in Stacked Column Chart
• The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) Word interop on RE-open
• X Axis zoom
• Reducing space between column categories
• Chart Control with Authentication mode="Forms"
• Hyperlink (ImageMap?) for Legend items
• How Can I get a series's color
• stacked Bar setting xvalue
• "False Border" on Charts
• In the Crystal Report, change the data displayed at runtime