Migrations
3 years ago
ajax
3 years ago
models
3 years ago
queries
3 years ago
sql
3 years ago
tables
3 years ago
utils
3 years ago
campaign_builder.php
3 years ago
capability_manager.php
3 years ago
chart.php
3 years ago
chart_geo.php
3 years ago
chart_svg.php
3 years ago
dashboard_options.php
3 years ago
dashboard_widget.php
3 years ago
email_reports.php
3 years ago
filters.php
3 years ago
freemius.php
3 years ago
geo_database.php
3 years ago
geo_database_download_job.php
3 years ago
health_check.php
3 years ago
independent_analytics.php
3 years ago
known_referrers.php
3 years ago
pdf.php
3 years ago
query.php
3 years ago
quick_stats.php
3 years ago
real_time.php
3 years ago
rest_api.php
3 years ago
settings.php
3 years ago
track_resource_changes.php
3 years ago
view_counter.php
3 years ago
chart_geo.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | class Chart_Geo |
| 6 | { |
| 7 | private $geos; |
| 8 | private $title; |
| 9 | |
| 10 | public function __construct($geos, $title = null) |
| 11 | { |
| 12 | $this->geos = $geos; |
| 13 | $this->title = $title; |
| 14 | } |
| 15 | |
| 16 | public function get_html() |
| 17 | { |
| 18 | $chart_data = array_map(function ($geo) { |
| 19 | return [$geo->country(), $geo->views(), $geo->visitors()]; |
| 20 | }, $this->geos->fetch()); |
| 21 | |
| 22 | ob_start(); ?> |
| 23 | <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> |
| 24 | <div class="chart-container"> |
| 25 | <div class="chart-inner"> |
| 26 | <div class="legend-container"> |
| 27 | <h2 class="legend-title"><?php echo $this->title ?></h2> |
| 28 | </div> |
| 29 | <div id="myChart" |
| 30 | data-controller="chart-geo" |
| 31 | data-chart-geo-data-value="<?php esc_attr_e(json_encode($chart_data)) ?>" |
| 32 | data-chart-geo-dark-mode-value="<?php esc_attr_e((int) IAWP()->get_option('iawp_dark_mode', false)) ?>"> |
| 33 | <div data-chart-geo-target="chart"></div> |
| 34 | </div> |
| 35 | </div> |
| 36 | </div><?php |
| 37 | |
| 38 | $html = ob_get_contents(); |
| 39 | ob_end_clean(); |
| 40 | |
| 41 | return $html; |
| 42 | } |
| 43 | } |
| 44 |