Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 892375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:02:40+00:00 2026-05-15T14:02:40+00:00

I have a problem zooming in on a line chart with a dateTimeAxis as

  • 0

I have a problem zooming in on a line chart with a dateTimeAxis as horizontal axis. I want to zoom in and out, by setting the minimum and the maximum attribute of the dateTimeAxis with a slider. The date labels change as should, but the lines disappear as I set the minimum or the maximum.

Here’s a part of the code I have:

private function updateBoundariesFromSlider():void
        {
            leftBoundary = slider.values[0];
            rightBoundary = slider.values[1];
            updateMainData();
        }

        private function updateMainData():void
        {

            dateAxis.minimum = new Date(leftBoundary);
            dateAxis.maximum = new Date(rightBoundary);

        }


public function setChartData( data:XML, shown:Array, minDate:Date, maxDate:Date ):void
        {
            globalLeftBoundary = minDate.getTime();
            globalRightBoundary = maxDate.getTime();
            leftBoundary = minDate.getTime();
            rightBoundary = maxDate.getTime();

            for each( var s:String in shown )
            {
                var localXML:XMLList = data.track.(type == s);

                // Create the new series and set its properties.
                var localSeries:LineSeries = new LineSeries();
                localSeries.dataProvider = localXML;
                localSeries.yField = "value";
                localSeries.xField = "time";

                localSeries.displayName = s;

                mySeries.push(localSeries);


            }


            hAxis = new DateTimeAxis();

            hAxis.dataUnits = "minutes";
            hAxis.dataInterval = 1;
            hAxis.labelFunction = showLabel;
            hAxis.alignLabelsToUnits = true;
            hAxis.parseFunction = createDate;
            //hAxis.minimum = new Date( leftBoundary );
            //hAxis.maximum = new Date( rightBoundary );
            Alert.show( (new Date( leftBoundary )).toString());

            dateAxis = hAxis;
        }

        private function createDate(s:String):Date {

            var dateTime:Array = s.split(" ");

            var date:Array = dateTime[0].split("-");
            var time:Array = dateTime[1].split(":");

            var newDate:Date = new Date(date[0],date[1],date[2],time[0],time[1],time[2]);
            return newDate;
        }


<mx:LineChart id="lineChart" left="10" top="10" bottom="47" right="10" series="{mySeries}" horizontalAxis="{dateAxis}" />

<mx:Legend dataProvider="{lineChart}" height="23" bottom="16" left="10" id="legend" width="100"/>
<flexlib:HSlider id="slider" height="25"
                allowTrackClick="true" allowThumbOverlap="false" 
                liveDragging="true" change="updateBoundariesFromSlider()"
                showDataTip="false"
                showTrackHighlight="true"
                thumbCount="2" snapInterval="0"
                values="{[leftBoundary, rightBoundary]}"
                minimum="{globalLeftBoundary}" maximum="{globalRightBoundary}"
                right="50" left="198" y="155"
                />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:02:41+00:00Added an answer on May 15, 2026 at 2:02 pm

    I had an application with a similar chart zooming requirement, and I found that filtering the charts data provider based of the upper and lower bounds looks much better than modifying the minimum and maximum on the charts horizontal axis. Here is a simple, working example (Flex 3, UPDATE 6-29-10: Modified example to use XMLListCollection):

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
        xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout="vertical" initialize="{init()}"
    >
    
        <mx:Script>
            <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.collections.ArrayCollection;
                public static const MIN_DATE:Number = 1900;
                public static const MAX_DATE:Number = 2010;
    
                public var mainData:XML = function():XML{
                    var ret:XML = <data></data>;
                    for(var i:Number = MIN_DATE;
                        i <= MAX_DATE; i++)
                    {
                        ret.appendChild(
                            XMLList(
                                '<datum><date>' 
                                    + i + 
                                    '</date><value>' 
                                    + Math.random() + 
                                '</value></datum>'
                            )
                        );
                    }
                    return ret;
                }();
    
                [Bindable]
                public var selectedData:XMLListCollection = 
                        new XMLListCollection(mainData.child('datum'));
    
                public function init():void
                {
                    selectedData.filterFunction = filterData;
                    selectedData.refresh();
                }
    
                private function filterData(o:Object):Boolean
                {
                    return o.date >= minStepper.value && o.date <= maxStepper.value;
                }
            ]]>
        </mx:Script>
    
    
        <mx:LineChart 
            id="lineChart" 
            dataProvider="{selectedData}"
        >
            <mx:horizontalAxis>
                <mx:DateTimeAxis 
                    id="hAxis" 
                    parseFunction="{
                        function(obj:Object):Date
                        {
                            return new Date(obj.toString(), 1);
                        }
                    }"
                />
            </mx:horizontalAxis>
            <mx:verticalAxis>
                <mx:LinearAxis 
                    id="vAxis" 
                />
            </mx:verticalAxis>
            <mx:series>
                <mx:LineSeries 
                    xField="date" 
                    yField="value" 
                />
            </mx:series>
        </mx:LineChart>
        <mx:HBox>
            <mx:NumericStepper 
                id="minStepper" 
                minimum="{MIN_DATE}" 
                maximum="{Math.min(maxStepper.value - 1, MAX_DATE)}" 
                change="{selectedData.refresh();}"
                value="{MIN_DATE}"
            />
            <mx:NumericStepper id="maxStepper" 
                maximum="{MAX_DATE}" 
                minimum="{Math.max(minStepper.value + 1, MIN_DATE)}" 
                change="{selectedData.refresh();}"
                value="{MAX_DATE}"
            />
        </mx:HBox>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.