c# - Getting more than one Legend object in LegendCollection to stack vertically when chart renders -
i'm trying learn mschart control. want create histogram chart has stat panel right displays statistics chart. tried doing creating legend object docked right.
i boxes stack vertically right of chart. each box represents legend object in legendscollection.
code:
private void createstatpanel( chart chart ) { var legend = new legend { title = "basic stats", titlealignment = stringalignment.near, titlebackcolor = color.lightgray, docking = docking.right, bordercolor = color.lightgray, borderwidth = 1, borderdashstyle = chartdashstyle.solid, }; var item = new legenditem(); var column = new legendcell { celltype = legendcelltype.text, backcolor = color.white, forecolor = color.black, text = "54 data values ", alignment = contentalignment.middleright }; var item2 = new legenditem(); var column2 = new legendcell { celltype = legendcelltype.text, backcolor = color.white, forecolor = color.black, text = "maximum \t 14", alignment = contentalignment.middleright }; var box = new legend { title = "subgroup stats", titlealignment = stringalignment.near, titlebackcolor = color.lightgray, bordercolor = color.lightgray, borderwidth = 1, borderdashstyle = chartdashstyle.solid }; var boxrowone = new legenditem(); var boxrowcell = new legendcell { celltype = legendcelltype.text, backcolor = color.white, forecolor = color.black, text = "n=6", alignment = contentalignment.middleright }; var boxrowtwo = new legenditem(); var boxrowtwocell = new legendcell { celltype = legendcelltype.text, backcolor = color.white, forecolor = color.black, text = "estimated sigma", alignment = contentalignment.middleleft }; var boxrowtwocelltwo = new legendcell { celltype = legendcelltype.text, backcolor = color.white, forecolor = color.black, text = "1.82", alignment = contentalignment.middleleft }; item.cells.add( column ); item2.cells.add( column2 ); boxrowone.cells.add(boxrowcell); boxrowtwo.cells.add(boxrowtwocell); boxrowtwo.cells.add(boxrowtwocelltwo); box.customitems.add(boxrowone); box.customitems.add(boxrowtwo); legend.customitems.add( item ); legend.customitems.add( item2 ); chart.legends.add( legend ); chart.legends.add( box ); chart.series[ 0 ].isvisibleinlegend = false; }
you can try this:
chart.legends[component].legendstyle = legendstyle.column; chart.legends[component].docking = docking.right;
Comments
Post a Comment