Group: Forum Members
Last Active: 2 Years Ago
Posts: 5,
Visits: 49
|
Hello , I plot multiple traces on the same chart and axis . Each of the traces has a unique name , and all of them are included in the legend . I would like to have a single custom name for all of these traces in the legend while still having their actual name displayed when you mouse over them . Is it possible to achieve this with the automatic legend ?
|
Group: Forum Members
Last Active: Last Month
Posts: 3,055,
Visits: 4,055
|
Hi Timothy , Yes , you can easily display a legend with a single item ( or any custom number of items ), when you set the legend mode property to manual . The following code shows how to create a chart with two series and a legend that displays a single legend item : & nbsp ;& nbsp ;& nbsp ; NChart chart = nChartControl1 . Charts [ 0 ]; & nbsp ;& nbsp ;& nbsp ;& nbsp ; for ( int i = 0 ; i & lt ; 2 ; i ++) & nbsp ;& nbsp ;& nbsp ;& nbsp ;{ & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; NBarSeries barSeries = new NBarSeries (); & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; barSeries . MultiBarMode = MultiBarMode . Clustered ; & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; barSeries . Values . Add ( 10 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; barSeries . Values . Add ( 20 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; barSeries . Values . Add ( 30 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;& nbsp ; chart . Series . Add ( barSeries ); & nbsp ;& nbsp ;& nbsp ;& nbsp ;} & nbsp ;& nbsp ;& nbsp ;& nbsp ; NLegend legend = nChartControl1 . Legends [ 0 ]; & nbsp ;& nbsp ;& nbsp ;& nbsp ; legend . Mode = LegendMode . Manual ; & nbsp ;& nbsp ;& nbsp ;& nbsp ; NLegendItemCellData legendItem = new NLegendItemCellData (" Single Legend Item ", LegendMarkShape . Rectangle ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; legendItem . MarkFillStyle = new NColorFillStyle ( Color . Red ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; legendItem . MarkLineStyle . Width = new NLength ( 0 ); & nbsp ;& nbsp ;& nbsp ;& nbsp ; legend . Data . Items . Add ( legendItem ); You can also take a look at " All Examples \ Panels \ Legend " group of examples for more examples of how to configure the legend . We hope this helps - let us know if you have any questions or meet any problems .
Best Regards, Nevron Support Team
|