Flex 图表中堆叠系列中的错误
我认为 Flex 图表存在错误。
“日期时间轴在某些情况下不支持系列堆叠,而线性轴和类别在类似条件下运行良好”
当每个系列都有其单独的数据提供者时,“集群”和“堆叠”类型会发生这种情况。如果数据提供者被分配了图表本身,它就会工作得很好。
下面的代码在以下情况下工作正常 (1)'c.dataprovider=yearlydata; ' 未注释 (2)'series1.dataProvider=yearlyData2;'被评论。 (3)'series2.dataProvider=yearlyData2;'被注释了,
但是如果使用类别轴或线性轴,那么无论我们如何分配数据提供者,代码都可以正常工作。下面粘贴代码供您参考。
“这是 Flex 中的错误还是我遗漏了什么”?
我非常需要它,请帮忙。
提前致谢。
=================================================== ========
[Bindable]
private var yearlyData1:ArrayCollection = new ArrayCollection([
{month:"January", revenue:120, costs:45, id:1,
overhead:102, oneTime:23, date:new Date(2010,1,19,1,1,1)},
{month:"February", revenue:108, costs:42, id:2,
overhead:87, oneTime:47, date:new Date(2010,1,19,1,1,2)},
{month:"March", revenue:150, costs:82, id:3,
overhead:32, oneTime:21, date:new Date(2010,1,19,1,1,3)},
{month:"April", revenue:170, costs:44, id:4,
overhead:68, date:new Date(2010,1,19,1,1,4) }
]);
[Bindable]
private var yearlyData2:ArrayCollection = new ArrayCollection([
{month:"January", revenue:120, costs:45, id:1,
overhead:102, oneTime:23, date:new Date(2010,1,19,1,1,1)},
{month:"February", revenue:108, costs:42, id:2,
overhead:87, oneTime:47, date:new Date(2010,1,19,1,1,2)},
{month:"March", revenue:150, costs:82, id:3,
overhead:32, oneTime:21, date:new Date(2010,1,19,1,1,3)},
{month:"April", revenue:170, costs:44, id:4,
overhead:68, date:new Date(2010,1,19,1,1,4) }
]);
var c:ChartBase = new CartesianChart();
private function initApp():void {
// 当取消注释时,这将正常工作 // c.dataProvider = 年数据1;
var hAxis:DateTimeAxis = new DateTimeAxis();
CartesianChart(c).horizontalAxis = hAxis;
var vAxis:LinearAxis = new LinearAxis();
CartesianChart(c).verticalAxis = vAxis;
var mySeries:Array = new Array();
panel2.addChild(c);
var innerSet:ColumnSet = new ColumnSet();
innerSet.type = "stacked";
var series1:Series = new ColumnSeries();
// This will work fine when commented
series1.dataProvider = yearlyData1;
ColumnSeries(series1).xField = "date";
ColumnSeries(series1).yField = "costs";
ColumnSeries(series1).displayName = "Costs";
ColumnSeries(series1).horizontalAxis = hAxis;
ColumnSeries(series1).verticalAxis = vAxis;
var series2:Series = new ColumnSeries();
// This will work fine when commented
series2.dataProvider = yearlyData2;
ColumnSeries(series2).xField = "date";
ColumnSeries(series2).yField = "oneTime";
ColumnSeries(series2).displayName = "One-Time Costs";
ColumnSeries(series2).horizontalAxis = hAxis;
ColumnSeries(series2).verticalAxis = vAxis;
innerSet.horizontalAxis = hAxis;
innerSet.verticalAxis = vAxis;
innerSet.series.push(series1);
innerSet.series.push(series2);
c.series.push(innerSet);
var l:Legend = new Legend();
l.dataProvider = c;
panel2.addChild(l);
}
]]>
=================================================== ========
I think there is bug in Flex charting.
"DATETIME AXIS DOES NOT SUPPORT SERIES STACKING IN CERTAIN CASES WHILE LINEAR AXIS AND CATEGORY WORKS FINE IN SIMILAR CONDITIONS"
This happens for 'clustered' and 'stacked' types when each series has its individual data provider. If data provider is assigned with chart itself it will work fine.
Below code works fine when
(1)'c.dataprovider = yearlydata; ' is uncommented
(2)'series1.dataProvider = yearlyData2;' is commented.
(3)'series2.dataProvider = yearlyData2;' is commented
However if category axis or linear axis is used then the code works fine, no matter how do we assign the data providerThe code is pasted below for your reference.
"IS IT A BUG IN FLEX OR AM I MISSING SOMETHING" ??
I need it desperately, please help.
Thanks in advance.
==========================================================
[Bindable]
private var yearlyData1:ArrayCollection = new ArrayCollection([
{month:"January", revenue:120, costs:45, id:1,
overhead:102, oneTime:23, date:new Date(2010,1,19,1,1,1)},
{month:"February", revenue:108, costs:42, id:2,
overhead:87, oneTime:47, date:new Date(2010,1,19,1,1,2)},
{month:"March", revenue:150, costs:82, id:3,
overhead:32, oneTime:21, date:new Date(2010,1,19,1,1,3)},
{month:"April", revenue:170, costs:44, id:4,
overhead:68, date:new Date(2010,1,19,1,1,4) }
]);
[Bindable]
private var yearlyData2:ArrayCollection = new ArrayCollection([
{month:"January", revenue:120, costs:45, id:1,
overhead:102, oneTime:23, date:new Date(2010,1,19,1,1,1)},
{month:"February", revenue:108, costs:42, id:2,
overhead:87, oneTime:47, date:new Date(2010,1,19,1,1,2)},
{month:"March", revenue:150, costs:82, id:3,
overhead:32, oneTime:21, date:new Date(2010,1,19,1,1,3)},
{month:"April", revenue:170, costs:44, id:4,
overhead:68, date:new Date(2010,1,19,1,1,4) }
]);
var c:ChartBase = new CartesianChart();
private function initApp():void {
// This will work fine when uncommented
// c.dataProvider = yearlyData1;
var hAxis:DateTimeAxis = new DateTimeAxis();
CartesianChart(c).horizontalAxis = hAxis;
var vAxis:LinearAxis = new LinearAxis();
CartesianChart(c).verticalAxis = vAxis;
var mySeries:Array = new Array();
panel2.addChild(c);
var innerSet:ColumnSet = new ColumnSet();
innerSet.type = "stacked";
var series1:Series = new ColumnSeries();
// This will work fine when commented
series1.dataProvider = yearlyData1;
ColumnSeries(series1).xField = "date";
ColumnSeries(series1).yField = "costs";
ColumnSeries(series1).displayName = "Costs";
ColumnSeries(series1).horizontalAxis = hAxis;
ColumnSeries(series1).verticalAxis = vAxis;
var series2:Series = new ColumnSeries();
// This will work fine when commented
series2.dataProvider = yearlyData2;
ColumnSeries(series2).xField = "date";
ColumnSeries(series2).yField = "oneTime";
ColumnSeries(series2).displayName = "One-Time Costs";
ColumnSeries(series2).horizontalAxis = hAxis;
ColumnSeries(series2).verticalAxis = vAxis;
innerSet.horizontalAxis = hAxis;
innerSet.verticalAxis = vAxis;
innerSet.series.push(series1);
innerSet.series.push(series2);
c.series.push(innerSet);
var l:Legend = new Legend();
l.dataProvider = c;
panel2.addChild(l);
}
]]>
==========================================================
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论