简体   繁体   English

点击按钮如何调用酒吧聊天功能

[英]How to call the bar chat function in click the button

Here i am using bhar chat onloading it is working , my question is onclick the button also i want to call the same function , from this code where they are calling the function i am not able to get, if any one know means update my snippet.which purpose i am asking means clicking button that time i will pass the AJAX and again i will display the results 在这里我正在使用bhar chat onloading它正在工作,我的问题是在onclick按钮上我也想调用相同的功能,从此代码中他们正在调用我无法获得的功能,如果有人知道意味着更新我的代码段我要问的目的是指单击按钮,那次我将通过AJAX,然后再次显示结果

 $(function () { Highcharts.setOptions({ colors: ['#67BCE6'], chart: { style: { fontFamily: 'sans-serif', color: '#fff' } } }); $('#barchat').highcharts({ chart: { type: 'column', backgroundColor: '#36394B' }, title: { text: 'Trip Details', style: { color: '#fff' } }, xAxis: { tickWidth: 0, labels: { style: { color: '#fff', } }, categories: ['Project', 'Escort', 'Adhoc'] }, yAxis: { gridLineWidth: .5, gridLineDashStyle: 'dash', gridLineColor: 'black', title: { text: '', style: { color: '#fff' } }, labels: { formatter: function() { return '$'+Highcharts.numberFormat(this.value, 0, '', ','); }, style: { color: '#fff', } } }, legend: { enabled: false, }, credits: { enabled: false }, tooltip: { //valuePrefix: '$' }, plotOptions: { column: { borderRadius: 2, pointPadding: 0, groupPadding: 0.1 } }, series: [{ name: 'No of trip used', data: [1000, 2000, 2300] }] }); }); 
 <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- Barchat --> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="barchat" style="width:100%; height:320px;"></div> <button id="clickMeBtn">CLick Me</button> 

If I understood your question correctly, you're trying to reload the chart when the button is clicked. 如果我正确理解了您的问题,则您正在尝试单击按钮时重新加载图表。 If so, please try this code: 如果是这样,请尝试以下代码:

 $(function () { displayChart(['Project', 'Escort', 'Adhoc'],[1000, 2000, 2300]); }); $('button#clickMeBtn').on('click',function(){ displayChart(['Project', 'Escort', 'Adhoc'],[3000, 2000, 2300]); }); function displayChart(aCategories,aData){ Highcharts.setOptions({ colors: ['#67BCE6'], chart: { style: { fontFamily: 'sans-serif', color: '#fff' } } }); $('#barchat').highcharts({ chart: { type: 'column', backgroundColor: '#36394B' }, title: { text: 'Trip Details', style: { color: '#fff' } }, xAxis: { tickWidth: 0, labels: { style: { color: '#fff' } }, categories: aCategories }, yAxis: { gridLineWidth: .5, gridLineDashStyle: 'dash', gridLineColor: 'black', title: { text: '', style: { color: '#fff' } }, labels: { formatter: function() { return '$'+Highcharts.numberFormat(this.value, 0, '', ','); }, style: { color: '#fff', } } }, legend: { enabled: false, }, credits: { enabled: false }, tooltip: { //valuePrefix: '$' }, plotOptions: { column: { borderRadius: 2, pointPadding: 0, groupPadding: 0.1 } }, series: [{ name: 'No of trip used', data: aData }] }); } 
 <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- Barchat --> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="barchat" style="width:100%; height:320px;"></div> <button id="clickMeBtn">CLick Me</button> 

Create separate function for chat and pass new value in button click like below snippet in AJAX call. 创建单独的聊天功能,并在按钮单击中传递新值,如AJAX调用中的以下代码片段所示。

 $(function() { var data = [1000, 2000, 2300]; chart(data); $("#clickMeBtn").on("click", function() { //call AJAX and set new data and call chart function again. data = [2000, 1000, 2500] // New data chart(data); }); }); function chart(data) { Highcharts.setOptions({ colors: ['#67BCE6'], chart: { style: { fontFamily: 'sans-serif', color: '#fff' } } }); $('#barchat').highcharts({ chart: { type: 'column', backgroundColor: '#36394B' }, title: { text: 'Trip Details', style: { color: '#fff' } }, xAxis: { tickWidth: 0, labels: { style: { color: '#fff', } }, categories: ['Project', 'Escort', 'Adhoc'] }, yAxis: { gridLineWidth: .5, gridLineDashStyle: 'dash', gridLineColor: 'black', title: { text: '', style: { color: '#fff' } }, labels: { formatter: function() { return '$' + Highcharts.numberFormat(this.value, 0, '', ','); }, style: { color: '#fff', } } }, legend: { enabled: false, }, credits: { enabled: false }, tooltip: { //valuePrefix: '$' }, plotOptions: { column: { borderRadius: 2, pointPadding: 0, groupPadding: 0.1 } }, series: [{ name: 'No of trip used', data: data }] }); } 
 <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- Barchat --> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="barchat" style="width:100%; height:320px;"></div> <button id="clickMeBtn">CLick Me</button> 

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

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