Back to Devexpress

ChartImageUtils Class

corelibraries-devexpress-dot-xtracharts-cc7167b1.md

latest4.6 KB
Original Source

ChartImageUtils Class

Contains APIs for chart images.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public static class ChartImageUtils
vb
Public Module ChartImageUtils

Example

In the example below, a user can switch between series views by selecting them in the drop-down list.

The following code uses the ChartImageUtils.GetViewImage method to obtain view icons and then use them to create an ImageComboBoxEdit‘s items. ImageCollection objects (in the example below, smallViewImages and viewImages) are used to store images:

csharp
using DevExpress.Utils.Svg;
using DevExpress.XtraCharts;
using DevExpress.XtraEditors.Controls;
using System;
using System.Drawing;
using System.Windows.Forms;

private void Form1_Load(object sender, EventArgs e) {
    SvgPalette palette = new SvgPalette();
    palette.Colors.Add(new SvgColor("Red", ColorTranslator.FromHtml("#D04D2F")));
    palette.Colors.Add(new SvgColor("Yellow", ColorTranslator.FromHtml("#EEB764")));
    palette.Colors.Add(new SvgColor("Blue", ColorTranslator.FromHtml("#377AB5")));
    palette.Colors.Add(new SvgColor("Green", ColorTranslator.FromHtml("#4DAE89")));
    palette.Colors.Add(new SvgColor("Black", ColorTranslator.FromHtml("#000000")));
    palette.Colors.Add(new SvgColor("White", ColorTranslator.FromHtml("#FFFFFF")));

    imageComboBoxEdit1.Properties.SmallImages = viewImages;
    imageComboBoxEdit1.Properties.LargeImages = smallViewImages;

    viewImages.ImageSize = new Size(16, 16);
    smallViewImages.ImageSize = new Size(32, 32);

    foreach (ViewType vt in Enum.GetValues(typeof(ViewType))) {

        viewImages.AddImage(ChartImageUtils.GetViewImage(vt, palette));
        smallViewImages.AddImage(ChartImageUtils.GetViewImage(vt, palette));

        imageComboBoxEdit1.Properties.Items.Add(new ImageComboBoxItem(vt, imageComboBoxEdit1.Properties.Items.Count));
    }
    imageComboBoxEdit1.EditValue = ViewType.Line;
}
private void imageComboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) {
    chartControl1.Series[0].ChangeView((ViewType)imageComboBoxEdit1.EditValue);
}
vb
Imports DevExpress.Utils.Svg
Imports DevExpress.XtraCharts
Imports DevExpress.XtraEditors.Controls
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim palette As SvgPalette = New SvgPalette()
    palette.Colors.Add(New SvgColor("Red", ColorTranslator.FromHtml("#D04D2F")))
    palette.Colors.Add(New SvgColor("Yellow", ColorTranslator.FromHtml("#EEB764")))
    palette.Colors.Add(New SvgColor("Blue", ColorTranslator.FromHtml("#377AB5")))
    palette.Colors.Add(New SvgColor("Green", ColorTranslator.FromHtml("#4DAE89")))
    palette.Colors.Add(New SvgColor("Black", ColorTranslator.FromHtml("#000000")))
    palette.Colors.Add(New SvgColor("White", ColorTranslator.FromHtml("#FFFFFF")))
    imageComboBoxEdit1.Properties.SmallImages = viewImages
    imageComboBoxEdit1.Properties.LargeImages = smallViewImages
    viewImages.ImageSize = New Size(16, 16)
    smallViewImages.ImageSize = New Size(32, 32)

    For Each vt As ViewType In [Enum].GetValues(GetType(ViewType))
        viewImages.AddImage(ChartImageUtils.GetViewImage(vt, palette))
        smallViewImages.AddImage(ChartImageUtils.GetViewImage(vt, palette))
        imageComboBoxEdit1.Properties.Items.Add(New ImageComboBoxItem(vt, imageComboBoxEdit1.Properties.Items.Count))
    Next

    imageComboBoxEdit1.EditValue = ViewType.Line
End Sub

Private Sub imageComboBoxEdit1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    chartControl1.Series(0).ChangeView(CType(imageComboBoxEdit1.EditValue, ViewType))
End Sub

Inheritance

Object ChartImageUtils

See Also

ChartImageUtils Members

DevExpress.XtraCharts Namespace