SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.



I need to draw a three-dimensional surface with a special coloring according to the fourth dimension. I tried to do this using the texture. But I did not find examples of how to do it. This code only works if you specify the size of the texture 1024×1.

var texture = new Texture2D(1024, 1, TextureFormat.TEXTUREFORMAT_A8B8G8R8);
uint[] rgbaData = new uint[1024];
for (int i = 0; i < rgbaData.Length; i++)
    if (i > 512)
        rgbaData[i] = 0xFF8080FF;
    else rgbaData[i] = 0xFFFF8080;

meshSeries.ColorMapTexture = texture;
meshSeries.ColorMapTextureSize = new Size(1024, 1);

It is possible to set the color of the mesh as a function?

  • You must to post comments

Hi Yuriy

Have you seen our example: WPF 3D Chart Realtime 3D Surface Mesh Plot Example

This has an option to change the MeshColorPalette on the left.

One of the options allows you to apply a texture to the surface, you can see a screenshot below.

enter image description here.

The way this works is there is a BrushColorPalette applied to the SurfaceMeshRenderableSeries3D.ColorPalette property. This accepts type Brush so you can use a Visual Brush and place an image in there.

If you want finer grained control over the texture applied you can always inherit MeshColorPalette and provide your own implementation. For instance, the code for BrushColorPalette is like this:

public class BrushColorPalette : MeshColorPalette
    /// <summary>
    /// Defines the <see cref="Brush"/> DependencyProperty
    /// </summary>
    public static readonly DependencyProperty BrushProperty = DependencyProperty.Register(
        "Brush", typeof(Brush), typeof(BrushColorPalette), new PropertyMetadata(default(Brush), (s, e) => ((BrushColorPalette)s).OnColorPaletteChanged()));

    /// <summary>
    /// Initializes a new instance of the <see cref="BrushColorPalette"/> class.
    /// </summary>
    public BrushColorPalette()
        DefaultStyleKey = typeof(BrushColorPalette);

    /// <summary>
    /// Gets or sets the brush to create color-palette from. 
    /// </summary>        
    public Brush Brush
        get { return (Brush) GetValue(BrushProperty); }
        set { SetValue(BrushProperty, value); }

    /// <summary>
    /// Gets the <see cref="Texture2D" /> to apply to the <see cref="SurfaceMeshRenderableSeries3D" />, given the size passed in
    /// </summary>
    /// <param name="size">The size.</param>
    /// <returns>
    /// The <see cref="Texture2D" /> instance to map to the surface
    /// </returns>
    public override Texture2D GetTexture(Size size)
        if (Brush == null)
            return null;

        var b = Brush.Clone();
        if (b is LinearGradientBrush)
            ((LinearGradientBrush)b).StartPoint = new Point(0, 0);
            ((LinearGradientBrush)b).EndPoint = new Point(1, 0);
        Rectangle r = new Rectangle() { Width = size.Width, Height = size.Height, Fill = b };
        return Texture2D.FromWriteableBitmap(r.RenderToBitmap());

Take a look and let me know if this is what you need.

Best regards,

  • You must to post comments

Hi, Andrew!

Thanks for the detailed answer.

I was not able to appoint a palette of resources.
Code from example is working:

MeshColorPalette="{Binding ElementName=ColorMapCombo, Path=SelectedItem}" 

But my code does not work:

MeshColorPalette="{StaticResource SmileColorPalette}" 

For me, it is not critical, since I more suitable option with inheritance MeshColorPalette. I got to use a computed palette of arbitrary size.

SurfaceMesh.ColorMapTextureSize = new Size(lengthSize, timeSize);
SurfaceMesh.MeshColorPalette = new MyFuncColorPalette();

Best regards

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.