Back

Milestone markers

Apple stock prices, years 2004 - 2014

Documentation Open in JSFiddle
Start Free Trial Purchase

HTML

HTML
<script src="https://cdn.zoomcharts-cloud.com/1/nightly/zoomcharts.js"></script>

<div id="demo"></div>

CSS

CSS
//No CSS for this example 

JavaScript

JavaScript

    var chart;
    function success(data){
        data.dataLimitFrom = 0;
        data.dataLimitTo = 0;
        for (var i in data.values) {
            if (data.dataLimitFrom == 0) {
                data.dataLimitFrom = data.values[i][0];
            }
            data.dataLimitFrom = data.dataLimitFrom > data.values[i][0] ? data.values[i][0] : data.dataLimitFrom;
            data.dataLimitTo = data.dataLimitTo < data.values[i][0] ? data.values[i][0] : data.dataLimitTo;
        }
        chart = new TimeChart(
            settings = {
                container: document.getElementById("demo"),
                data:[
                    {
                        units:["d"],
                        id: "apple",
                        preloaded: data
                    }
                ],
                valueAxisDefault: {
                    title: "Value, $"
                },
                series:[
                    {
                        name:"Apple Stock price, avg",
                        id:"series2",
                        type:"line",
                        data:{
                            index:1,
                            aggregation:"avg",
                            source:"apple"
                        },
                        style:{
                            fillColor: "#eab404",
                            lineColor: "#eab404"
                        }
                    }
                ],
                navigation: {
                    initialDisplayUnit: "1 y",
                    initialDisplayPeriod: "10 y",
                    initialDisplayAnchor: "newestData"
                },
                area: {
                    displayUnits: [
                        {name: "day", unit: "1 d"},
                        {name: "month", unit: "1 M"},
                        {name: "year", unit: "1 y"},
                        {name: "10 years", unit: "10 y"}
                    ]
                },
                milestones: [
                    {time:1183075200000, label:{text: "iPhone 1st gen"}},
                    {time:1215734400000, label:{text: "iPhone 3G"}},
                    {time:1245369600000, label:{text: "iPhone 3GS"}},
                    {time:1277337600000, label:{text: "iPhone 4"}},
                    {time:1318550400000, label:{text: "iPhone 4S"}},
                    {time:1348185600000, label:{text: "iPhone 5"}},
                    {time:1379635200000, label:{text: "iPhone 5C"}},
                    {time:1411084800000, label:{text: "iPhone 6"}},
                    {time:1443139200000, label:{text: "iPhone 6S"}}
                ],
                currentTime: {
                    enabled: false
                }
            }
        );
    }
    // using a custom library to load CSV data
    loadCSV("/dvsl/data/time-chart/apple-stock-prices.csv", "d", [
        {type: "date", format:"([0-9]+)\/([0-9]+)\/([0-9]+)", fields: [3,2,1], process: [null, null,null, function(a){return 2000+parseInt(a);}]},
        {type: "decimal"},
        {type: "decimal"}
    ], "\t",function(data){
        success(data);
    });

Data

Data
//Data too large to output
Download Data