MS Charts Asp.Net Table For Legend

 If you want a table like thing for a Legend you can take a look at the following.  Putting this in the Load event works.  However...this code was never actually used.  Why?  Because it takes up too much chart real estate, and when the pages to a small width the chart resizes too small and becomes unreadable.  Too bad. :(.

  ////Create a new legend called "Legend3".
         Chart1.Legends.Add(new Legend("Legend3"));

          ////Set Docking of the Legend chart to the Default Chart Area.
         Chart1.Legends["Legend3"].Docking = Docking.Left;
         Chart1.Legends["Legend3"].Alignment = StringAlignment.Center;
       
          ////Assign the legend to Series1.
         Chart1.Series["Series1"].Legend = "Legend3";
         Chart1.Series["Series1"].IsVisibleInLegend = true;


         LegendCellColumn lccSym = new LegendCellColumn("Sym", LegendCellColumnType.SeriesSymbol, "");
         lccSym.HeaderFont = new Font(new FontFamily("Microsoft Sans Serif"), 11);
         Chart1.Legends["Legend3"].CellColumns.Add(lccSym);

         LegendCellColumn lccName = new LegendCellColumn("Name", LegendCellColumnType.Text, "#VALX");
         lccName.HeaderFont = new Font(new FontFamily("Microsoft Sans Serif"), 11);
         lccName.Alignment = ContentAlignment.MiddleLeft;
         Chart1.Legends["Legend3"].CellColumns.Add(lccName);


         //LegendCellColumn lccName = new LegendCellColumn("Name", LegendCellColumnType.Text, "#LEGENDTEXT");
         LegendCellColumn lccPerc = new LegendCellColumn("Percent", LegendCellColumnType.Text, "#PERCENT");
         lccPerc.HeaderFont = new Font(new FontFamily("Microsoft Sans Serif"), 11);
         lccPerc.Alignment = ContentAlignment.MiddleLeft;
         Chart1.Legends["Legend3"].CellColumns.Add(lccPerc);

         LegendCellColumn lccVal = new LegendCellColumn("Value", LegendCellColumnType.Text, "#VALY{C}");
         lccVal.HeaderFont = new Font(new FontFamily("Microsoft Sans Serif"), 11);
         lccVal.Alignment = ContentAlignment.MiddleLeft;
         Chart1.Legends["Legend3"].CellColumns.Add(lccVal);

 Refs
 http://stackoverflow.com/questions/16439279/value-cannot-be-null-parameter-name-font
https://msdn.microsoft.com/en-us/library/vstudio/dd456711%28v=vs.100%29.aspx

Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid