Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -05001740757http://forums.silverlight.net//p/12592/40757.aspx/1?create+line+chart+in+silverlight2+0create line chart in silverlight2.0 <p>create line chart in silverlight2.0</p> 2008-03-25T09:06:07-04:0041527http://forums.silverlight.net//p/12592/41527.aspx/1?Re+create+line+chart+in+silverlight2+0Re: create line chart in silverlight2.0 <p>Hello, here's a simple sample:</p> <p>First you should have a Path with a PathFigure to draw your lines. Note that the Silverlight coordinate begins from the top left. That is, the top left point of the Path is 0,0. This is different from math coordinates. The easiest solution is to create a transform on the Path.</p> <font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">Path</font><font color="#ff0000" size="2"> Stroke</font><font color="#0000ff" size="2">=&quot;Black&quot;</font><font color="#ff0000" size="2"> Margin</font><font color="#0000ff" size="2">=&quot;10,10,0,0&quot;&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">Path.Data</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">PathGeometry</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">PathFigure</font><font color="#ff0000" size="2"> x</font><font color="#0000ff" size="2">:</font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;figure&quot;/&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">PathGeometry</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">Path.Data</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">Path.RenderTransform</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">TransformGroup</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">RotateTransform</font><font color="#ff0000" size="2"> Angle</font><font color="#0000ff" size="2">=&quot;180&quot;/&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">ScaleTransform</font><font color="#ff0000" size="2"> ScaleX</font><font color="#0000ff" size="2">=&quot;-1&quot;/&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">TranslateTransform</font><font color="#ff0000" size="2"> Y</font><font color="#0000ff" size="2">=&quot;200&quot;/&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">TransformGroup</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">Path.RenderTransform</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#a31515" size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">Path</font><font color="#0000ff" size="2">&gt;</p> </font> <p>When your path is ready, you can draw lines based on your data source.</p> <font size="2"> <p></font><font color="#008000" size="2">//Some dummy data.</p> </font><font size="2"></font><font color="#2b91af" size="2">List</font><font size="2">&lt;</font><font color="#0000ff" size="2">double</font><font size="2">&gt; source = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">List</font><font size="2">&lt;</font><font color="#0000ff" size="2">double</font><font size="2">&gt;();</font><font size="2"> <p></font><font color="#2b91af" size="2">Random</font><font size="2"> random = </font> <font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Random</font><font size="2">();</p> </font><font color="#0000ff" size="2">for</font><font size="2"> (</font><font color="#0000ff" size="2">int</font><font size="2"> i = 0; i &lt; 20; i&#43;&#43;)</font><font size="2"> <p>{</p> <p>source.Add(random.NextDouble() * 200);</p> <p>}</p> <p></font><font color="#008000" size="2">//Draw lines according to the data.</p> </font><font size="2">figure.Segments = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">PathSegmentCollection</font><font size="2">();</font><font size="2"> <p>figure.StartPoint = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Point</font><font size="2">(0, source[0]);</p> </font><font color="#0000ff" size="2">for</font><font size="2">(</font><font color="#0000ff" size="2">int</font><font size="2"> i = 1; i &lt; source.Count; i&#43;&#43;)</font><font size="2"> <p>{</p> </font><font color="#2b91af" size="2">LineSegment</font><font size="2"> segment = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">LineSegment</font><font size="2">() { Point = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Point</font><font size="2">(i * 20, source[i]) };</font><font size="2"> <p>figure.Segments.Add(segment);</p> <p>}</p> </font> 2008-03-27T05:49:13-04:0041620http://forums.silverlight.net//p/12592/41620.aspx/1?Re+create+line+chart+in+silverlight2+0Re: create line chart in silverlight2.0 <p>Hello Sir,</p> <p>&nbsp;</p> <p>I m Subhash iand i am very new to silverlight. i have a assignment to draw line chart. i have seen your code given but i am not getting where i have to write this code, xaml file or javascript or else..</p> <p>i copied your code in expression blend but for loops and other parts from for loop shows eerror..</p> <p>&nbsp;</p> <p>please tell me how to see output..</p> 2008-03-27T10:49:30-04:0041624http://forums.silverlight.net//p/12592/41624.aspx/1?Re+create+line+chart+in+silverlight2+0Re: create line chart in silverlight2.0 <p>Put the XAML code in Page.xaml between &lt;Grid x:Name=&quot;LayoutRoot&quot;&gt;&lt;/Grid&gt;. Put the C# code in Page.xaml.cs under the constructor below InitializeComponent(); You can begin learning Silverlight with the resources found in <a href="http://silverlight.net/learn/">http://silverlight.net/learn/</a>.</p> 2008-03-27T11:01:11-04:0041625http://forums.silverlight.net//p/12592/41625.aspx/1?Re+create+line+chart+in+silverlight2+0Re: create line chart in silverlight2.0 <p>Hii.. How can i read data from xml file using silverlight.</p> <p>just give me small example please. to read xml data using silverligh and display in html file.</p> <p>as simple as possible . without use of server . xml file will locally on system in some drive.</p> <p>plz tell me stepwise</p> 2008-03-27T11:10:18-04:0041628http://forums.silverlight.net//p/12592/41628.aspx/1?Re+Re+create+line+chart+in+silverlight2+0Re: Re: create line chart in silverlight2.0 <p>ok i will try and if i will not get then again i will disturb you.. please don't mind .. help me sir...</p> <p>sir acctually i m still using javascript to write events and xaml for desigining. and calling it in html file.</p> <p>i don't have vs-08 so may be i am unable to understand .. ok i will try with that and inform you. thanku sir </p> 2008-03-27T11:23:31-04:0041646http://forums.silverlight.net//p/12592/41646.aspx/1?Re+Re+create+line+chart+in+silverlight2+0Re: Re: create line chart in silverlight2.0 <p>we have to set the axis(x,y) . can u give me the idea .</p> 2008-03-27T12:40:59-04:0041851http://forums.silverlight.net//p/12592/41851.aspx/1?Re+Re+create+line+chart+in+silverlight2+0Re: Re: create line chart in silverlight2.0 <p>Can you be more specific? Do you want to draw two axis?</p> 2008-03-28T02:45:13-04:0041872http://forums.silverlight.net//p/12592/41872.aspx/1?Re+Re+Re+create+line+chart+in+silverlight2+0Re: Re: Re: create line chart in silverlight2.0 <p>yes. dynamically we will give the vaue according to it will draw the line in a x-y axis</p> 2008-03-28T04:06:08-04:0041937http://forums.silverlight.net//p/12592/41937.aspx/1?Re+Re+Re+Re+create+line+chart+in+silverlight2+0Re: Re: Re: Re: create line chart in silverlight2.0 <p>users will give the value and according to it will draw the line .</p> <p>i need this scenario.</p> 2008-03-28T08:38:44-04:0041978http://forums.silverlight.net//p/12592/41978.aspx/1?Re+Re+Re+Re+Re+create+line+chart+in+silverlight2+0Re: Re: Re: Re: Re: create line chart in silverlight2.0 <p>In my original code, you'll notice I hard code:</p> <p><font size="2">source.Add(random.NextDouble() * 200);</font></p> <p>Random.NextDouble will return a value between 0 and 1. So if the value is 0.82, then the point representing this value will have a y axis of 164. So the basic idea is: you can calculate a proper y value based on your coordinate system. Sorry I don't have time to write a more complete sample...</p> 2008-03-28T10:37:08-04:0041982http://forums.silverlight.net//p/12592/41982.aspx/1?Re+Re+Re+Re+Re+Re+create+line+chart+in+silverlight2+0Re: Re: Re: Re: Re: Re: create line chart in silverlight2.0 <p>thanks shan</p> 2008-03-28T10:50:52-04:0044018http://forums.silverlight.net//p/12592/44018.aspx/1?How+to+replace+variable+valueHow to replace variable value <p>suppose we have two varibale&nbsp;</p> <p>var t= 50;<br> var l= 22;</p> <p>then how can i put t and l&nbsp; value in below statement for Top and Left</p> <p>var e =slControl.content.createFromXaml('&lt;Ellipse&nbsp; Height=&quot;10&quot; Width=&quot;10&quot; Fill=&quot;red&quot; Canvas.top=&quot;t&quot; &nbsp;Canvas.Left=&quot;l&quot; /&gt;');</p> <p>plz reply soon its urgent</p> <p>&nbsp;</p> <p>Thanking You</p> <p>Subhash</p> 2008-04-04T04:29:25-04:0044032http://forums.silverlight.net//p/12592/44032.aspx/1?Re+How+to+replace+variable+valueRe: How to replace variable value <p></p> <blockquote><span class="icon-blockquote"></span> <h4>sitian</h4> var e =slControl.content.createFromXaml('&lt;Ellipse&nbsp; Height=&quot;10&quot; Width=&quot;10&quot; Fill=&quot;red&quot; Canvas.top=&quot;t&quot; &nbsp;Canvas.Left=&quot;l&quot; /&gt;');</blockquote> &nbsp; <p></p> <p>var e =slControl.content.createFromXaml('&lt;Ellipse&nbsp; Height=&quot;10&quot; Width=&quot;10&quot; Fill=&quot;red&quot; Canvas.top=&quot;<b>' &#43; t &#43; '</b>&quot; &nbsp;Canvas.Left=&quot;<b>' &#43; l &#43; '</b>&quot; /&gt;'); <br> </p> 2008-04-04T06:17:05-04:0044059http://forums.silverlight.net//p/12592/44059.aspx/1?Re+How+to+replace+variable+valueRe: How to replace variable value <p>Thanks .. its worked..</p> <p>&nbsp;</p> <p>Thank alot..</p> <p>&nbsp;</p> <p>one more problem ..</p> <p>i am creating few ellipse at runtime when canvas will load.... like this below code..</p> <p>for(i=0;i&lt;n1.length;i&#43;&#43;){<br> &nbsp;&nbsp; var t= n1[i]-10;<br> &nbsp;&nbsp; var l= hspace*(i)&#43;15;</p> <p>&nbsp;&nbsp; var slControl = Sender.getHost();</p> <p>&nbsp;&nbsp; var e =slControl.content.createFromXaml('&lt;Ellipse Fill=&quot;blue&quot; Opacity=&quot;0.5&quot; Height=&quot;10&quot; Width=&quot;10&quot; Canvas.Top=&quot;'&#43;t&#43;'&quot; Canvas.Left=&quot;'&#43;l&#43;'&quot; MouseEnter=&quot;show&quot;/&gt;');<br> &nbsp;&nbsp; var canvas = Sender.findName(&quot;main&quot;);<br> &nbsp;&nbsp; canvas.children.Add(e);</p> <p>}</p> <p>&nbsp;</p> <p>Now on other event i want to remove all previous ellipse and draw it again with differn parameter say i=0;i&lt;n-20;i&#43;&#43;</p> <p>how i can do it ..</p> <p>&nbsp;</p> <p>&quot;Thanking You&quot;</p> <p>&nbsp;</p> <p>Subhash</p> 2008-04-04T08:38:34-04:0044108http://forums.silverlight.net//p/12592/44108.aspx/1?Re+How+to+replace+variable+valueRe: How to replace variable value <p>Look at this:&nbsp;</p> <p>http://www.visifire.com/index.php&nbsp;</p> 2008-04-04T13:46:40-04:0044791http://forums.silverlight.net//p/12592/44791.aspx/1?Re+Re+How+to+replace+variable+valueRe: Re: How to replace variable value <p>Hello Sir,</p> <p>Thanks for this nice link..</p> <p>now charting becames easy.</p> <p>i am new so i have some problem.</p> <p>i am saving Data.xml and calling in html then its showing an error </p> <p>error is:--&gt;Error Log Version:1.0.6 Beta</p> <p>[Arg_NotsupportedException]</p> <p>Arguments:</p> <p>debugging Resources string are unavailbale</p> <p>at System.Net.Webclient(...)</p> <p>at .....................................</p> <p>&nbsp;</p> <p>can you help me to come out</p> <p>&nbsp;</p> <p>Thank You</p> 2008-04-08T05:58:17-04:0044792http://forums.silverlight.net//p/12592/44792.aspx/1?Re+Re+How+to+replace+variable+valueRe: Re: How to replace variable value <p>Hello Sir,</p> <p>Thanks for this nice link..</p> <p>now charting becames easy.</p> <p>i am new so i have some problem.</p> <p>i am saving Data.xml and calling in html then its showing an error </p> <p>error is:--&gt;Error Log Version:1.0.6 Beta</p> <p>[Arg_NotsupportedException]</p> <p>Arguments:</p> <p>debugging Resources string are unavailbale</p> <p>at System.Net.Webclient(...)</p> <p>at .....................................</p> <p>&nbsp;</p> <p>can you help me to come out</p> <p>&nbsp;</p> <p>Thank You</p> 2008-04-08T05:58:18-04:0046385http://forums.silverlight.net//p/12592/46385.aspx/1?Re+Re+How+to+replace+variable+valueRe: Re: How to replace variable value <p>Have a look at the following forum post. I guess you've a similar problem&nbsp;</p> <p>http://www.visifire.com/forums/index.php?showtopic=27&nbsp;</p> 2008-04-14T18:00:43-04:0046616http://forums.silverlight.net//p/12592/46616.aspx/1?How+to+intract+with+html+pageHow to intract with html page <p>Hello Sir, i am desiging one slider in silverlight and i need to intract with table content which is in html.. when slider left or right thumb will move then table value should also change,,,, Note: i am using javascrip code so plz answer with this context only.. Thank you Sir </p> 2008-04-15T09:10:15-04:00