弹性图表未沿 x 轴显示正确的值
我不知道有什么更好的方式来问这个问题。
如果运行下面的代码 (我知道 cData 部分在预览中不可见,某些原因导致它被忽略)。
结果不能正确表示数据。 1. Flex 忽略 DECKER 缺失的 8 月 24 日日期。 2. 它错误地将 42.77 与 8 月 23 日而不是 8 月 24 日关联起来。
有没有办法在柔性, 其中 x 轴是所有可用点的并集?
下面的代码完全来自: Adobe 网站链接
我只评论了 2 个数据点。 //{日期:“2005 年 8 月 23 日”,收盘价:45.74}, 和 //{日期:"24-Aug-05", 收盘价:150.71},
<?xml version="1.0"?>
[Bindable]
public var SMITH:ArrayCollection = new ArrayCollection([
{date:"22-Aug-05", close:41.87},
//{date:"23-Aug-05", close:45.74},
{date:"24-Aug-05", close:42.77},
{date:"25-Aug-05", close:48.06},
]);
[Bindable]
public var DECKER:ArrayCollection = new ArrayCollection([
{date:"22-Aug-05", close:157.59},
{date:"23-Aug-05", close:160.3},
//{date:"24-Aug-05", close:150.71},
{date:"25-Aug-05", close:156.88},
]);
[Bindable]
public var deckerColor:Number = 0x224488;
[Bindable]
public var smithColor:Number = 0x884422;
]]>
<mx:horizontalAxisRenderers>
<mx:AxisRenderer placement="bottom" axis="{h1}"/>
</mx:horizontalAxisRenderers>
<mx:verticalAxisRenderers>
<mx:AxisRenderer placement="left" axis="{v1}">
<mx:axisStroke>{h1Stroke}</mx:axisStroke>
</mx:AxisRenderer>
<mx:AxisRenderer placement="left" axis="{v2}">
<mx:axisStroke>{h2Stroke}</mx:axisStroke>
</mx:AxisRenderer>
</mx:verticalAxisRenderers>
<mx:series>
<mx:ColumnSeries id="cs1"
horizontalAxis="{h1}"
dataProvider="{SMITH}"
yField="close"
displayName="SMITH"
>
<mx:fill>
<mx:SolidColor color="{smithColor}"/>
</mx:fill>
<mx:verticalAxis>
<mx:LinearAxis id="v1" minimum="40" maximum="50"/>
</mx:verticalAxis>
</mx:ColumnSeries>
<mx:LineSeries id="cs2"
horizontalAxis="{h1}"
dataProvider="{DECKER}"
yField="close"
displayName="DECKER"
>
<mx:verticalAxis>
<mx:LinearAxis id="v2" minimum="150" maximum="170"/>
</mx:verticalAxis>
<mx:lineStroke>
<mx:Stroke
color="{deckerColor}"
weight="4"
alpha="1"
/>
</mx:lineStroke>
</mx:LineSeries>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}"/>
I don't know of any better way to ask this question.
If the below code is run
(i know the cData sections are not visible in the preview, something causes it to be ignored).
The result does not represent the data correctly.
1. Flex ignores missing date 24 aug for DECKER.
2. It wrongly associates 42.77 to 23-Aug instead of 24-AUG.
Is there a way in flex,
where the x-axis is a union of all available points ?
The below code is entirely from :
Adobe website link
I have only commented 2 data points.
//{date:"23-Aug-05", close:45.74},
and
//{date:"24-Aug-05", close:150.71},
<?xml version="1.0"?>
[Bindable]
public var SMITH:ArrayCollection = new ArrayCollection([
{date:"22-Aug-05", close:41.87},
//{date:"23-Aug-05", close:45.74},
{date:"24-Aug-05", close:42.77},
{date:"25-Aug-05", close:48.06},
]);
[Bindable]
public var DECKER:ArrayCollection = new ArrayCollection([
{date:"22-Aug-05", close:157.59},
{date:"23-Aug-05", close:160.3},
//{date:"24-Aug-05", close:150.71},
{date:"25-Aug-05", close:156.88},
]);
[Bindable]
public var deckerColor:Number = 0x224488;
[Bindable]
public var smithColor:Number = 0x884422;
]]>
<mx:horizontalAxisRenderers>
<mx:AxisRenderer placement="bottom" axis="{h1}"/>
</mx:horizontalAxisRenderers>
<mx:verticalAxisRenderers>
<mx:AxisRenderer placement="left" axis="{v1}">
<mx:axisStroke>{h1Stroke}</mx:axisStroke>
</mx:AxisRenderer>
<mx:AxisRenderer placement="left" axis="{v2}">
<mx:axisStroke>{h2Stroke}</mx:axisStroke>
</mx:AxisRenderer>
</mx:verticalAxisRenderers>
<mx:series>
<mx:ColumnSeries id="cs1"
horizontalAxis="{h1}"
dataProvider="{SMITH}"
yField="close"
displayName="SMITH"
>
<mx:fill>
<mx:SolidColor color="{smithColor}"/>
</mx:fill>
<mx:verticalAxis>
<mx:LinearAxis id="v1" minimum="40" maximum="50"/>
</mx:verticalAxis>
</mx:ColumnSeries>
<mx:LineSeries id="cs2"
horizontalAxis="{h1}"
dataProvider="{DECKER}"
yField="close"
displayName="DECKER"
>
<mx:verticalAxis>
<mx:LinearAxis id="v2" minimum="150" maximum="170"/>
</mx:verticalAxis>
<mx:lineStroke>
<mx:Stroke
color="{deckerColor}"
weight="4"
alpha="1"
/>
</mx:lineStroke>
</mx:LineSeries>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果切换到 /* */style 引号而不是 // 是否可以解决问题?我认为编译器认为您的数组集合都是一行(无论换行符如何),因此您可能无法在其中使用 // 样式引号。
If you switch to /* */style quotes instead of // does it fix the problem? I think the compiler thinks your array collection is all one line (regardless of line breaks) so you may not be able to use // style quotes in it.
经过大量搜索,
上述来源使用了 2 个不同的数据源和 2 个不同的系列。
每个数据源都与一个系列相关联。因此,数据源:系列之间存在 1:1 的关系。
然而,
公认的方法是使用一个数据源和两个系列。
数据源有一个与每个系列相关联的字段。所以,dataField:series 之间存在 1:1 的关系。
我使用第二种方法解决了这个问题,但这意味着我们必须手动构建具有正确值的单个数据源。
After much searching ,
The above source used 2 different datasources and 2 different series.
Each of datasource is associated with one series. So, there is a 1:1 between datasource : series.
However,
The accepted way to seams to be to use one data source and 2 series.
The datasource has one field associated with each of the series. So , there is a 1:1 between dataField : series.
I resolved the problem using the second approach, but that means we have to manually construct a single datasource with right values.