<?xml version="1.0" encoding="utf-8"?>
<mx:HDividedBox xmlns:mx="http://www.adobe.com/2006/mxml" 
    label="Scientists Sample (Updated!)" 
    xmlns:gantt4flex="http://www.flower-platform.com/gantt4flex"
    initialize="init()">

    <mx:Script>
        <![CDATA[
            import com.crispico.flower.flexdiagram.gantt.timeline.YearTimeUnit;
            import com.crispico.flower.flexdiagram.gantt.samples.scientists.model.Scientist;
            import mx.collections.ArrayCollection;
            
            private const todayDate:Date = new Date();
            
            public function init():void {
                var data:ArrayCollection = new ArrayCollection();
                
                data.addItem(new Scientist("Isaac Newton", new Date(1643, 0, 4), new Date(1727, 02, 31)));
                data.addItem(new Scientist("Albert Einstein", new Date(1879, 2, 14), new Date(1955, 3, 18)));
                data.addItem(new Scientist("Charles Darwin", new Date(1809, 1, 12), new Date(1882, 3, 19)));
                data.addItem(new Scientist("Louis Pasteur", new Date(1822, 11, 27), new Date(1895, 8, 28)));
                data.addItem(new Scientist("Sigmund Freud", new Date(1856, 5, 6), new Date(1939, 8, 23)));
                data.addItem(new Scientist("Galileo Galilei", new Date(1564, 1, 15), new Date(1642, 0, 8)));
                data.addItem(new Scientist("Antoine Laurent Lavoisier", new Date(1743, 7, 26), new Date(1794, 5, 8)));
                data.addItem(new Scientist("Johannes Kepler", new Date(1571, 11, 27), new Date(1630, 10, 15)));
                data.addItem(new Scientist("Nicolaus Copernicus", new Date(1473, 1, 19), new Date(1543, 5, 24)));
                data.addItem(new Scientist("Michael Faraday", new Date(1791, 8, 22), new Date(1867, 7, 25)));
                data.addItem(new Scientist("James Clerk Maxwell", new Date(1831, 5, 13), new Date(1879, 10, 5))); 
                data.addItem(new Scientist("Claude Bernard", new Date(1813, 6, 12), new Date(1878, 1, 10))); 
                data.addItem(new Scientist("Franz Boas", new Date(1858, 6, 9), new Date(1942, 11, 21))); 
                data.addItem(new Scientist("Werner Heisenberg", new Date(1901, 11, 5), new Date(1976, 1, 1))); 
                data.addItem(new Scientist("Linus Pauling", new Date(1901, 1, 28), new Date(1994, 7, 19))); 
                data.addItem(new Scientist("Rudolf Virchow", new Date(1821, 9, 13), new Date(1902, 8, 5))); 
                data.addItem(new Scientist("Erwin Schrodinger", new Date(1887, 7, 12), new Date(1961, 0, 4)));
                data.addItem(new Scientist("Ernest Rutherford", new Date(1871, 7, 30), new Date(1937, 9, 19)));
                data.addItem(new Scientist("Paul Dirac", new Date(1902, 7, 8), new Date(1984, 9, 20)));
                data.addItem(new Scientist("Andreas Vesalius", new Date(1514, 11, 31), new Date(1564, 9, 15)));
                data.addItem(new Scientist("Tycho Brahe", new Date(1546, 11, 14), new Date(1601, 9, 24)));
                data.addItem(new Scientist("Comte de Buffon", new Date(1707, 8, 7), new Date(1788, 3, 16)));
                data.addItem(new Scientist("Ludwig Boltzmann", new Date(1844, 1, 20), new Date(1906, 8, 5))); 
                data.addItem(new Scientist("Max Planck", new Date(1858, 3, 23), new Date(1947, 9, 4))); 
                data.addItem(new Scientist("Marie Curie", new Date(1867, 10, 7), new Date(1934, 6, 4)));
                data.addItem(new Scientist("William Herschel", new Date(1738, 10, 15), new Date(1822, 7, 25)));
                data.addItem(new Scientist("Charles Lyell", new Date(1797, 10, 14), new Date(1875, 1, 22)));
                data.addItem(new Scientist("Pierre Simon de Laplace", new Date(1749, 2, 23), new Date(1827, 2, 5)));
                data.addItem(new Scientist("Edwin Hubble", new Date(1889, 10, 20), new Date(1953, 8, 28)));
                data.addItem(new Scientist("Joseph J. Thomson", new Date(1856, 11, 18), new Date(1940, 7, 30)));
                data.addItem(new Scientist("Francis Crick", new Date(1916, 5, 8), new Date(2004, 6, 28)));
                data.addItem(new Scientist("Enrico Fermi", new Date(1901, 8, 29), new Date(1954, 10, 28)));
                data.addItem(new Scientist("Leonard Euler", new Date(1707, 3, 15), new Date(1783, 8, 18))); 
                data.addItem(new Scientist("Justus Liebig", new Date(1803, 5, 12), new Date(1873, 3, 18))); 
                data.addItem(new Scientist("Arthur Eddington", new Date(1882, 11, 28), new Date(1944, 10, 22))); 
                data.addItem(new Scientist("William Harvey", new Date(1578, 3, 1), new Date(1657, 5, 3))); 
                data.addItem(new Scientist("Marcello Malpighi", new Date(1628, 2, 10), new Date(1694, 10, 29))); 
                data.addItem(new Scientist("Christiaan Huygens", new Date(1629, 3, 14), new Date(1695, 6, 8))); 
                data.addItem(new Scientist("Carl Gauss", new Date(1777, 3, 30), new Date(1855, 1, 23)));
                data.addItem(new Scientist("Albrecht von Haller", new Date(1708, 9, 16), new Date(1777, 11, 12)));
                data.addItem(new Scientist("August Kekule", new Date(1829, 8, 7), new Date(1896, 6, 13)));
                data.addItem(new Scientist("Robert Koch", new Date(1843, 11, 11), new Date(1910, 5, 27)));
                data.addItem(new Scientist("Murray Gell-Mann", new Date(1929, 8, 15), todayDate));
                data.addItem(new Scientist("Emil Fischer", new Date(1852, 9, 9), new Date(1919, 6, 15)));
                data.addItem(new Scientist("Dmitri Mendeleev", new Date(1834, 1, 8), new Date(1907, 1, 2)));
                data.addItem(new Scientist("Sheldon Glashow", new Date(1934, 11, 5), todayDate));
                data.addItem(new Scientist("James Watson", new Date(1928, 3, 6), todayDate));
                data.addItem(new Scientist("John Bardeen", new Date(1908, 5, 23), new Date(1991, 0, 30)));
                data.addItem(new Scientist("John von Neumann", new Date(1903, 11, 28), new Date(1957, 1, 8)));
                data.addItem(new Scientist("Richard Feynman", new Date(1918, 5, 11), new Date(1988, 1, 15)));
                data.addItem(new Scientist("Alfred Wegener", new Date(1880, 10, 1), new Date(1930, 10, 1)));
                data.addItem(new Scientist("Stephen Hawking", new Date(1942, 0, 8), todayDate));
                data.addItem(new Scientist("Anton van Leeuwenhoek", new Date(1632, 10, 24), new Date(1723, 7, 26)));
                data.addItem(new Scientist("Max von Laue", new Date(1879, 9, 9), new Date(1960, 3, 24))); 
                data.addItem(new Scientist("Gustav Kirchhoff", new Date(1824, 2, 12), new Date(1887, 9, 17))); 
                data.addItem(new Scientist("Hans Bethe", new Date(1906, 6, 2), new Date(2005, 2, 6)));
                data.addItem(new Scientist("Gregor Mendel", new Date(1822, 6, 20), new Date(1884, 0, 6)));
                data.addItem(new Scientist("Heike Kamerlingh Onnes", new Date(1853, 8, 21), new Date(1926, 1, 21))); 
                data.addItem(new Scientist("Thomas Hunt Morgan", new Date(1866, 8, 25), new Date(1945, 11, 4))); 
                data.addItem(new Scientist("Hermann von Helmholtz", new Date(1821, 7, 31), new Date(1894, 8, 8))); 
                data.addItem(new Scientist("Paul Ehrlich", new Date(1854, 2, 14), new Date(1915, 7, 20))); 
                data.addItem(new Scientist("Ernst Mayr", new Date(1904, 6, 5), new Date(2005, 1, 3))); 
                data.addItem(new Scientist("Charles Sherrington", new Date(1857, 10, 27), new Date(1952, 2, 4))); 
                data.addItem(new Scientist("Theodosius Dobzhansky", new Date(1900, 0, 24), new Date(1975, 11, 18))); 
                data.addItem(new Scientist("Max Delbruck", new Date(1906, 8, 4), new Date(1981, 2, 9))); 
                data.addItem(new Scientist("Jean Baptiste Lamarck", new Date(1744, 7, 1), new Date(1829, 11, 18))); 
                data.addItem(new Scientist("William Bayliss", new Date(1860, 4, 2), new Date(1924, 7, 27))); 
                data.addItem(new Scientist("Noam Chomsky", new Date(1928, 11, 7), todayDate)); 
                data.addItem(new Scientist("Frederick Sanger", new Date(1918, 7, 13), todayDate)); 
                data.addItem(new Scientist("John Dalton", new Date(1766, 8, 6), new Date(1844, 6, 27))); 
                data.addItem(new Scientist("Louis Victor de Broglie", new Date(1892, 7, 15), new Date(1987, 2, 19))); 
                data.addItem(new Scientist("Carl Linnaeus", new Date(1707, 4, 23), new Date(1778, 0, 10))); 
                data.addItem(new Scientist("Jean Piaget", new Date(1896, 7, 9), new Date(1980, 8, 16)));
                data.addItem(new Scientist("George Gaylord Simpson", new Date(1902, 5, 16), new Date(1984, 9, 6)));
                data.addItem(new Scientist("Claude Levi-Strauss", new Date(1908, 10, 28), new Date(2009, 9, 30)));
                data.addItem(new Scientist("Lynn Margulis", new Date(1938, 2, 5), todayDate));
                data.addItem(new Scientist("Karl Landsteiner", new Date(1868, 5, 14), new Date(1943, 5, 26))); 
                data.addItem(new Scientist("Konrad Lorenz", new Date(1903, 10, 7), new Date(1989, 1, 27))); 
                data.addItem(new Scientist("Edward O. Wilson", new Date(1929, 5, 10), todayDate)); 
                data.addItem(new Scientist("Frederick Gowland Hopkins", new Date(1861, 5, 20), new Date(1947, 4, 16))); 
                data.addItem(new Scientist("Gertrude Belle Elion", new Date(1918, 0, 23), new Date(1999, 1, 21))); 
                data.addItem(new Scientist("Hans Selye", new Date(1907, 0, 26), new Date(1982, 9, 16))); 
                data.addItem(new Scientist("J. Robert Oppenheimer", new Date(1904, 3, 22), new Date(1967, 1, 18))); 
                data.addItem(new Scientist("Edward Teller", new Date(1908, 0, 15), new Date(2003, 8, 9))); 
                data.addItem(new Scientist("Willard Libby", new Date(1908, 11, 17), new Date(1980, 8, 8)));
                data.addItem(new Scientist("Ernst Haeckel", new Date(1834, 1, 16), new Date(1919, 7, 9)));
                data.addItem(new Scientist("Jonas Salk", new Date(1914, 9, 28), new Date(1995, 5, 23)));
                data.addItem(new Scientist("Emil Kraepelin", new Date(1856, 1, 15), new Date(1926, 9, 7)));
                data.addItem(new Scientist("Trofim Lysenko", new Date(1898, 8, 29), new Date(1976, 10, 20)));
                data.addItem(new Scientist("Francis Galton", new Date(1822, 1, 16), new Date(1911, 0, 17)));
                data.addItem(new Scientist("Alfred Binet", new Date(1857, 6, 8), new Date(1911, 9, 18)));
                data.addItem(new Scientist("Alfred Kinsey", new Date(1894, 5, 23), new Date(1956, 7, 25)));
                data.addItem(new Scientist("Alexander Fleming", new Date(1881, 7, 6), new Date(1955, 2, 11)));
                data.addItem(new Scientist("B. F. Skinner", new Date(1904, 2, 20), new Date(1990, 7, 18)));
                data.addItem(new Scientist("Wilhelm Wundt", new Date(1832, 7, 16), new Date(1920, 7, 31))); 

                gantt.dataProvider = data;
                gantt.setDisplayInterval(new Date(1800, 0), new Date(1900, 0));
            }        
            
            private function getDateLabel(item:Object,column:DataGridColumn):String {
                if (item[column.dataField] == todayDate)
                    return "---";
                else
                    return dateFormatter.format(item[column.dataField]);
            }     
            
            private function toggleDescriptionFullScreen():void {
                if (gantt.width != 0) {
                    // expand description full screen
                    gantt.width = 0;
                    descriptionPanel.percentWidth = 100;
                } else {
                    // collapse description
                    gantt.width = NaN;
                    gantt.percentWidth = 100;
                    descriptionPanel.width = 200;
                }
            }

        ]]>
    </mx:Script>
    <mx:DateFormatter id="dateFormatter" formatString="DD/MM/YYYY"/>
    <gantt4flex:GanttDiagramFigure id="gantt" width="100%" height="100%"
        startDateProperty="bornDate" endDateProperty="dieDate">
        <gantt4flex:dataGrid>
            <mx:DataGrid width="20%">
                <mx:columns>
                    <mx:DataGridColumn headerText="Name" dataField="name" sortable="false"/>
                    <mx:DataGridColumn headerText="Born Date" dataField="bornDate" labelFunction="getDateLabel" sortable="false"/>
                    <mx:DataGridColumn headerText="Die Date" dataField="dieDate" labelFunction="getDateLabel" sortable="false"/>
                </mx:columns>
            </mx:DataGrid>
        </gantt4flex:dataGrid>
        <!-- add a timeline -->
        <gantt4flex:timelines>
            <gantt4flex:Timeline id="minorTimeline">
                <gantt4flex:timeUnits>
                    <gantt4flex:YearTimeUnit/>
                    <gantt4flex:YearTimeUnit multiple="10"/>
                    <gantt4flex:YearTimeUnit multiple="25"/>
                    <gantt4flex:YearTimeUnit multiple="50"/>
                </gantt4flex:timeUnits>
            </gantt4flex:Timeline>
        </gantt4flex:timelines>
        
        <!-- add two grids-->
        <gantt4flex:grids>
            <gantt4flex:HorizontalGrid alternatingColors="[0xB1B9B0, 0xD1D9D0]"/>
            <gantt4flex:VerticalGrid colorAlpha="0.7"/>
        </gantt4flex:grids>
        <gantt4flex:nowIndicatorLine>
            <gantt4flex:NowIndicatorLine/>
        </gantt4flex:nowIndicatorLine>

        <!-- define TimeUnits that will be used to snap to grid when moving/resizing segments-->
        <gantt4flex:snapToGridTimeUnits>
            <gantt4flex:MonthTimeUnit/>
            <gantt4flex:YearTimeUnit/>
        </gantt4flex:snapToGridTimeUnits>
        
        <!-- customize status bar text -->
        <gantt4flex:statusBarTextFormatter>
            <gantt4flex:StatusBarTextFormatter 
                cursorPositionFormat="YYYY"
                cursorPositionDeltaFormat="Y year(s) MM months"
                
                segmentStartFormat="MMM DD, YYYY"
                segmentEndFormat="MMM DD, YYYY"
                segmentDurationFormat="Y year(s) MM months">
                
                <!-- use CDATA sections because of special characters <, >, etc -->
                <gantt4flex:segmentStartString>
                    <![CDATA[Born on: <font color="#62C469"><b>{0}</b></font>]]>
                </gantt4flex:segmentStartString>
                <gantt4flex:segmentStartNewString>
                    <![CDATA[New birth date: <font color="#62C469"><b>{0}</b></font>]]>
                </gantt4flex:segmentStartNewString>
                
                <gantt4flex:segmentEndString>
                    <![CDATA[Died on: <font color="#F57676"><b>{0}</b></font>]]>
                </gantt4flex:segmentEndString>
                <gantt4flex:segmentEndNewString>
                    <![CDATA[New die date: <font color="#F57676"><b>{0}</b></font>]]>
                </gantt4flex:segmentEndNewString>
                
                <gantt4flex:segmentDurationString>
                    <![CDATA[Age: <b>{0}</b>]]>
                </gantt4flex:segmentDurationString>

                <gantt4flex:segmentDurationNewString>
                    <![CDATA[New age: <b>{0}</b>]]>
                </gantt4flex:segmentDurationNewString>
            </gantt4flex:StatusBarTextFormatter>
        </gantt4flex:statusBarTextFormatter>
    </gantt4flex:GanttDiagramFigure>
    <mx:Panel id="descriptionPanel" title="Sample Description" width="200" height="100%" doubleClickEnabled="true" doubleClick="toggleDescriptionFullScreen()" toolTip="Double click on the text to toggle Sample Description full screen">
        <mx:Text width="100%">
            <mx:htmlText>
                <![CDATA[This example illustrates:
                
- <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=model-configuration" target="_blank"><u>a flat, single segment model</u></a>
- basic <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=datagrid" target="_blank"><u>DataGrid</u></a>
- one <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=timelines" target="_blank"><u>timeline</u></a> with custom configuration
- <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=grids" target="_blank"><u>grids</u></a>
- customizing the <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=status-bar-text" target="_blank"><u>status bar text</u></a>
- <a href="http://www.flower-platform.com/dispatch.php?link=g4f_doc&anchor=snap-grid" target="_blank"><u>snap to grid</u></a> independent (of timelines)

Use CTRL + mouse wheel or click on the timeline to zoom. Select and drag to move/resize.

The diagram displays the lifelines of some of the greatest scientists (model's diagram below).

Right click/View Source is enabled.
<img src="../img_samples/model_scientists.png"/>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>]]>
            </mx:htmlText>
        </mx:Text>
    </mx:Panel>
</mx:HDividedBox>