Re: How to edit the maximum and minimum datetimes display on the x axis?

729 views
Skip to first unread message

asgallant

unread,
Sep 5, 2012, 7:54:35 PM9/5/12
to google-visua...@googlegroups.com
You're options won't quite work as posted.  Try this instead:

var options {
    title'Silver Bid or Ask - <?php echo $string_for_chart_date; ?>',
    width:680,
    height300,
    chartArea.left'0px',
    theme'maximized',
    lineWidth:1,
    hAxis{
        viewWindow{
            minnew Date(<?php echo $year.",".($month+2).",".$day.",07,15,0"?>),
            maxnew Date(<?php echo $year.",".($month+1).",".$day.",20,15,0"?>)
        },
        viewWindowMode'explicit'
    }
}; 

On Wednesday, September 5, 2012 4:26:22 PM UTC-4, Max wrote:
I'm trying to make it so that my graph displays the remaining time in the day (so it doesn't look like the market is closed). If my data points don't run until the market close, I want the chart to be blank until that time.

I've tried using the following options. Anything I'm missing?

              var data = new google.visualization.DataTable();
     data.addColumn('datetime', 'Date');
     data.addColumn('number', 'Bid');              

              var dataView = new google.visualization.DataView(data);
     dataView.setColumns([{calc: function(data, row) { return data.getFormattedValue(row, 0); }, type:'datetime'}, 1]);
     // Set chart options
     var options = {'title':'Silver Bid or Ask - <?php echo $string_for_chart_date; ?>',
                    'width':680,
                    'height':300,
                    'chartArea.left': '0px',
                    'theme': 'maximized',
                    'lineWidth':1,
                    'hAxis.maxValue': new Date(<?php echo $year.",".($month+1).",".$day.",20,15,0"; ?>),
                    'hAxis.minValue': new Date(<?php echo $year.",".($month+2).",".$day.",07,15,0"; ?>),
                    'hAxis.viewWindowMode': 'explicit'};

Max

unread,
Sep 5, 2012, 10:23:15 PM9/5/12
to google-visua...@googlegroups.com
Perfect, that did the trick! Thanks for the help!

One small thing, I had to put quotes around the options (i.e. title, width, height, etc.). Worked after that small change. Just wanted to add that in case anyone ever came up on this answer.

Thanks again!

asgallant

unread,
Sep 5, 2012, 10:30:23 PM9/5/12
to google-visua...@googlegroups.com
You shouldn't need to put quotes around them; all modern javascript interpreters read them correctly without quotes.  Any problems were probably due to a couple of typos I didn't catch the first time around.  This the is corrected code:


var options {
    title'Silver Bid or Ask - <?php echo $string_for_chart_date; ?>',
    width:680,
    height300,
    chartArea{
        left0

    },
    theme'maximized',
    lineWidth1,
    hAxis{
        viewWindow{
            minnew Date(<?php echo $year.",".($month+2).",".$day.",07,15,0"?>),
            maxnew Date(<?php echo $year.",".($month+1).",".$day.",20,15,0"?>)
        },
        viewWindowMode'explicit'
    }
}; 

Max

unread,
Sep 5, 2012, 10:51:47 PM9/5/12
to google-visua...@googlegroups.com
Yep, that worked! One last thing, while debugging, I was messing with the months and made the minimum greater than the maximum. I'm pretty sure nobody's going to use my php code, but just wanted to add that. 

Thanks again for the prompt responses and help. I was having a lot of trouble with this and this saved me hours upon hours of debugging.

Have a good one!

asgallant

unread,
Sep 6, 2012, 9:17:57 AM9/6/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages