Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex Flex中包含事件的简单时间线图_Apache Flex_Charts_Timeline - Fatal编程技术网

Apache flex Flex中包含事件的简单时间线图

Apache flex Flex中包含事件的简单时间线图,apache-flex,charts,timeline,Apache Flex,Charts,Timeline,我正在寻找一个简单的时间线图,我可以在不同的时间跨度上显示几个事件。我还没有在Flex中找到任何特定的图表,有人创建或使用过类似的图表吗?我找到了这个,但这只是我寻找的部分内容。我使用mx:PlotChart创建了一个时间线。看起来是这样的: 我使用了一个底部有DateTimeAxis,侧面有LinearAxis的绘图图。我将其放入一个小型Flex应用程序: <mx:Script> <![CDATA[ import mx.charts.chartCla

我正在寻找一个简单的时间线图,我可以在不同的时间跨度上显示几个事件。我还没有在Flex中找到任何特定的图表,有人创建或使用过类似的图表吗?我找到了这个,但这只是我寻找的部分内容。

我使用mx:PlotChart创建了一个时间线。看起来是这样的:

我使用了一个底部有DateTimeAxis,侧面有LinearAxis的绘图图。我将其放入一个小型Flex应用程序:

<mx:Script>
    <![CDATA[
        import mx.charts.chartClasses.IAxis;
        import mx.charts.HitData;
        import mx.collections.ArrayCollection;

        [Bindable]
        public var max:Date;

        [Bindable]
        public var min:Date;

        [Bindable]
        private var notifAC:ArrayCollection;

        public function init():void
        {
            var notif1:Date = new Date(2009, 9, 8, 11, 30, 0, 0);
            var notif2:Date = new Date(2009, 9, 8, 12, 40, 0, 0);
            var notif3:Date = new Date(2009, 9, 8, 13, 45, 0, 0);

            notifAC = new ArrayCollection( [
                { Date: notif1, Name: "Notif 1", Value: 1 },
                { Date: notif2, Name: "Notif 2", Value: 1 },
                { Date: notif3, Name: "Notif 3", Value: 1 } ]);

            //set min and max to outside most notifs
            min = new Date(notif1.getTime());
            max = new Date(notif3.getTime());

            //calculate the range between min and max
            var timelineRange:Number = max.getTime() - min.getTime();

            //if less than 2 hours switch to minutes
            if(timelineRange < 7200000)
            {
                timelineDateAxis.dataUnits = "minutes";
            }
            //if greater than 2 days switch to days
            else if(timelineRange > 172800000)
            {
                timelineDateAxis.dataUnits = "days";
            }

            //as long as the timeline has a range other than 0, add 10% to the min and max
            if(timelineRange != 0)
            {
                min = new Date(min.getTime() - (timelineRange * .1));
                max = new Date(max.getTime() + (timelineRange * .1));
            }
            //if the timeline does have a range of 0, add 1 minute to min and max
            else
            {
                min = new Date(min.getTime() - 60000);
                max = new Date(max.getTime() + 60000);
            }
            //set the min and max of the axis
            timelineDateAxis.minimum = min;
            timelineDateAxis.maximum = max;
        }

        public function timelineDataTips(e:HitData):String
        {
            return "<b>" + e.item.Name + "</b>\n" + dataTipsFormatter.format(e.item.Date);
        }
    ]]>
</mx:Script>

<mx:Style>
    .issueTimelineHolder
    {
        background-color:#787878;
    }
    .issueTimelineChart
    {
        padding-top:5px;
        padding-right:0;
        padding-bottom:0;
        padding-left:0;    
    }
    .timelineDateAxis
    {
        color:#ffffff;
    }

</mx:Style>

<mx:Stroke id="timelineDateAxisStroke" 
    color="#9B9B9B"
    weight="8" 
    alpha=".75"
    caps="none"
/>
<mx:Stroke id="timelineTickStroke"
    color="#ffffff"
/>

<mx:DateFormatter id="dataTipsFormatter" formatString="HH:NN:SS MM/DD/YYYY" />

 <mx:Canvas styleName="issueTimelineHolder" width="350" height="120">
     <mx:PlotChart id="issueTimelineChart" styleName="issueTimelineChart" width="100%" height="100%" 
        showDataTips="true" dataTipFunction="timelineDataTips" dataProvider="{notifAC}">
        <mx:backgroundElements>
            <mx:GridLines direction="horizontal" />
        </mx:backgroundElements>

        <mx:verticalAxis>
            <mx:LinearAxis id="timelineValueAxis" minimum="0" maximum="2" interval="1" />
        </mx:verticalAxis>
        <mx:verticalAxisRenderers>
            <mx:AxisRenderer axis="{timelineValueAxis}" showLabels="false" showLine="false"
                tickPlacement="none" minorTickPlacement="none" />
        </mx:verticalAxisRenderers>

        <mx:horizontalAxis>
            <mx:DateTimeAxis id="timelineDateAxis" dataUnits="hours"
                minimum="{min}" maximum="{max}" displayLocalTime="true"/>
        </mx:horizontalAxis>
        <mx:horizontalAxisRenderers>
            <mx:AxisRenderer axis="{timelineDateAxis}" styleName="timelineDateAxis" tickPlacement="outside">
                <mx:axisStroke>{timelineDateAxisStroke}</mx:axisStroke>
                <mx:tickStroke>{timelineTickStroke}</mx:tickStroke>
            </mx:AxisRenderer>
        </mx:horizontalAxisRenderers>

        <mx:series>
            <mx:PlotSeries xField="Date" yField="Value" />
        </mx:series>
    </mx:PlotChart>
</mx:Canvas>

172800000)
{
timelineDateAxis.dataUnits=“天”;
}
//只要时间线的范围不是0,则在最小值和最大值上添加10%
如果(timelineRange!=0)
{
min=新日期(min.getTime()-(timelineRange*.1));
max=新日期(max.getTime()+(timelineRange*.1));
}
//如果时间线的范围为0,则将1分钟添加到最小值和最大值
其他的
{
min=新日期(min.getTime()-60000);
max=新日期(max.getTime()+60000);
}
//设置轴的最小值和最大值
timelineDateAxis.minimum=min;
timelineDateAxis.max=最大值;
}
公共函数timelineDataTips(e:HitData):字符串
{
返回“+e.item.Name+”\n“+dataTipsFormatter.format(e.item.Date);
}
]]>
.发行人
{
背景色:#7878;
}
.issueTimelineChart
{
垫面:5px;
右边填充:0;
填充底部:0;
左侧填充:0;
}
.时间轴
{
颜色:#ffffff;
}
{timelineDateAxisStroke}
{timelineTickStroke}