简体   繁体   English

折线图未连接点(Sencha-Charts程序包)

[英]Line Chart Not Connecting Dots (Sencha-Charts Package)

I'm having issues with an Cartesian chart component whereby it is failing to draw a line between two points. 我在使用笛卡尔图表组件时遇到问题,因此无法在两点之间画一条线。 I've narrowed the issue down to missing interval-data for a step in a particular series but haven't found a good solution. 我已将问题缩小为缺少特定系列中某个步骤的间隔数据,但没有找到一个好的解决方案。

In the following - simplified - example, you will see a break in the red line where data exists for a marker on the blue line at interval "three" - which sits between two red markers. 在下面的简化示例中,您将在红线中看到一个中断点,其中蓝线上的标记的数据间隔为“三”,该间隔位于两个红色标记之间。 I'm trying to find a way to draw straight from the red marker at interval "two" to the marker at interval "four" in a scenario where only partial data exists for 1 or more steps across several series. 我试图找到一种方法,在多个系列中只有部分或几个步骤的数据存在的情况下,可以从间隔“两个”的红色标记直接绘制到间隔“四个”的标记。

在此处输入图片说明

In my live application the data along the x-axis are actually dates so it is unreasonable to expect data at every interval for every series. 在我的实时应用程序中,沿x轴的数据实际上是日期,因此期望每个系列在每个间隔的数据都是不合理的。 I am also reluctant to fake points where no data exists as the markers have meaning and I'm doing other things with them on click-events. 我也不太愿意伪造那些没有数据的点,因为标记具有含义,并且我会在点击事件中对其进行其他处理。

Looking at the API my only line of investigation seem to be overloading the Series renderer function but as yet, I've not figured out what triggers the draw as the documentation is scarce at best. 看一下API,我唯一的研究思路似乎是过载Series renderer函数,但是到目前为止,由于文档稀缺,我还没有弄清楚触发绘制的原因。

I'd appreciate any pointers before I go picking apart the framework if someone's already gotten around this? 如果有人已经解决了这个问题,那么在我拆解框架之前,我将不胜感激。 Or - sanity check - have I missed some glaringly obvious configuration property? 或者-健全性检查-我错过了一些显而易见的配置属性吗?

» please fiddle »请摆弄

Ext.create('Ext.Container', {
    renderTo: Ext.getBody(),
    width: 600,
    height: 400,
    layout: 'fit',
    items: {
        xtype: 'cartesian',
        store: {
          fields: ['name', 'p1', 'p2'],
          data: [
              { name: 'one',   p1: 10, p2: 3  },
               { name: 'two',  p1: 7,  p2: 5  },
              { name: 'three', /*p1: 5,*/  p2: 10 },
              { name: 'four',  p1: 2,  p2: 8  },
              { name: 'five',  p1: 18, p2: 15 }
          ]
        },
        axes: [
            {
                type: 'numeric',
                position: 'left',
                fields: ['p1', 'p2'],
                minimum: 0
            }, 
            {
                type: 'category',
                position: 'bottom',
                fields: ['name']
            }
        ],
        series: [ 
            {
                type: 'line',
                style: {
                    lineWidth: 3
                },
                xField: 'name',
                yField: 'p1',
                marker: 'circle',
                colors: ['red']
            },
            {
                type: 'line',
                style: {
                    lineWidth: 3
                },
                xField: 'name',
                yField: 'p2',
                marker: 'circle',
                colors: ['blue']
            }
        ]
    }
});

The behavior you are after is, unfortunately, not configurable. 不幸的是,您所追求的行为是不可配置的。 However, there is always something that can be done about it . 但是, 总有一些事情可以解决 In this case you could implement a convert method for p1 field. 在这种情况下,您可以为p1字段实现一个convert方法。

The logic would find previous and next valid data and then would calculate an interpolation from them so that the chart would be satisfied. 逻辑将找到前一个和下一个有效数据,然后从中计算出一个插值,从而使图表得到满足。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM