c# - How to rotate labels of WinRTXamlToolkit column chart? -


i have following xaml definition:

<charting:chart x:name="columnchart"                 horizontalalignment="center"                 verticalalignment="center"                 width="auto"                 height="auto"                 padding="50"                 title="100 random numbers">     <charting:columnseries title="skills"                            independentvaluepath="name"                            dependentvaluepath="pts"                            isselectionenabled="true">      </charting:columnseries> </charting:chart> 

how can rotate labels (let's on -90 degrees) in order make them more readable?

enter image description here

rotating labels possible. requires few steps, , unfortunately, due missing feature in winrt xaml layout, custom class potentially.

the core idea found here.

<grid background="{themeresource applicationpagebackgroundthemebrush}">     <charting:chart x:name="columnchart"             horizontalalignment="stretch"             verticalalignment="stretch"             padding="50"             title="100 random numbers">         <charting:columnseries title="skills" x:name="thecolumnseries"                        independentvaluepath="name"                        dependentvaluepath="pts"                        isselectionenabled="true">             <charting:columnseries.independentaxis>                 <charting:categoryaxis orientation="x">                     <charting:categoryaxis.axislabelstyle>                         <style targettype="charting:axislabel">                             <setter property="template">                                 <setter.value>                                     <controltemplate targettype="charting:axislabel">                                         <textblock text="{templatebinding formattedcontent}">                                             <textblock.lay                                             <textblock.rendertransform>                                                 <rotatetransform angle="-60" />                                             </textblock.rendertransform>                                         </textblock>                                     </controltemplate>                                 </setter.value>                             </setter>                         </style>                     </charting:categoryaxis.axislabelstyle>                 </charting:categoryaxis>             </charting:columnseries.independentaxis>         </charting:columnseries>     </charting:chart> </grid> 

the c# code used:

public sealed partial class mainpage : page {     public mainpage()     {         this.initializecomponent();          this.loaded += mainpage_loaded;     }      void mainpage_loaded(object sender, routedeventargs e)     {         var rnd = new random(444);         observablecollection<demo> values = new observablecollection<demo>();         (int = 0; < 15; i++)         {             values.add(new demo() { name = (rnd.nextdouble() * 100).tostring(), pts = });         }           ((columnseries)columnchart.series[0]).itemssource = values;     } }  class demo {     public string name { get; set; }     public double pts { get; set; } } 

but, unfortunately, it's not you'll want. problem there isn't layouttransform exists in wpf. if run code shown above, labels rotated, overlap other content.

rotation not right

the author of blog has written layouttransformer class may solve problem, although designed silverlight (so may portable , work winrt xaml).


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -