| ||
SharpPlot Tutorials General Tutorials Chart Samples Style Examples SharpLeaf Tutorials Document Layout Tutorials Text Flow Tutorials Table Tutorials Visual Glossaries SharpPlot Class SharpPlot Properties SharpPlot Structures SharpPlot Enumerations PageMap Class SharpLeaf Reference SharpLeaf Class SharpLeaf Properties SharpLeaf Methods Table Class Table Properties Table Methods SharpLeaf Structures FontType Structure ParagraphStyle Structure BoxStyle Structure SharpLeaf Enumerations DocumentLayout Classes DocumentLayout Class PageLayout Class PageElement Abstract Class Frame : PageElement Class TextBlock : PageElement Class ImageBlock : PageElement Class Box : PageElement Class Rule : PageElement Class Common Reference Document Class VectorMath Class DbUtil Class Download Release Notes Licensing |
SharpPlot Reference > SharpPlot Methods > DrawKey Method SharpPlot.DrawKey MethodThis will draw and clear any pending keys, using the current setting of key text. It is called automatically on Rendering the completed chart, so is only required if you need an exact key location or a custom-designed key. Use the KeyLimit property to restrict the number of items used at each call. Use the SetKeyIndices method for finer control over key selection and order. Examplesp.KeyStyle = KeyStyles.Boxed|KeyStyles.Vertical|KeyStyles.Shadowed|KeyStyles.Rounded; sp.SetKeyBackground(Color.SlateBlue,FillStyle.Solid); sp.SetKeyFont("Arial,sans",12,FontStyle.Bold,Color.Orange); sp.SetKeyText(new string[]{"First","Second"}); sp.DrawKey(2,260); Overloads
DescriptionThe chart Key or Legend consists of small placeholders for each line or filled area (appropriately coloured and styled) with an item of descriptive text for each. When any of the Draw methods is called to create a chart (you may call these repeatedly with various series to reuse the same set of axes) a placeholder is stored away to represent all the series plotted on that call. When the chart is rendered, DrawKey is called automatically to check if any KeyText has been set for the various series. If so, a placeholder and associated text are drawn as specified in the KeyStyle setting. This method may be used to position the key ‘by hand’ anywhere in the chart area instead of at one of the many default locations which may be given in the style. It should always be called after all the charts have been drawn, otherwise the key placeholders will not be available for all the data series. It is possible to override the automatic key-generation process completely, passing an array of key-definitions as the 3rd argument. sp.SetKeyText(new string[] {"Corals","Latiproductus"}); sp.KeyStyle = KeyStyles.Vertical|KeyStyles.Boxed; sp.DrawKey(72,25, new KeyDefinition[] { new KeyDefinition(2,Color.Maroon), new KeyDefinition(2,Color.Green) } ) This example is from the ‘Wise Eel’s Bridge’ cellular plot in the sample set. See also ...SharpPlot Members | SharpPlot.KeyLimit Property | SharpPlot.KeyStyle Property | SharpPlot.SetKeyIndices Method |