hightcharts图表简单使用




[javascript]  view plain  copy
  1. @{  
  2.     Layout = null;  
  3. }  
  4.   
  5. <!DOCTYPE html>  
  6.   
  7. <html>  
  8. <head>  
  9.     <meta name="viewport" content="width=device-width" />  
  10.     <title>PriceLclLog</title>  
  11.      @Html.Partial("_JsCss")  
  12.     <script src="~/Scripts/Custom/highcharts.js"></script>  
  13. </head>  
  14. <body>  
  15.         <div id="tb" style="height: auto">  
  16.         <h>起始日期:</h>  
  17.         <input style="width: 100px;" class="Wdate" id="Starttime" name="Starttime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />  
  18.         <h>截止日期:</h>  
  19.         <input style="width: 100px;" class="Wdate" id="Endtime" name="Endtime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />  
  20.         <input οnclick="searchClick();" type="button" value="检索" />  
  21.     </div>  
  22.       <div id="container" style="min-width: 400px; height: 300px; margin: 0 auto">  
  23.   
  24.       </div>    
  25.      <div id="container2" style="min-width: 400px; height: 300px; margin: 0 auto">  
  26.   
  27.       </div>    
  28.      <div id="container3" style="min-width: 400px; height: 300px; margin: 0 auto">  
  29.   
  30.       </div>    
  31. </body>  
  32. </html>  
  33.   
  34. <script>  
  35.   
  36.     $(function () {  
  37.   
  38.           
  39.         $.ajax({  
  40.             url: '/CompanysRepositoryLog/GetTongjiByCompanys',  
  41.             type: "post",  
  42.             success: function (data) {  
  43.                 createchartsdata(data);  
  44.                 createchartsdata2(data);  
  45.             }  
  46.         });  
  47.   
  48.     });  
  49.   
  50.   
  51.     function createchartsdata(data)  
  52.     {  
  53.         var categories = [];  
  54.         var cdata = [];  
  55.         $.each(data.rows, function (index, item) {  
  56.             if (index <= 25) {  
  57.                 categories.push(item.Country);  
  58.                 cdata.push(item.Count);  
  59.             }  
  60.         });  
  61.         createcharts(categories, cdata);  
  62.     }  
  63.   
  64.   
  65.     function createchartsdata2(data) {  
  66.         var categories = [];  
  67.         var cdata = [];  
  68.         $.each(data.rows, function (index, item) {  
  69.             if (index > 25 && index <= 50) {  
  70.                 categories.push(item.Country);  
  71.                 cdata.push(item.Count);  
  72.             }  
  73.         });  
  74.         createcharts2(categories, cdata);  
  75.     }  
  76.   
  77.   
  78.   
  79.     function createcharts(categories,_data)  
  80.     {  
  81.         $('#container').highcharts({  
  82.             chart: {  
  83.                 type: 'column'  
  84.             },  
  85.             title: {  
  86.                 text: '海外直客热点图',  
  87.                 labels: {  
  88.                     style: {  
  89.                         color: '#000'  
  90.                     },  
  91.                     color: '#000'  
  92.                 }  
  93.             },  
  94.             //subtitle: {  
  95.             //    text: '5月份'  
  96.             //},  
  97.             xAxis: {  
  98.                 categories: categories  
  99.             },  
  100.             yAxis: {  
  101.                 min: 0,  
  102.                 title: {  
  103.                     text: '点击数量'  
  104.                 }  
  105.             },  
  106.             tooltip: {  
  107.                 headerFormat: '<span style="font-size:10px">{point.key}</span>',  
  108.                 pointFormat: '' +  
  109.                     '',  
  110.                 footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',  
  111.                 shared: true,  
  112.                 useHTML: true  
  113.             },  
  114.             plotOptions: {  
  115.                 column: {  
  116.                     pointPadding: 0.2,  
  117.                     borderWidth: 0  
  118.                 }  
  119.             },  
  120.             series: [{  
  121.                 name: '国家',  
  122.                 data: _data,  
  123.                 dataLabels: { //显示数值  
  124.                     enabled: true,  
  125.                     color: '#666666'  
  126.                 }  
  127.             }  
  128.             ]  
  129.         });  
  130.     }  
  131.   
  132.     function createcharts2(categories, _data) {  
  133.         var colors = Highcharts.getOptions().colors;  
  134.         $('#container2').highcharts({  
  135.             chart: {  
  136.                 type: 'column'  
  137.             },  
  138.             title: {  
  139.                 text: '海外直客热点图'  
  140.             },  
  141.             //subtitle: {  
  142.             //    text: '5月份'  
  143.             //},  
  144.             xAxis: {  
  145.                 categories: categories  
  146.             },  
  147.             yAxis: {  
  148.                 min: 0,  
  149.                 title: {  
  150.                     text: '点击数量'  
  151.                 }  
  152.             },  
  153.             tooltip: {  
  154.                 headerFormat: '<span style="font-size:10px">{point.key}</span>',  
  155.                 pointFormat: '' +  
  156.                     '',  
  157.                 footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',  
  158.                 shared: true,  
  159.                 useHTML: true  
  160.             },  
  161.             plotOptions: {  
  162.                 column: {  
  163.                     pointPadding: 0.2,  
  164.                     borderWidth: 0  
  165.                 }  
  166.             },  
  167.             series: [{  
  168.                 name: '国家',  
  169.                 data: _data,  
  170.                 dataLabels: {  
  171.                     enabled: true,  
  172.                     color: '#666666'  
  173.                 }  
  174.                 //color: colors[2]  //修改柱状图颜色  
  175.             }  
  176.             ]  
  177.         });  
  178.     }  
  179. </script>  


[javascript]  view plain  copy
  1. @{  
  2.     Layout = null;  
  3. }  
  4.   
  5. <!DOCTYPE html>  
  6.   
  7. <html>  
  8. <head>  
  9.     <meta name="viewport" content="width=device-width" />  
  10.     <title>PriceLclLog</title>  
  11.      @Html.Partial("_JsCss")  
  12.     <script src="~/Scripts/Custom/highcharts.js"></script>  
  13. </head>  
  14. <body>  
  15.         <div id="tb" style="height: auto">  
  16.         <h>起始日期:</h>  
  17.         <input style="width: 100px;" class="Wdate" id="Starttime" name="Starttime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />  
  18.         <h>截止日期:</h>  
  19.         <input style="width: 100px;" class="Wdate" id="Endtime" name="Endtime" οnclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />  
  20.         <input οnclick="searchClick();" type="button" value="检索" />  
  21.     </div>  
  22.       <div id="container" style="min-width: 400px; height: 300px; margin: 0 auto">  
  23.   
  24.       </div>    
  25.      <div id="container2" style="min-width: 400px; height: 300px; margin: 0 auto">  
  26.   
  27.       </div>    
  28.      <div id="container3" style="min-width: 400px; height: 300px; margin: 0 auto">  
  29.   
  30.       </div>    
  31. </body>  
  32. </html>  
  33.   
  34. <script>  
  35.   
  36.     $(function () {  
  37.   
  38.           
  39.         $.ajax({  
  40.             url: '/CompanysRepositoryLog/GetTongjiByCompanys',  
  41.             type: "post",  
  42.             success: function (data) {  
  43.                 createchartsdata(data);  
  44.                 createchartsdata2(data);  
  45.             }  
  46.         });  
  47.   
  48.     });  
  49.   
  50.   
  51.     function createchartsdata(data)  
  52.     {  
  53.         var categories = [];  
  54.         var cdata = [];  
  55.         $.each(data.rows, function (index, item) {  
  56.             if (index <= 25) {  
  57.                 categories.push(item.Country);  
  58.                 cdata.push(item.Count);  
  59.             }  
  60.         });  
  61.         createcharts(categories, cdata);  
  62.     }  
  63.   
  64.   
  65.     function createchartsdata2(data) {  
  66.         var categories = [];  
  67.         var cdata = [];  
  68.         $.each(data.rows, function (index, item) {  
  69.             if (index > 25 && index <= 50) {  
  70.                 categories.push(item.Country);  
  71.                 cdata.push(item.Count);  
  72.             }  
  73.         });  
  74.         createcharts2(categories, cdata);  
  75.     }  
  76.   
  77.   
  78.   
  79.     function createcharts(categories,_data)  
  80.     {  
  81.         $('#container').highcharts({  
  82.             chart: {  
  83.                 type: 'column'  
  84.             },  
  85.             title: {  
  86.                 text: '海外直客热点图',  
  87.                 labels: {  
  88.                     style: {  
  89.                         color: '#000'  
  90.                     },  
  91.                     color: '#000'  
  92.                 }  
  93.             },  
  94.             //subtitle: {  
  95.             //    text: '5月份'  
  96.             //},  
  97.             xAxis: {  
  98.                 categories: categories  
  99.             },  
  100.             yAxis: {  
  101.                 min: 0,  
  102.                 title: {  
  103.                     text: '点击数量'  
  104.                 }  
  105.             },  
  106.             tooltip: {  
  107.                 headerFormat: '<span style="font-size:10px">{point.key}</span>',  
  108.                 pointFormat: '' +  
  109.                     '',  
  110.                 footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',  
  111.                 shared: true,  
  112.                 useHTML: true  
  113.             },  
  114.             plotOptions: {  
  115.                 column: {  
  116.                     pointPadding: 0.2,  
  117.                     borderWidth: 0  
  118.                 }  
  119.             },  
  120.             series: [{  
  121.                 name: '国家',  
  122.                 data: _data,  
  123.                 dataLabels: { //显示数值  
  124.                     enabled: true,  
  125.                     color: '#666666'  
  126.                 }  
  127.             }  
  128.             ]  
  129.         });  
  130.     }  
  131.   
  132.     function createcharts2(categories, _data) {  
  133.         var colors = Highcharts.getOptions().colors;  
  134.         $('#container2').highcharts({  
  135.             chart: {  
  136.                 type: 'column'  
  137.             },  
  138.             title: {  
  139.                 text: '海外直客热点图'  
  140.             },  
  141.             //subtitle: {  
  142.             //    text: '5月份'  
  143.             //},  
  144.             xAxis: {  
  145.                 categories: categories  
  146.             },  
  147.             yAxis: {  
  148.                 min: 0,  
  149.                 title: {  
  150.                     text: '点击数量'  
  151.                 }  
  152.             },  
  153.             tooltip: {  
  154.                 headerFormat: '<span style="font-size:10px">{point.key}</span>',  
  155.                 pointFormat: '' +  
  156.                     '',  
  157.                 footerFormat: '<table><tbody><tr><td style="color:{series.color};padding:0">{series.name}: </td><td style="padding:0"><b>{point.y:.1f} 次</b></td></tr></tbody></table>',  
  158.                 shared: true,  
  159.                 useHTML: true  
  160.             },  
  161.             plotOptions: {  
  162.                 column: {  
  163.                     pointPadding: 0.2,  
  164.                     borderWidth: 0  
  165.                 }  
  166.             },  
  167.             series: [{  
  168.                 name: '国家',  
  169.                 data: _data,  
  170.                 dataLabels: {  
  171.                     enabled: true,  
  172.                     color: '#666666'  
  173.                 }  
  174.                 //color: colors[2]  //修改柱状图颜色  
  175.             }  
  176.             ]  
  177.         });  
  178.     }  
  179. </script>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值