Handling of selection through javascript
Please refer to the link of my chart .
http://www.humblesoftware.com/fin开发者_运维问答ance/index (Customized this )
Basically the requirement is that , only one month of selection can be made at a point of time .(From the child chart)
If the selection is made from left side , i am simply adding 30 to the other value
xmin = Math.floor(area.x1);
xmax = xmin+30;
But if the selection is made from the right side then how to handle this ??
(Means if the xmax
is selected first then how can i handle the xmin
value )??
Without knowing too much about the situation, something like this should do:
// set the xmin to where they click
xmin = Math.floor(area.x1);
// make x-max the + 30 as you normally do
xmax = xmin + 30;
// now add a check to make sure we're not off the chart
// if we are, make the chart's last possible X value the
// x max, and subtract 30 from that to go backwards (and
// it may be a good idea to check if xmin is under the
// chart's min x value.
if (xmax > chart.xmax){
xmax = chart.xmax;
xmin = xmax - 30;
if (xmin < chart.xmin){
xmin = chart.xmin;
}
}
精彩评论