locked
how to align bar and independend axis values of winrt xaml column series chart from c# code

    Question

  • how to align bar and independend axis values of winrt xaml column series chart from c# code

    private static Style GetNewDataPointStyle2(int it)
            {
    
               
       
                if (it == 0)
                {
                    background = Colors.SkyBlue;
                }
                if (it == 1)
                {
                    background = Colors.LightGreen;
                }
                if (it == 2)
                {
                    background = Colors.IndianRed;
                }
                if (it == 3)
                {
                    background = Colors.Goldenrod;
                }
                if (it == 4)
                {
                    background = Colors.Chocolate;
                }
                if (it == 5)
                {
                    background = Colors.Aqua;
                }
                if (it == 6)
                {
                    background = Colors.Brown;
                }
    
    
    
                Style style = new Style(typeof(Control));
                Setter st1 = new Setter(Control.BackgroundProperty, new SolidColorBrush(background));
                Setter st2 = new Setter(Control.BorderBrushProperty, new SolidColorBrush(Colors.White));
                Setter st3 = new Setter(Control.BorderThicknessProperty, new Thickness(0));
                Setter st4 = new Setter(Control.HeightProperty, 0);
                Setter st5 = new Setter(Control.WidthProperty, 0);
                Setter st6 = new Setter(Control.MaxWidthProperty, 30);
                Setter st7 = new Setter(Control.MinWidthProperty, 30);
                Setter st8 = new Setter(Control.MarginProperty, new Thickness(5,0,5,0));
                Setter st9 = new Setter(Control.PaddingProperty, new Thickness(2, 2, 2, 2));
               
                //Setter st6 = new Setter(DataPoint.TemplateProperty, null); // causes exception
                style.Setters.Add(st1); style.Setters.Add(st2); style.Setters.Add(st3); style.Setters.Add(st4); style.Setters.Add(st5); style.Setters.Add(st6); style.Setters.Add(st7); style.Setters.Add(st8); style.Setters.Add(st9);
                return style;
            }


    i used this code to fix column/bar size  and give different color to each bar

    my output is looked like

    • Edited by ankit15 Thursday, March 06, 2014 6:43 AM
    Thursday, March 06, 2014 6:35 AM

Answers

  • You don't say what control you are using. There is no control which does what you show in-box. You probably need to talk to the authors of that control for help on how to use it.

    --Rob

    Thursday, March 06, 2014 7:02 AM
    Owner