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

Custom Color problems

4 Answers 67 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 06 Dec 2010, 06:19 PM
I am having a couple issues with setting custom colors to a chart:
  1. The legend and datachart are not the same as the chart
  2. The second color is transparent which is not consistent with the other items
  3. how to remove a repeating color
below is what I have been doing. 
protected void rcNetworkBroadcastChange_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
{
    string net = ((DataRowView)e.DataItem)["Net"].ToString();
    e.SeriesItem.ActiveRegion.Tooltip = "Network: " + net + "\n" + ((DataRowView)e.DataItem)["Demo"].ToString() + ": " + ((DataRowView)e.DataItem)["Demo_Value"].ToString();
   if (NetworkColor.ContainsKey(net))
    {
        e.SeriesItem.Appearance.FillStyle.MainColor = (Color)NetworkColor[net];
        e.ChartSeries.Appearance.FillStyle.MainColor = (Color)NetworkColor[net];
      //  e.SeriesItem.Appearance.FillStyle.SecondColor = Color.Black;
    }
}

4 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 09 Dec 2010, 01:04 PM
Hi John,

1. " The legend and datachart are not the same as the chart " - I don't get the meaning of this. Could you be more specific - what is not shown as expected?
2. The colors you specify for the chart have FillType - Gradient which means that each element is filled by two colors. You should set them to Solid (Element is filled by one color.) like this:
radChart1.Series[0].Items[0].Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Solid;
3. To be able to show non-repeating colors you can follow this help topic - http://www.telerik.com/help/aspnet-ajax/howtoassigncolors.html

Best wishes,
Evgenia
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John Giblin
Top achievements
Rank 1
answered on 09 Dec 2010, 04:46 PM
thanks.  I figured an option for 2.  I set the color to:
e.SeriesItem.Appearance.FillStyle.SecondColor = ControlPaint.Dark(e.SeriesItem.Appearance.FillStyle.MainColor);

For #1, see the image.  The legend in the Datatable is not matching.

0
Evgenia
Telerik team
answered on 14 Dec 2010, 04:24 PM
Hello John,

Please, find below my answer, provided in the support ticket you have started:

------------------------
1. This is caused by setting LegendDisplayMode property to ChartSeriesLegendDisplayMode.ItemLabels. As I mentioned in my previous post this is used when you want to see each Bar's Legend Label in the Legend - note that each series has 3 items. If you don't want to see each Item's Label just comment this code line.
2. Item X is the default name of the Items when no LegendName is set for each of them
3. The following code colors the PlotArea, the Chart Legend and the DataTable's Markers in same color as expected:

Copy Code
protected void Page_Load(object sender, EventArgs e)
    {
        List<Product> products = new List<Product>();
        products.Add(new Product("Parka L", 120, 40));
        products.Add(new Product("Parka M", 100, 64));
        products.Add(new Product("Parka S", 132, 120));
        products.Add(new Product("Wool Cap", 45, 90));
        products.Add(new Product("Mittens", 67, 75));
        RadChart1.DataSource = products;
        RadChart1.Series[0].DataYColumn = "Value1";
        RadChart1.Series[1].DataYColumn = "Value2";
        RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name";
        RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font
         = new System.Drawing.Font("Arial", 8);
        RadChart1.DataBind();  
  
        RadChart1.PlotArea.DataTable.Visible = true;
        Color[] colors = new Color[] { Color.MediumPurple, Color.Yellow, Color.RoyalBlue, Color.LightGreen };
        for (int i = 0; i < RadChart1.Series.Count; i++)
        {
            RadChart1.Series[i].Appearance.FillStyle.FillType = FillType.Solid;
            RadChart1.Series[i].Appearance.FillStyle.MainColor = colors[i];
            RadChart1.Series[i].Appearance.Border.Color = colors[i];
        }
    }
  
    public class Product
    {
        public Product(string name, int value1, int value2)
        {
            _name = name;
            _value1 = value1;
            _value2 = value2;
        }
        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        private int _value1;
        public int Value1
        {
            get { return _value1; }
            set { _value1 = value; }
        }
        private int _value2;
        public int Value2
        {
            get { return _value2; }
            set { _value2 = value; }
        }
    }

You can find a sample picture attached showing the result of running the code snippet above.
Please modify the given code snippet so that it applies your scenario.

-----------------------

Please, choose one of the threads to continue the communication, so it is easier for both sides to keep track. Thank you.

Kind regards,
Evgenia
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
John Giblin
Top achievements
Rank 1
answered on 14 Dec 2010, 11:05 PM
this did work when I removed the custom palette.

When I used added a custom palette, it would only change the border.  I guess I was doing to many things.

Thanks for your help
Tags
Chart (Obsolete)
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
John Giblin
Top achievements
Rank 1
Share this question
or