[CLOSED] Transparency of colors in PieChart but not in legend

  1. #1

    [CLOSED] Transparency of colors in PieChart but not in legend

    Hi,

    I have put a transparency on colors used in a piechart.
    That is done through the style of the series.

     
    <Series>
       <ext:PieSeries
         AngleField="Data1"
         ShowInLegend="true"  
         Donut="20" 
         Highlight="true" 
         HighlightSegmentMargin="10"> 
         <Style Opacity="0.6" StrokeWidth="1" Stroke="#666"   />
       </ext:PieSeries>
    </Series>
    Transparency works good in the chart, but is not shown in the legend. I can not find any option for setting the transparency of the colors in the legend. Any idea?

    Hans
  2. #2
    Hello!

    I'm afraid that there is no such functionality but I think there were some reasons. However, you can try the following:

    Add config to LegendConfig
    <LegendConfig Position="Right">
    	<CustomConfig>
    		<ext:ConfigItem Name="opacity" Value="0.5" Mode="Raw" />
    	</CustomConfig>
    </LegendConfig>
    Override default legend rendering:

    <script>
    	Ext.override(Ext.chart.LegendItem, {
    		createLabel: function (config) {
    			var me = this,
    			legend = me.legend;
    			return me.add('label', me.surface.add({
    				type: 'text',
    				x: 20,
    				y: 0,
    				zIndex: (me.zIndex || 0) + 2,
    				fill: legend.labelColor,
    				font: legend.labelFont,
    				text: me.getLabelText(),
    				opacity: legend.opacity,
    				style: {
    					cursor: 'pointer'
    				}
    			}));
    		},
    
    		drawMarker: function (x, y, z, markerConfig) {
    			var me = this,
    				surface = me.surface,
    				series = me.series;
    			return me.add('marker', Ext.chart.Shape[markerConfig.type](surface, {
    				fill: markerConfig.fill,
    				x: x,
    				y: y,
    				zIndex: (z || 0) + 2,
    				opacity: this.legend.opacity,
    				radius: markerConfig.radius || markerConfig.size,
    				style: {
    					cursor: 'pointer'
    				}
    			}));
    		},
    		drawFilledBox: function (width, height, z, index) {
    			var me = this,
    				surface = me.surface,
    				series = me.series;
    			return me.add('box', surface.add({
    				type: 'rect',
    				zIndex: (z || 0) + 2,
    				opacity: this.legend.opacity,
    				x: 0,
    				y: 0,
    				width: width,
    				height: height,
    				fill: series.getLegendColor(index),
    				style: {
    					cursor: 'pointer'
    				}
    			}));
    		} 
    	});
    </script>
    Last edited by Baidaly; Feb 25, 2013 at 1:33 AM.
  3. #3
    Hi Baidaly,

    I tried it and it certainly works. Only minor change: also the text gets the transparency, but putting 'opacity:1' in CreateLabel in stead of 'opacity: legend.opacity' makes the text normal again.

    So thanks a lot.
    Hans

Similar Threads

  1. [CLOSED] PieChart rendering problem in IE10
    By HansWapenaar in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 24, 2013, 7:52 PM
  2. [CLOSED] Is it possible to change default calendar colors?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 12, 2011, 5:56 PM
  3. [CLOSED] Issue with Ext Icons Transparency in IE6
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 26, 2011, 11:15 AM
  4. [CLOSED] Alternating background colors of a listview row
    By mattwoberts in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 23, 2011, 2:35 PM
  5. Replies: 1
    Last Post: Jan 14, 2010, 12:42 PM

Posting Permissions