2

Please find the below code

    <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
 <![CDATA[
  [Bindable]
        public var testAC:Array = [
           {date:"without", close:50},
           {date:"with", close:45}           
        ];

 ]]>
</mx:Script>
 <mx:ColumnChart id="myChart" dataProvider="{testAC}">
  <mx:horizontalAxis>
   <mx:CategoryAxis categoryField="date"/>
  </mx:horizontalAxis>
  <mx:verticalAxis>
   <mx:CategoryAxis categoryField="close"/>
  </mx:verticalAxis>
  <mx:series>
   <mx:ColumnSeries dataProvider="{testAC}" xField="date" yField="close"/>
   <mx:LineSeries dataProvider="{testAC}" xField="date" yField="close"/>
  </mx:series>
 </mx:ColumnChart>
</mx:Application>

This code is drawing a colum chart with two columns and drawing a line across the top of both columns. I have two requirements :

  1. the line need to be dashed
  2. as of now the line starts from top right corner of the first column to the same corner of the second column. How can i shift the line to the left, so that it starts from center of first column to center of second column.

Regards, PK

4

3 回答 3

2

您可以在笛卡尔图表上的两个值之间画一条线

<mx:Script><![CDATA[
    private function connectTwoPoints(
        month1:String, value1:Number, 
        month2:String, value2:Number):void 
    {
        // Draw Line
        canvas.clear();
        canvas.lineStyle(4, 
            0xCCCCCC, 
            .75, 
            true, 
            LineScaleMode.NORMAL, 
            CapsStyle.ROUND, 
            JointStyle.MITER, 
            2);
        canvas.moveTo(month1, value1);
        canvas.lineTo(month2, value2);
    }
]]></mx:Script>

<mx:annotationElements>
    <mx:CartesianDataCanvas id="canvas" includeInRanges="true"/>
</mx:annotationElements>

您绘制的线将是使用“笛卡尔数据画布”的“注释元素”。注释元素被绘制在前景中。完美示例: http://livedocs.adobe.com/flex/3/html/help.html?content=
charts_eventsandeffects_13.html

于 2010-05-19T18:33:20.650 回答
1

对于我的许多具有复杂蒙皮的图表,我一直在使用 Axiis。它非常类似于 Degrafa,可以让您进行 degrafa 笔划并将其放在您的“dataCanvas”上您想要的任何位置。

这是一个非常直接的示例:http: //axiis.org/examples/HClusterStackExample.html

'这不是最好的答案,但使用 axiis 是如此简单,但它允许通过带有plain-ol' flex 图表的 mxml 不允许的复杂填充和描边。

祝你好运,杰里米

于 2010-03-15T16:01:22.780 回答
1

经过长时间的研究,我终于完成了虚线图的绘制。我使用 Adob​​e 自己提供的 DashedGraphicUtilities 来绘制虚线。我扩展了 LineSeries 并使用这个 DashedGraphicUtilities 来绘制虚线。这解决了我的第一个和邮件问题。每当我得到第二个解决方案时,我都会更新它。

我也得到了第二个问题的解决方案。当我将图表类型从 ColumnChart 更改为 CartesianChart 时,折线图可以根据需要完美显示。我在其中使用了列系列和线系列,并且线和列完美呈现。

问候, 阿努普

于 2010-03-25T15:54:19.420 回答