简体   繁体   English

按下按钮时如何显示条形图(jqplot)?

[英]how to display a bar chart (jqplot) when pressing a button?

i try to display a bar chart on a pressing on a button but without success , can some one can give me an example ? 我尝试在按下按钮时显示条形图,但没有成功,有人可以举一个例子吗? ( i'm new in java script) i try that: (我是Java脚本的新手)我尝试这样做:

$("#vm_buttons").button();
        $("#vm_buttons").click(function (evt) {
            // increment the value of output
          //  alert ('click');
            bar_chart_add('test_1',[1,3,4],[2,5,6] ,"test",['a','b','c']);

        });

bar_chart is function that make bar chart . bar_chart是制作条形图的功能。

10x, perry 10x,佩里

Give your button an ID. 给您的按钮一个ID。 Then, use the click(function()) to achieve the functionality. 然后,使用click(function())实现功能。 I used jqplot in the example - 我在示例中使用了jqplot-

See this - https://jsfiddle.net/ha3y1omd/ 看到这个-https://jsfiddle.net/ha3y1omd/

<button type="button" id="btnclick" class="btn btn-primary">Primary</button>

<div class="container" id="chart1">
</div>

In your JS file, 在您的JS文件中,

 $(document).ready(function(){
    $('#btnclick').click(function(){
       CapacityChart();
    });
  });

function CapacityChart()    {
       var plot1 = $.jqplot ('chart1', [[3,7,9,1,4,6,8,2,5]]);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM