ExtJS 4图表:线不关心点

发布于 2024-12-29 05:15:26 字数 2528 浏览 2 评论 0原文

我想在我的新 ExtJS4 应用程序中使用图表。
轴渲染得很好,我也得到了一条线;但这没有任何意义。这是我的问题的屏幕截图: Line does not care aboutpoints...

所以正如你所看到的,我得到了很好的轴和左边的数据应绘制图表;但显然,它并没有真正达到我的预期;-)

我尝试对数据进行硬编码,所以这是我的商店

Ext.define('MR.store.ResultChartStore', {
 extend: 'Ext.data.Store',
 model: 'MR.model.ResultPoint',
 data: [
   {rings: 400, date: new Date(1970, 1, 1)},
   {rings: 398, date: new Date(1970, 1, 2)},
   {rings: 275, date: new Date(1970, 1, 3)}
 ]
});

引用的模型看起来像这样:

Ext.define('MR.model.ResultPoint', {
 extend: 'Ext.data.Model',
 fields: ['rings', 'date']
});

最后我的图表看起来像这样:

{
  xtype: 'chart',
  width: 600,
  height: 300,
  theme: 'Green',
  store: 'ResultChartStore',
  axes: [
    {
      title: 'Ringe',
      type: 'Numeric',
      position: 'left',
      fields: ['rings'],
      minimum: 0,
      maximum: 400
    },
    {
      title: 'Datum',
      type: 'Time',
      position: 'bottom',
      fields: ['date'],
      dateFormat: 'd.m.Y'
    }
  ],
  series: [
    {
      type: 'line',
      xField: 'date',
      yField: 'rings'
    }
  ]
}

有人能发现我的错误吗?我似乎找不到它,在我看来,它看起来就像文档中的示例一样......

谢谢,提前感谢
吉拉拉斯

--------------------------------------更新-------- -------------------------------------------

我想我知道问题出在哪里,但我不知道如何解决:-/
当我向商店添加更多数据时,图表如下所示: 我的新图表

所以问题似乎是 Ext 不“知道”如何连接我的点...
在我看来,它找到一个点,通过它画一条线,并对我商店中指定的每个点重复它。

我的图表现在看起来像这样:

{
  xtype: 'chart',
  width: 600,
  height: 300,
  theme: 'Base',
  store: 'ResultChartStore',
  axes: [
    {
      title: 'Ringe',
      type: 'Numeric',
      position: 'left',
      fields: ['rings'],
      minimum: 0,
      maximum: 400,
      minorTickSteps: 1,
      grid: {
        odd: {
          opacity: 1,
          fill: '#ddd',
          stroke: '#bbb',
          'stroke-width': 0.5
        }
      }
    },
    {
      title: 'Datum',
      type: 'Time',
      position: 'bottom',
      fields: ['date'],
      dateFormat: 'd'
    }
  ],
  series: [
    {
      type: 'line',
      xField: 'date',
      yField: 'rings',
      highlight: {
        size: 7,
        radius: 7
      },
      markerConfig: {
        type: 'cross',
        size: 4,
        radius: 4,
        'stroke-width': 0
      }
    }
  ]
}

有人知道我可能做错了什么吗?

I wanna use a chart in my new ExtJS4 application.
The axes render just fine, and I get a line, too; but it does not make any sense. Here's a screenshot of my problem:
Line does not care about points...

So as you can see, I got the axes just fine and the data left of the chart should be drawn; but obviously, it doesn't really do what I expected ;-)

I tried to hardcode the data, so here's my store:

Ext.define('MR.store.ResultChartStore', {
 extend: 'Ext.data.Store',
 model: 'MR.model.ResultPoint',
 data: [
   {rings: 400, date: new Date(1970, 1, 1)},
   {rings: 398, date: new Date(1970, 1, 2)},
   {rings: 275, date: new Date(1970, 1, 3)}
 ]
});

The referenced model looks like this:

Ext.define('MR.model.ResultPoint', {
 extend: 'Ext.data.Model',
 fields: ['rings', 'date']
});

And finally my chart looks like this:

{
  xtype: 'chart',
  width: 600,
  height: 300,
  theme: 'Green',
  store: 'ResultChartStore',
  axes: [
    {
      title: 'Ringe',
      type: 'Numeric',
      position: 'left',
      fields: ['rings'],
      minimum: 0,
      maximum: 400
    },
    {
      title: 'Datum',
      type: 'Time',
      position: 'bottom',
      fields: ['date'],
      dateFormat: 'd.m.Y'
    }
  ],
  series: [
    {
      type: 'line',
      xField: 'date',
      yField: 'rings'
    }
  ]
}

Can anybody spot my mistake? I just can't seem to find it, in my eyes it looks just like the examples in the docs ...

Greetz and thanks in advance
gilaras

-------------------------------------UPDATE---------------------------------------

I guess I know where the problem is, but I don't know how to solve it :-/
When I add more data to the store, the chart looks like this:
My new chart

So the problem seems to be that Ext does not "know" how to connect my points...
In my opinion it finds a point, draws a line through it and repeats it for every point specified in my store.

My chart looks like this now:

{
  xtype: 'chart',
  width: 600,
  height: 300,
  theme: 'Base',
  store: 'ResultChartStore',
  axes: [
    {
      title: 'Ringe',
      type: 'Numeric',
      position: 'left',
      fields: ['rings'],
      minimum: 0,
      maximum: 400,
      minorTickSteps: 1,
      grid: {
        odd: {
          opacity: 1,
          fill: '#ddd',
          stroke: '#bbb',
          'stroke-width': 0.5
        }
      }
    },
    {
      title: 'Datum',
      type: 'Time',
      position: 'bottom',
      fields: ['date'],
      dateFormat: 'd'
    }
  ],
  series: [
    {
      type: 'line',
      xField: 'date',
      yField: 'rings',
      highlight: {
        size: 7,
        radius: 7
      },
      markerConfig: {
        type: 'cross',
        size: 4,
        radius: 4,
        'stroke-width': 0
      }
    }
  ]
}

Anyone got an idea what I may be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽你眉间 2025-01-05 05:15:26

首先,您缺少系列中的一个重要配置。 axis 配置将商店中的点绑定到图表上的轴。然而,Sencha 文档中有关此配置的内容具有误导性; Sencha 说配置需要一个字符串,而实际上它需要一个字符串或一个字符串数组。在您的情况下,请使用axis: ['left', 'bottom']

其次(我对此不太确定),您可以尝试在图表配置中使用完全限定的商店名称。因此,'MR.store.ResultChartStore' 而不仅仅是'ResultChartStore'。尽管您似乎得到了很好的分数,但如果出现某种副作用,我不会感到惊讶。

第三,时间轴可能有点问题。如果您遇到问题,请尝试将其设置为“类别”并将日期转换为字符串。上面提到的问题确实指出类别轴也有问题,但我个人没有遇到任何问题。

First, you're missing an important configuration in your series. The axis config binds the points in your store to the axes on the chart. The Sencha documentation on this config is misleading, however; Sencha says the config takes a string when in fact it takes either a string or an array of strings. In your case, use axis: ['left', 'bottom'].

Second (and I'm less sure about this), you might try using the fully qualified store name in your chart config. So, 'MR.store.ResultChartStore' instead of just 'ResultChartStore'. Although you appear to be getting the points just fine, I wouldn't be surprised if there was some sort of side-effect.

Third, the Time axis can be a bit buggy. If you're having trouble with it, try setting it to Category and converting the date to a string. The referenced question above does state that Category axes are bugged too, but I've personally not experienced any problems with them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文