将隐藏值调用到高图

时间:2013-07-30 15:17:01

标签: javascript asp.net vb.net highcharts

我有来自vb.net的数据,我想调用y轴。

代码背后的代码:

 Dim yaxis As String
 If RadioButtonList1.SelectedItem.Value = 1 Then
     yaxis = "Fruit eaten"
 End If

 hidden10.Value = yaxis

的javascript

 $(function () { 
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {

               text: '** i want Fruit eaten here***'**

            }
        },
        series: [{
            name: 'Jane',
            data: [1, 0, 4]
        }, {
            name: 'John',
            data: [5, 7, 3]
        }]
    });
 });​


<asp:HiddenField ID="hidden10" runat="server" />
var a10 = $("#<%=hidden10.ClientID%>").val();  

你可以看到它说文字:但我希望hidden10值显示...

我已经拥有的绘制功能

       function draw(d) {

           var testarray = JSON.parse(a);
           var testarray1 = JSON.parse(a1);
           var testarray2 = JSON.parse(a2);


           var yaxis = $("#<%=hidden10.ClientID%>").val();

testarray是来自反码的数据。

在radiobuttons的代码后面:

    Select Case RadioButtonList1.SelectedItem.Value
        Case 1

            Dim yaxis As String
            If RadioButtonList1.SelectedItem.Value = 1 Then
                yaxis = "fruit eaten"
            End If




            Dim serializer1 As New JavaScriptSerializer()

            Dim arrayJsonTest1 As String = serializer1.Serialize(testarray)
            Dim arrayJson11 As String = serializer1.Serialize(testarray1)
            Dim arrayJson12 As String = serializer1.Serialize(testarray2)

            hidden.Value = arrayJsonTest1
            hidden1.Value = arrayJson11
            hidden2.Value = arrayJson12

            ' Bind_kWhValues(Year1, Year2, Year3)
            ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "draw",         "javascript:draw(1);", True)



        Case 2
            Dim yaxis As String
            If RadioButtonList1.SelectedItem.Value = 2 Then
                yaxis = "fruits not eaten"
            End If

            hidden10.Value = yaxis


          ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "draw",         "javascript:draw(2);", True)

2 个答案:

答案 0 :(得分:1)

yAxis: {
         title: {
                  text:Yaxis 
                 }
       },

以上代码适合我。 确保如果RadioButtonList1.SelectedItem.Value = 1则满足此if条件。 我尝试了以下代码:

var Yaxis = 'default';
function draw(d) {

       var testarray = JSON.parse(a);
       var testarray1 = JSON.parse(a1);
       var testarray2 = JSON.parse(a2);
        if(d == 1)
        {
            Yaxis='Fruit Eaten..';

        }

        else  if(d == 2)
        {
           Yaxis='Fruit not  Eaten..';
        }
        else 
        {
            Yaxis='Your Default value here...';
        }


       }
}

答案 1 :(得分:1)

yAxis:{          标题:{                   文本:Y轴                  }        },