2011-09-02 74 views
1

我有以下代码来构建一个饼图。
问题是我没有得到阴影。
注:如果图表配置,主题=“基地”,则派有阴影Extjs图表阴影

Ext.define('ChartPanel', { 
    extend: 'Ext.panel.Panel', 
    //------------------CONSTRUCTOR 
    , constructor: function(externalConfigs) { 
     externalConfigs = externalConfigs || {}; 

     var configs = { 
      title: 'My panel', 
      items: [ 
      { 
       xtype: 'chart', 
       store: myStore, 
       width: '30%', 
       series: [{ 
        type: 'pie' 
         , field: 'persentage' 
         , shadow: 'sides' 
         , showInLegend: false 
         , donut: false 
         , renderer: function(sprite, record, attributes, index, store) { 
          if (record.data.description == 'option1') { 
           sprite.setAttributes({ 
            fill: 'url(#redGradient)', 
            stroke: '#ffffff' 
           }, false); 
          } else if (record.data.description == 'option2') { 
           sprite.setAttributes({ 
            fill: 'url(#greenGradient)', 
            stroke: '#ffffff' 
           }, false); 
          } 
         } 
        }] 
        , gradients: [{ 
         id: 'redGradient', 
         angle: 45, 
         stops: { 
          0: { color: '#820000' }, 
          100: { color: '#BD1E00' } 
         }       
        }, { 
         id: 'greenGradient', 
         angle: 0, 
         stops: { 
          0: { color: '#89AC10' }, 
          100: { color: '#A1C22D' } 
         } 
        }] 
       } 
      ] 
      } 

      Ext.apply(configs, externalConfigs); 
      this.callParent([configs]); //Call the parent constructor 
     } 


    });  

任何想法如何得到一个影子? 谢谢

回答

2

使用shadow: true(请参阅上一个链接中的文档以查看其他可能的选项)在您的chart定义。 (不在pie定义内)。 Ext.chart.series.Pie没有shadow配置属性。您需要在Ext.chart.series.Pie内使用shadowAttributes

+0

感谢您的回答。阴影:如果系列渲染器将属性设置为即使是一个精灵,也不会做任何事情。但让我问你。在哪里可以找到shadowAttributes选项? –

+0

这是一个非常好的问题。我可以建议的最好的方法是查看Ext.chart.series.Pie的源代码,并且您会注意到它们使用以下选项:“stroke-width”:6, “stroke-opacity”:1,stroke: 'rgb(200,200,200)', translate:{ x:1.2, y:2 } – LittleTreeX

1

我发现

return attributes; 

渲染器里面是必不可少的。