在图表调整大小维护图表时单击数据点 [英] During chart resize maintain chart click on data points

查看:81
本文介绍了在图表调整大小维护图表时单击数据点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图表,在该图表中我有一些系列,每个系列都有一些数据点。我想让每个数据点都可点击。我做了。但是当我在图表上应用调整大小时,它就失去了它的可点击性。我做的不知道怎么解决这个问题。请帮忙我急需你的帮助



我尝试了什么:



Jquery



 功能 winResized (){
var $ Chrt = $(' #Chart1' );
var wiw = $( window )。width();
var whi = $( window )。height();
if ($ Chrt.size()){
$ Chrt.css({
' position'' 已修复'
' width':wiw-10,
' height':whi-10,
});

}
}
$( window )。load( function (){
winResized(); $( #Chart1) .click( function (){
});
})。bind(' resize' function (){
winResized();
} );



aspx代码



 <   asp:Chart     ID   =  Chart1    runat   =  server >  
< 系列 >
< asp:Series 名称 = Series1 >
< 积分 >
< asp:DataPoint XValue = 3 YValues = 53 BorderWidth = 5 / >
< asp:DataPoint XValue = 2 YValues = 55 / >
< / Points >
< / asp:Series >
< asp:Series ChartArea = ChartArea2 < span class =code-attribute>名称 = Series2 >
< 积分 >
< asp:DataPoint XValue = 10 YValues = 90 / >
< asp:DataPoint XValue = 20 YValues = 80 / >
< / Points > ;
< / asp:Series >
< / Series >
< ChartAreas >
< ; asp:ChartArea 名称 = ChartArea1 >
< / asp:ChartArea >
< asp:ChartArea 名称 = ChartArea2 >
< / asp:ChartArea >
< / ChartAreas >
< / asp:Chart >



aspx.cs代码

  protected   void  Page_Load( object  sender, EventArgs e)
{
for int i = 0 ; i < Chart1.Series.Count; i ++)
{
for int j = 0 ; j < Chart1.Series [i] .Points.Count; j ++)
{
Chart1 .Series [i] .Points [i] .ToolTip = #VALY,#VALX;
Chart1.Series [i] .Points [j] .PostBackValue = j.ToString();
}

}
Chart1.Click + = new ImageMapEventHandler(chart_click);
Label1.Text = TextBox1.Text;
}
protected void chart_click( object sender,ImageMapEventArgs e)
{
for int i = 0 ; i < Chart1.Series [ Series1]。Points.Count; i ++)
{
if (e.PostBackValue == i.ToString())
{
Response.Write( 数据点 + i + 点击);
break ;
}
}
}

解决方案

Chrt =


< blockquote>(' #Chart1');
var wiw =


window )。宽度();
var whi =


I have one chart and in that chart I have some series and every series has some data points.I want to make each datapoints clickable.I did.but when I applied resize on charts then it lost its clickable nature.I do not know how to solve this issue.Please help I need your help urgently

What I have tried:

Jquery

function winResized() {
	var $Chrt=$('#Chart1');
    var wiw=$(window).width();
    var whi=$(window).height();
	if ($Chrt.size()){
    $Chrt.css({
			'position':'fixed',
			'width': wiw-10,
			'height': whi-10,
	});  
           
}
}
$(window).load(function() {
	winResized();$("#Chart1").click(function () {
            });
    }).bind('resize',function() {
	winResized();
});


aspx code

<asp:Chart ID="Chart1" runat="server">
            <Series>
                <asp:Series Name="Series1">
                <Points>
                        <asp:DataPoint XValue="3" YValues="53" BorderWidth="5" />
                        <asp:DataPoint XValue="2" YValues="55" />
                        </Points>
                </asp:Series>
                <asp:Series ChartArea="ChartArea2" Name="Series2">
                    <Points>
                        <asp:DataPoint XValue="10" YValues="90" />
                        <asp:DataPoint XValue="20" YValues="80" />
                    </Points>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
                <asp:ChartArea Name="ChartArea2">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>


aspx.cs code

protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < Chart1.Series.Count; i++)
            {
                for (int j = 0; j < Chart1.Series[i].Points.Count; j++)
                {
                    Chart1.Series[i].Points[i].ToolTip = "#VALY, #VALX";
                    Chart1.Series[i].Points[j].PostBackValue = j.ToString();
                }
               
            }
            Chart1.Click += new ImageMapEventHandler(chart_click);
            Label1.Text = TextBox1.Text;
        }
protected void chart_click(object sender, ImageMapEventArgs e)
        {
            for (int i = 0; i < Chart1.Series["Series1"].Points.Count; i++)
            {
                if (e.PostBackValue == i.ToString())
                {
                    Response.Write("data point" + i + "clicked");
                    break;
                }
            }
        }

解决方案

Chrt=


('#Chart1'); var wiw=


(window).width(); var whi=


这篇关于在图表调整大小维护图表时单击数据点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆