This is a migrated thread and some comments may be shown as answers.

Colors of pie

6 Answers 732 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Anastasiya
Top achievements
Rank 1
Anastasiya asked on 03 Jul 2018, 02:08 PM

Hi!

How to change colors in the chart? For some reason in my chart only 6 different colors(but 8 sectors, that is, two colors are repeated).

How to fix it? How to change colors in the chart?

Thank you!

6 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 04 Jul 2018, 01:41 PM
Hi Anastasiya,

The Graph item comes with built-in palettes, and you can define additional custom palette. These palette colors also appear in the legend. When multiple series are added to the chart, the chart assigns the series a color in the order that the colors have been defined in the palette.

If there are a greater number of series than there are colors in the palette, the chart will begin reusing colors, and two series may have the same color. To avoid confusion, define a custom palette with at least the same number of colors as you have series on your chart.

For more information on how to define a custom color palette, please refer to Formatting Series Colors.

Regards,
Nasko
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Vas
Top achievements
Rank 1
Veteran
answered on 14 Apr 2020, 07:14 AM

Hi,

May I please know if we can assign custom colour to each series in Pie-Chart. Sometimes if there are 4 series expected such as Satisfied/Extremely satisfied/Dissatisfied/Extremely dissatisfied but the records returned are only 2 rows one for each series, then if I use colour pallete the first series gets mapped to the first colour in colour pallete. 

 

Instead is there a way where we can assign a colour from the database itself?

 

Thanks

Vas

0
Todor
Telerik team
answered on 16 Apr 2020, 12:56 PM

Hello Vas,

You may use Conditional Formatting. The property you need is 'DataPointConditionalFormatting' for the corresponding Series - check the attached screenshot 'SeriesDataPointConditionalFormatting.png'. The color, in this case, is independent of the Color Palette.

For manipulating the label, e.g. to assign it a custom color conditionally, you may use ''DataPointLabelConditionalFormatting' property of the series.

The conditional formatting does not allow to set the color with Expression. It is necessary to select it from the hard-coded colors. You may want to vote for the Ability to dynamically specify the graph series color via binding feature request.

 

Alternatively, you may set the ColorPalette with Bindings:

Property Path	|	Expression
ColorPalette	|	= MyUserFunctionName(MyColor1, MyColor2, ...)

The User Function should return the proper palette based on its arguments -  type Telerik.Reporting.Drawing.IColorPalette. Here is a sample function that returns palette based on a list of Hex colors:

public static IColorPalette UserColorPalette(params string[] hexColors)
{
    string[] colors = hexColors;

    if (null == colors || colors.Length <= 0)
    {
        return null;
    }

    if (colors.Length == 1)
    {
        colors = colors[0]
            .Split('#')
            .Where(c => !string.IsNullOrWhiteSpace(c))
            .Select(c => $"#{c.Trim()}")
            .ToArray();
    }

    ColorPalette colorPalette = new ColorPalette(colors);

    return colorPalette;
}

The list of color arguments may be easily substituted with other values, for example, fields from the database.

Regards,
Todor
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Erik
Top achievements
Rank 1
Veteran
answered on 01 Jun 2020, 09:36 AM

Sorry if this is only loosely related to the previous questions...

In several of my reports, I have the same data in both a table and a pie chart, side by side.

Is there any way that the colors of the pie chart palette (standard or custom, nvm) can be used to color a shape in the table, so that the legend becomes redundant?

A bit left-field, I admit, but any help appreciated. :-)

Erik

0
Ramesh
Top achievements
Rank 1
Veteran
Iron
answered on 26 Aug 2020, 11:38 AM

Hello Todor, 

I have the exact requirement similar to Vas. I would like to bind the color from the database.

As you suggest as an alternate way of ColorPalette Bindings, can you please help me with a working example ? because  i do not know where to write the User Function  (c# code or js code). I could not able to bind ColorPalette property as well 

Thanks for your support

Ramesh R

1
Todor
Telerik team
answered on 31 Aug 2020, 08:13 AM

Hi Ramesh,

The User Function should be in a C# or VB ClassLibrary project. Then you need to copy the assembly with the function in the Standalone Designer folder or reference it in the project that hosts the Reporting engine. You also have to register the assembly in the configuration file of the designer, or the project with the Reporting engine.

Check also the following resources:

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Report Designer (standalone)
Asked by
Anastasiya
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Vas
Top achievements
Rank 1
Veteran
Todor
Telerik team
Erik
Top achievements
Rank 1
Veteran
Ramesh
Top achievements
Rank 1
Veteran
Iron
Share this question
or