Create a Custom Palette
- 2 minutes to read
Palettes are used to paint chart series. You can use the predefined palettes that ship with the Chart Control or create a custom palette.
Create and Apply a Palette at Design Time
Click the chart’s smart tag and select the Palettes… link.
This invokes the Palettes dialog that you can use to change the collection of predefined palettes and create new palettes.
Click the Add button.
Rename the newly created palette.
Click the plus button to add new colors to the palette. Double-click a color to change it.
Click OK to save the palette and apply it to the chart. This registers the palette in the Chart Control’s palette repository and adds the palette to the chart toolbar‘s Palette menu.
Create and Apply a Palette at Runtime
- Create a Palette object and use the Add method to populate the palette with colors.
- Use the ChartControl.PaletteRepository.RegisterPalette method to register the palette in the chart control.
- To apply the palette to the chart, assign the palette name to the ChartControl.PaletteName property.
The following example shows how to create a palette, register and apply it to a chart:
// Create a palette.
Palette palette = new Palette("Custom Palette");
palette.Add(Color.Yellow);
palette.Add(Color.Red);
palette.Add(Color.Green);
// Register the palette.
chartControl1.PaletteRepository.RegisterPalette(palette);
// Assign the palette to the chart.
chartControl1.PaletteName = "Custom Palette";
See Also