This post Google Column Graph Single Date and value showing as multiple adjucent bars has a clue in the hidden code snippet which helped me solve the question posed below.
I'm passing json-like data into google chart datatable. The head and tail are shown below.
Head:
var GSPC =
{
cols:[
{label: "Date", type: "date"},
{label: "High", type: "number"},
{label: "Low", type: "number"},
],
rows:[
{c:[{v:"Date(1985,01,02)"},{v:167.20},{v:165.19}]},
{c:[{v:"Date(1985,01,03)"},{v:166.11},{v:164.38}]},
{c:[{v:"Date(1985,01,04)"},{v:164.55},{v:163.36}]},
Tail:
{c:[{v:"Date(2018,02,14)"},{v:2702.10},{v:2648.87}]},
{c:[{v:"Date(2018,02,15)"},{v:2731.51},{v:2689.82}]},
{c:[{v:"Date(2018,02,16)"},{v:2754.42},{v:2725.11}]},
]
};
I have two ? marks in the javascript code below where I don't know how to set the range start and range end. The range end should be the last date in the DATA variable and the range start would be arbitrarily set relative to the range end (e.g. two years prior). How do I set the end of range to the final data value in the date array and how do I set the start of range to a prior date relative to the end date?
javascript - chart control wrapper
function drawDashBoard_GSPC() {
var data = new google.visualization.DataTable(GSPC);
var dashboard = new google.visualization.Dashboard(document.getElementById('GSPC_DashBoard'));
var control = new google.visualization.ControlWrapper({
controlType: 'ChartRangeFilter',
containerId: 'Control',
options: {
filterColumnLabel: 'Date',
ui: {
snapToData: false,
chartOptions: {
chartArea: {
left: 75, // set equal to left margin of scatter chartArea
top: 0, // set to 0
width: 1100, // set equalt to width of scatter chartArea
height: 40 // set to 40
}
}
}
},
state: {
range: { // SET START = 2 YEARS FROM END DATE
start: ?,
end: ?,
}
}
});