I theory, that would be possible to do, but in practice, it would be rather
complicated at best. The first problem you must overcome is finding all
intersections between the two lines. then you must add those points to your
data if they do not exist already. Create two new series (you can use a
DataView to do this), the first of which is always equal to the lower value
of the two lines, and the second of which is equal to the max of (blue line
- green line, 0):
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2, {
type: 'number',
calc: function (dt, row) {
return Math.min(dt.getValue(row, 1), dt.getValue(row, 2));
}
}, {
type: 'number',
calc: function (dt, row) {
return Math.max(dt.getValue(row, 1) - dt.getValue(row, 2), 0);
}
}]);
These two data series get added to the chart as "area" type series, with
the series.<series index> suboptions lineWidth = 0, pointSize = 0,
enableInteractivity = false, visibleInLegend = false. Set the first area's
color to "transparent" and the second to whatever color you want to fill in:
series: {
0: {
// blue line options
},
1: {
// green line options
},
2: {
// first area series
lineWidth: 0,
pointSize: 0,
enableInteractivity: false,
visibleInLegend: false,
color: 'transparent'
},
3: {
// second area series
lineWidth: 0,
pointSize: 0,
enableInteractivity: false,
visibleInLegend: false,
color: 'yellow'
}
}
This gets you there basically. You will probably have to turn off the
curveType: 'function' option if you are using that (as it appears you are
in the chart), as the curves will be different for the area series and the
lines, since they will not share all points in common.
On Friday, September 27, 2013 6:55:32 AM UTC-4, Basanta Kumar wrote:
>
> Hi,
>
> I have one line chart displaying market data. I want to highlight the
> chart upper area once any slider value cross the minimum value of that line
> chart. Please find the attached pic for more clarity.
>
> I need the fill the highlighted area in the pic. Can anyone help eme how
> can i do it by Google Chart API ?
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.