|
4 | 4 | <title>WebSockets Dashboard</title>
|
5 | 5 | <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"
|
6 | 6 | integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
7 |
| - <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/epoch/0.8.4/css/epoch.min.css" /> |
8 | 7 | <script
|
9 | 8 | src="https://code.jquery.com/jquery-3.3.1.min.js"
|
10 | 9 | integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
|
11 | 10 | crossorigin="anonymous"></script>
|
12 | 11 | <script src="https://js.pusher.com/4.3/pusher.min.js"></script>
|
13 | 12 | <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>
|
14 |
| - <script src="http://d3js.org/d3.v3.js" charset="utf-8"></script> |
15 |
| - <script src="https://cdnjs.cloudflare.com/ajax/libs/epoch/0.8.4/js/epoch.min.js"></script> |
| 13 | + <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> |
16 | 14 | </head>
|
17 | 15 |
|
18 | 16 | <body>
|
19 | 17 | <div class="container" id="app">
|
20 | 18 | <div class="card col-xs-12 mt-4">
|
21 | 19 | <div class="card-header">
|
22 | 20 | <form id="connect" class="form-inline" role="form">
|
23 |
| - <label class="my-1 mr-2" for="app">app:</label> |
| 21 | + <label class="my-1 mr-2" for="app">App:</label> |
24 | 22 | <select class="form-control form-control-sm mr-2" name="app" id="app" v-model="app">
|
25 | 23 | <option v-for="app in apps" :value="app">@{{ app.name }}</option>
|
26 | 24 | </select>
|
|
36 | 34 | <div id="status"></div>
|
37 | 35 | </div>
|
38 | 36 | <div class="card-body">
|
39 |
| - <div v-if="connected" id="statisticsChart" style="width: 100%; height: 250px;"> |
40 |
| - |
| 37 | + <div v-if="connected && app.statisticsEnabled"> |
| 38 | + <h4>Peak Connections</h4> |
| 39 | + <div id="statisticsChart" style="width: 100%; height: 250px;"></div> |
41 | 40 | </div>
|
42 | 41 | <div v-if="connected">
|
43 | 42 | <h4>Event Creator</h4>
|
|
148 | 147 |
|
149 | 148 | loadChart() {
|
150 | 149 | $.getJSON('/{{ request()->path() }}/api/'+this.app.id+'/statistics', (data) => {
|
151 |
| - this.chart = $('#statisticsChart').epoch({ |
152 |
| - type: 'time.line', |
153 |
| - axes: ['left', 'right', 'bottom'], |
154 |
| - data: [ |
155 |
| - { |
156 |
| - label: "Peak Connections", |
157 |
| - values: data.peak_connections, |
158 |
| - } |
159 |
| - ] |
160 |
| - }); |
| 150 | + this.chart = Plotly.plot('statisticsChart', [{ |
| 151 | + x: data.peak_connections.x, |
| 152 | + y: data.peak_connections.y, |
| 153 | + mode: 'lines', |
| 154 | + line: {color: '#80CAF6'} |
| 155 | + }]); |
161 | 156 | });
|
162 | 157 | },
|
163 | 158 |
|
|
183 | 178 | subscribeToStatistics() {
|
184 | 179 | this.pusher.subscribe('{{ \BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger::LOG_CHANNEL_PREFIX }}statistics')
|
185 | 180 | .bind('statistics-updated', (data) => {
|
186 |
| - this.chart.push([{ |
187 |
| - time: data.time, |
188 |
| - y: data.peak_connection_count |
189 |
| - }]); |
| 181 | + var update = { |
| 182 | + x: [[data.time]], |
| 183 | + y: [[data.peak_connection_count]] |
| 184 | + }; |
| 185 | +
|
| 186 | + Plotly.extendTraces('statisticsChart', update, [0]); |
190 | 187 | });
|
191 | 188 | },
|
192 | 189 |
|
|
0 commit comments