Skip to main content
RSS feed Subscribe to feed


How to Create a Table Value Renderer

This tutorial describes how to create a simple renderer turning data values into images. The source code is available in the SDK, and includes a dialog for the renderer settings.


This tutorial outlines the key steps when creating the simple table value renderer available in the SDK. It renders colors cells as high (red), medium (yellow) or low (green) based on the data values. If the data value is not one of the priority values, the renderer colors the cell white.

The following illustration shows a table with two identical columns. The table value renderer is applied to the second column using the settings displayed in settings dialog of the renderer:

The custom value renderer of the Spotfire SDK in action
Background Information
  • Creating a Table Value Renderer
    Table value renderers render values in table visualization columns. The most common scenario is to turn data values into images, which are rendered in the table cells.
  • Spotfire SDK\Examples\Extensions\SpotfireDeveloper.CustomValueRendererExample

Overriding RenderCore

The table value renderer implements the rendering of data values by overriding the RenderCore method of the custom value renderer class:

protected override void RenderCore(
    ValueRendererSettings rendererSettings,
    ValueRendererArgs renderingArgs,
    ValueRendererResult result)
    CustomValueRendererExampleSettings exampleSettings = rendererSettings as CustomValueRendererExampleSettings;
    string value = renderingArgs.DataValue.Value == null ? "" : renderingArgs.DataValue.Value.ToString();

    Color color = Color.White;

    if (value.Contains(exampleSettings.HighPriorityString))
        color = Color.Red;
    if (value.Contains(exampleSettings.MediumPriorityString))
        color = Color.Yellow;
    if (value.Contains(exampleSettings.LowPriorityString))
        color = Color.Green;

    Bitmap bitmap = new Bitmap(renderingArgs.Width, renderingArgs.Height);
    using (Graphics g = Graphics.FromImage(bitmap))
        g.FillRectangle(new SolidBrush(color), 0, 0, bitmap.Width, bitmap.Height);


Overriding GetRendererMatchCore

When implementing the factory class for the renderer, override the GetRendererMatchCoremethod, to indicate how well the renderers produced by the factory render the particular content type.

protected override float GetRendererMatchCore(DataValueProperties dataValueProperties)
    // The renderer supports strings, but it is not a perfect match
    // for any particular content type. The built-in default renderer
    // returns 50.0 regardless of content type or data type.

    // If we want to make a factory which is better suited than the built-in
    // default renderer, we return a higher value than 50.0. A better suited
    // factory means that it will have precedence during autoconfiguration.

    // In this case, we do not want the CustomValueRenderer to be automatically
    // configured in favor of the built-in default renderer, so we return
    // a lower value than 50.0.

    if (dataValueProperties.DataType == DataType.String)
        return 25.0f;

    return 0.0f;