首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ext.chart.Chart不工作

Ext.chart.Chart不工作
EN

Stack Overflow用户
提问于 2014-04-09 13:16:16
回答 1查看 1.8K关注 0票数 1

当我用Ext.chart.CartesianChart替换为Ext.chart.Chart不起作用时,这里的代码,

CartesianChart图表

代码语言:javascript
复制
Ext.define("dashboard.view.HrsWorkedChart", {
       extend: "Ext.chart.CartesianChart",
       requires: [
                  "Ext.TitleBar",
                  "Ext.chart.CartesianChart",
                  "Ext.chart.series.Line",
                  "Ext.chart.axis.Numeric",
                  "Ext.chart.axis.Category",
                  "Ext.draw.sprite.Circle"
                  ],
       alias: "widget.hrsworkedchart",
       config: {
       flex: 1,
       xtype: "chart",
       store: "HrsAndValueByYear",
       cls: "chart",
       innerPadding: 20,
       animate: true,
       series: [
                {
                type: "line",
                xField: "year",
                yField: "hrsworked",
                title: "Hours Worked",
                style: {
                stroke: "#003366",
                lineWidth: 3
                },
                marker: {
                type: "circle",
                stroke: "#003366",
                radius: 5,
                lineWidth: 3
                },
                label: {
                field: "hrsworked",
                color: "#000",
                display: "over",
                font:"10px Helvetica"
                }
                },
                {
                type: "line",
                xField: "year",
                yField: "hrsbilled",
                title: "Hours Billed",
                style: {
                stroke: "#6d0060",
                lineWidth: 3
                },
                marker: {
                type: "circle",
                stroke: "#6d0060",
                radius: 5,
                lineWidth: 3
                },
                label: {
                field: "hrsbilled",
                color: "#000",
                display: "over",
                font: "10px Helvetica"
                }
                }
                ],
       axes: [
              {
              type: "numeric",
              position: "left",
              title: {
              fontSize: 15,
              text: "Hrs"
              },
              minimum: 130000,
              maximum: 180000,
              grid: {
              even: {
              fill: "#f9f9f9"
              }
              }
              },
              {
              type: "category",
              position: "bottom"
              }
              ]
       }
       });

Ext.Chart.Chart

代码语言:javascript
复制
Ext.define("dashboard.view.HrsWorkedChart", {
       extend: "Ext.chart.Chart",
       alias : "widget.hrsworkedchart",
       flex: 1,
       shadow: true,
       animate: true,
       store: "HrsAndValueByYear",
       axes: [{
              type: 'Numeric',
              position: 'left',
              fields: ['year'],
              minimum: 0,
              hidden: true
              }, {
              type: 'Category',
              position: 'bottom',
              fields: ['hrsworked'],
              label: {
              renderer: function(v) {
              return Ext.String.ellipsis(v, 15, false);
              },
              font: '9px Arial',
              rotate: {
              degrees: 270
              }
              }
              }],
       series: [{
                type: 'column',
                axis: 'left',
                highlight: true,
                style: {
                fill: '#456d9f'
                },
                highlightCfg: {
                fill: '#a2b5ca'
                },
                label: {
                contrast: true,
                display: 'insideEnd',
                field: 'year',
                color: '#000',
                orientation: 'vertical',
                'text-anchor': 'middle'
                },
                xField: 'name',
                yField: ['price']
                }]        
       });

我的code.Please有什么问题帮我解决

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-09 15:52:50

几个指针

  1. 在轴配置中,有效类型为“数值”、“类别”。你把它作为大写字母N和C。
  2. 类别轴应该是年份,数字轴应该是人名。
  3. 我不知道是否有“列”系列。用"bar“代替。

您可以在这里看到示例https://fiddle.sencha.com/#fiddle/51f和下面的代码片段。

代码语言:javascript
复制
var store1 = Ext.create('Ext.data.Store', {
    fields: ['year', 'hrsworked'],
    data: [{
       year: 2010,
       hrsworked: 130000
    }, {
       year: 2011,
       hrsworked: 140000
    }, {
       year: 2012,
       hrsworked: 150000
    }]
});

Ext.define("dashboard.view.HrsWorkedChart", {
          extend: "Ext.chart.Chart",
          requires: ["Ext.TitleBar", "Ext.chart.CartesianChart", "Ext.chart.series.Bar", "Ext.chart.series.Line", "Ext.chart.axis.Numeric", "Ext.chart.axis.Category", "Ext.draw.sprite.Circle"],
          alias: "widget.hrsworkedchart",
          config: {
             flex: 1,
             shadow: true,
             animate: true,
             store: store1,
             cls: "chart",
             innerPadding: 20,
             animate: true,
             series: [{
                type: 'bar',
                xField: 'year',
                yField: ['hrsworked'],
                style: {
                  fill: 'blue'
                }
             }],
            axes: [{
                type: "numeric",
                position: "left",
                minimum:0,
                title: {
                  fontSize: 15,
                  text: "Hrs"
                },
                grid: {
                  even: {
                    fill: "#f9f9f9"
                  }
               },
               field: ['hrsworked']
            }, {
               type: "category",
               position: "bottom",
               label: {
        font: '9px Arial',
                    rotate: {
                      degrees: 270
                     }
           },
               field: 'year'
           }]
        }
 });
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22963725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档