123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- <div class="row">
- <div class="col-md-6" style="margin-top: 20px">
- <canvas id="line" style="width: 505px; display: block; height: 252px;" width="505" height="252"
- class="chartjs-render-monitor"></canvas>
- <script>
- $(function () {
- function randomScalingFactor() {
- return Math.floor(Math.random() * 100)
- }
- function getDataLabels(type = 1) {
- var labels = {}
- $.ajax({
- url: '/admin/getDataLabels',
- type: 'get',
- data: {type: type},
- dataType: 'json',
- async: false,
- success: function (res) {
- labels = res;
- }
- })
- return labels;
- }
- function getData(type) {
- var data = {}
- $.ajax({
- url: '/admin/data',
- type: 'get',
- data: {type: type},
- dataType: 'json',
- async: false,
- success: function (res) {
- data = res;
- }
- })
- return data;
- }
- window.chartColors = {
- red: 'rgb(255, 99, 132)',
- orange: 'rgb(255, 159, 64)',
- yellow: 'rgb(255, 205, 86)',
- green: 'rgb(75, 192, 192)',
- blue: 'rgb(54, 162, 235)',
- purple: 'rgb(153, 102, 255)',
- grey: 'rgb(201, 203, 207)'
- };
- var da = getData(1);
- var config = {
- type: 'line',
- data: {
- labels: da[1]['labels'],
- datasets: [{
- label: '店铺1',
- backgroundColor: window.chartColors.red,
- borderColor: window.chartColors.red,
- // data: getData(1, 1),
- data: da[1]['data'],
- fill: false,
- }, {
- label: '店铺2',
- fill: false,
- backgroundColor: window.chartColors.blue,
- borderColor: window.chartColors.blue,
- data: da[2]['data'],
- },{
- label: '店铺3',
- fill: false,
- backgroundColor: window.chartColors.orange,
- borderColor: window.chartColors.orange,
- data: da[3]['data'],
- }]
- },
- options: {
- responsive: true,
- title: {
- display: true,
- text: '最近七日店铺用户量'
- },
- tooltips: {
- mode: 'index',
- intersect: false,
- },
- hover: {
- mode: 'nearest',
- intersect: true
- },
- scales: {
- xAxes: [{
- display: true,
- scaleLabel: {
- display: true,
- labelString: '日期'
- }
- }],
- yAxes: [{
- display: true,
- scaleLabel: {
- display: true,
- labelString: '用户数量'
- }
- }]
- }
- }
- };
- var ctx = document.getElementById('line').getContext('2d');
- new Chart(ctx, config);
- });
- </script>
- </div>
- {{-- <div class="col-md-6" style="margin-top: 20px">--}}
- {{-- <canvas id="bar-line" width="505" height="252"--}}
- {{-- class="chartjs-render-monitor"></canvas>--}}
- {{-- <script>--}}
- {{-- $(function () {--}}
- {{-- function randomScalingFactor() {--}}
- {{-- return Math.floor(Math.random() * 100)--}}
- {{-- }--}}
- {{-- function getDataLabels(type = 1) {--}}
- {{-- var labels = {}--}}
- {{-- $.ajax({--}}
- {{-- url: '/admin/getDataLabels',--}}
- {{-- type: 'get',--}}
- {{-- data: {type: type},--}}
- {{-- dataType: 'json',--}}
- {{-- async: false,--}}
- {{-- success: function (res) {--}}
- {{-- labels = res;--}}
- {{-- }--}}
- {{-- })--}}
- {{-- return labels;--}}
- {{-- }--}}
- {{-- function getData(type = 1) {--}}
- {{-- var data = {}--}}
- {{-- $.ajax({--}}
- {{-- url: '/admin/data',--}}
- {{-- type: 'get',--}}
- {{-- data: {type: type},--}}
- {{-- dataType: 'json',--}}
- {{-- async: false,--}}
- {{-- success: function (res) {--}}
- {{-- data = res;--}}
- {{-- }--}}
- {{-- })--}}
- {{-- return data;--}}
- {{-- }--}}
- {{-- window.chartColors = {--}}
- {{-- red: 'rgb(255, 99, 132)',--}}
- {{-- orange: 'rgb(255, 159, 64)',--}}
- {{-- yellow: 'rgb(255, 205, 86)',--}}
- {{-- green: 'rgb(75, 192, 192)',--}}
- {{-- blue: 'rgb(54, 162, 235)',--}}
- {{-- purple: 'rgb(153, 102, 255)',--}}
- {{-- grey: 'rgb(201, 203, 207)'--}}
- {{-- };--}}
- {{-- var chartData = {--}}
- {{-- labels: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '五月', '六月', '七月'],--}}
- {{-- datasets: [{--}}
- {{-- type: 'line',--}}
- {{-- label: '每天用户增长情况',--}}
- {{-- borderColor: window.chartColors.blue,--}}
- {{-- borderWidth: 2,--}}
- {{-- fill: false,--}}
- {{-- data: getData(1)--}}
- {{-- }, {--}}
- {{-- type: 'bar',--}}
- {{-- label: '模型 2',--}}
- {{-- backgroundColor: window.chartColors.red,--}}
- {{-- data: getData(2),--}}
- {{-- borderColor: 'white',--}}
- {{-- borderWidth: 2--}}
- {{-- }, {--}}
- {{-- type: 'bar',--}}
- {{-- label: '模型 3',--}}
- {{-- backgroundColor: window.chartColors.green,--}}
- {{-- data: getData(3)--}}
- {{-- }]--}}
- {{-- };--}}
- {{-- var ctx = document.getElementById('bar-line').getContext('2d');--}}
- {{-- new Chart(ctx, {--}}
- {{-- type: 'bar',--}}
- {{-- data: chartData,--}}
- {{-- options: {--}}
- {{-- responsive: true,--}}
- {{-- title: {--}}
- {{-- display: true,--}}
- {{-- text: '用户模型'--}}
- {{-- },--}}
- {{-- tooltips: {--}}
- {{-- mode: 'index',--}}
- {{-- intersect: true--}}
- {{-- }--}}
- {{-- }--}}
- {{-- });--}}
- {{-- });--}}
- {{-- </script>--}}
- {{-- </div>--}}
- {{-- --}}{{-- ////////////////////////////--}}
- {{-- <div class="col-md-6" style="margin-top: 20px">--}}
- {{-- <canvas id="scatter" style="width: 505px; display: block; height: 252px;" width="505" height="252"--}}
- {{-- class="chartjs-render-monitor"></canvas>--}}
- {{-- <script>--}}
- {{-- $(function () {--}}
- {{-- function randomScalingFactor() {--}}
- {{-- return Math.floor(Math.random() * 100)--}}
- {{-- }--}}
- {{-- window.chartColors = {--}}
- {{-- red: 'rgb(255, 99, 132)',--}}
- {{-- orange: 'rgb(255, 159, 64)',--}}
- {{-- yellow: 'rgb(255, 205, 86)',--}}
- {{-- green: 'rgb(75, 192, 192)',--}}
- {{-- blue: 'rgb(54, 162, 235)',--}}
- {{-- purple: 'rgb(153, 102, 255)',--}}
- {{-- grey: 'rgb(201, 203, 207)'--}}
- {{-- };--}}
- {{-- var ctx = document.getElementById("scatter").getContext('2d');--}}
- {{-- var scatterChart = new Chart(ctx, {--}}
- {{-- type: 'scatter',--}}
- {{-- data: {--}}
- {{-- datasets: [{--}}
- {{-- label: 'My First dataset',--}}
- {{-- borderColor: window.chartColors.red,--}}
- {{-- data: [{--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }]--}}
- {{-- }, {--}}
- {{-- label: 'My Second dataset',--}}
- {{-- borderColor: window.chartColors.blue,--}}
- {{-- data: [{--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }, {--}}
- {{-- x: randomScalingFactor(),--}}
- {{-- y: randomScalingFactor(),--}}
- {{-- }]--}}
- {{-- }]--}}
- {{-- },--}}
- {{-- options: {--}}
- {{-- scales: {--}}
- {{-- xAxes: [{--}}
- {{-- type: 'linear',--}}
- {{-- position: 'bottom'--}}
- {{-- }]--}}
- {{-- }--}}
- {{-- }--}}
- {{-- });--}}
- {{-- });--}}
- {{-- </script>--}}
- {{-- </div>--}}
- {{-- <div class="col-md-6" style="margin-top: 20px">--}}
- {{-- <canvas id="doughnut" style="width: 505px; display: block; height: 252px;" width="505" height="252"--}}
- {{-- class="chartjs-render-monitor"></canvas>--}}
- {{-- <script>--}}
- {{-- $(function () {--}}
- {{-- function randomScalingFactor() {--}}
- {{-- return Math.floor(Math.random() * 100)--}}
- {{-- }--}}
- {{-- window.chartColors = {--}}
- {{-- red: 'rgb(255, 99, 132)',--}}
- {{-- orange: 'rgb(255, 159, 64)',--}}
- {{-- yellow: 'rgb(255, 205, 86)',--}}
- {{-- green: 'rgb(75, 192, 192)',--}}
- {{-- blue: 'rgb(54, 162, 235)',--}}
- {{-- purple: 'rgb(153, 102, 255)',--}}
- {{-- grey: 'rgb(201, 203, 207)'--}}
- {{-- };--}}
- {{-- var config = {--}}
- {{-- type: 'doughnut',--}}
- {{-- data: {--}}
- {{-- datasets: [{--}}
- {{-- data: [--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- ],--}}
- {{-- backgroundColor: [--}}
- {{-- window.chartColors.red,--}}
- {{-- window.chartColors.orange,--}}
- {{-- window.chartColors.yellow,--}}
- {{-- window.chartColors.green,--}}
- {{-- window.chartColors.blue,--}}
- {{-- ],--}}
- {{-- label: 'Dataset 1'--}}
- {{-- }],--}}
- {{-- labels: [--}}
- {{-- 'Red',--}}
- {{-- 'Orange',--}}
- {{-- 'Yellow',--}}
- {{-- 'Green',--}}
- {{-- 'Blue'--}}
- {{-- ]--}}
- {{-- },--}}
- {{-- options: {--}}
- {{-- responsive: true,--}}
- {{-- legend: {--}}
- {{-- position: 'top',--}}
- {{-- },--}}
- {{-- title: {--}}
- {{-- display: true,--}}
- {{-- text: 'Chart.js Doughnut Chart'--}}
- {{-- },--}}
- {{-- animation: {--}}
- {{-- animateScale: true,--}}
- {{-- animateRotate: true--}}
- {{-- }--}}
- {{-- }--}}
- {{-- };--}}
- {{-- var ctx = document.getElementById('doughnut').getContext('2d');--}}
- {{-- new Chart(ctx, config);--}}
- {{-- });--}}
- {{-- </script>--}}
- {{-- </div>--}}
- {{-- <div class="col-md-6" style="margin-top: 20px">--}}
- {{-- <canvas id="line-stacked" style="width: 505px; display: block; height: 252px;" width="505" height="252"--}}
- {{-- class="chartjs-render-monitor"></canvas>--}}
- {{-- <script>--}}
- {{-- $(function () {--}}
- {{-- function randomScalingFactor() {--}}
- {{-- return Math.floor(Math.random() * 100)--}}
- {{-- }--}}
- {{-- window.chartColors = {--}}
- {{-- red: 'rgb(255, 99, 132)',--}}
- {{-- orange: 'rgb(255, 159, 64)',--}}
- {{-- yellow: 'rgb(255, 205, 86)',--}}
- {{-- green: 'rgb(75, 192, 192)',--}}
- {{-- blue: 'rgb(54, 162, 235)',--}}
- {{-- purple: 'rgb(153, 102, 255)',--}}
- {{-- grey: 'rgb(201, 203, 207)'--}}
- {{-- };--}}
- {{-- var config = {--}}
- {{-- type: 'line',--}}
- {{-- data: {--}}
- {{-- labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],--}}
- {{-- datasets: [{--}}
- {{-- label: 'My First dataset',--}}
- {{-- borderColor: window.chartColors.red,--}}
- {{-- backgroundColor: window.chartColors.red,--}}
- {{-- data: [--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor()--}}
- {{-- ],--}}
- {{-- }, {--}}
- {{-- label: 'My Second dataset',--}}
- {{-- borderColor: window.chartColors.blue,--}}
- {{-- backgroundColor: window.chartColors.blue,--}}
- {{-- data: [--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor()--}}
- {{-- ],--}}
- {{-- }, {--}}
- {{-- label: 'My Third dataset',--}}
- {{-- borderColor: window.chartColors.green,--}}
- {{-- backgroundColor: window.chartColors.green,--}}
- {{-- data: [--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor()--}}
- {{-- ],--}}
- {{-- }, {--}}
- {{-- label: 'My Third dataset',--}}
- {{-- borderColor: window.chartColors.yellow,--}}
- {{-- backgroundColor: window.chartColors.yellow,--}}
- {{-- data: [--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor(),--}}
- {{-- randomScalingFactor()--}}
- {{-- ],--}}
- {{-- }]--}}
- {{-- },--}}
- {{-- options: {--}}
- {{-- responsive: true,--}}
- {{-- title: {--}}
- {{-- display: true,--}}
- {{-- text: 'Chart.js Line Chart - Stacked Area'--}}
- {{-- },--}}
- {{-- tooltips: {--}}
- {{-- mode: 'index',--}}
- {{-- },--}}
- {{-- hover: {--}}
- {{-- mode: 'index'--}}
- {{-- },--}}
- {{-- scales: {--}}
- {{-- xAxes: [{--}}
- {{-- scaleLabel: {--}}
- {{-- display: true,--}}
- {{-- labelString: 'Month'--}}
- {{-- }--}}
- {{-- }],--}}
- {{-- yAxes: [{--}}
- {{-- stacked: true,--}}
- {{-- scaleLabel: {--}}
- {{-- display: true,--}}
- {{-- labelString: 'Value'--}}
- {{-- }--}}
- {{-- }]--}}
- {{-- }--}}
- {{-- }--}}
- {{-- };--}}
- {{-- var ctx = document.getElementById('line-stacked').getContext('2d');--}}
- {{-- new Chart(ctx, config);--}}
- {{-- });--}}
- {{-- </script>--}}
- {{-- </div>--}}
- </div>
|