Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate dashboard chart from Raphael to Chartist (#406) #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jquery": true
},
"globals": {
"Raphael": "readonly",
"Chartist": "readonly",
"getAnchors": "readonly"
},
"rules": {
Expand Down
30 changes: 21 additions & 9 deletions antispam_bee.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,26 @@ public static function add_dashboard_chart() {
public static function add_dashboard_style() {
$plugin = get_plugin_data( __FILE__ );

wp_register_style(
'chartist_css',
plugins_url( '/css/chartist.min.css', __FILE__ ),
array(),
'1.3.0'
);
wp_register_style(
'chartist_tooltip_css',
plugins_url( '/css/chartist-plugin-tooltip.min.css', __FILE__ ),
array(),
'1.0.0'
);
wp_register_style(
'ab_chart',
plugins_url( 'css/dashboard.min.css', __FILE__ ),
array(),
$plugin['Version']
);

wp_print_styles( 'ab_chart' );
wp_print_styles( array( 'chartist_css', 'chartist_tooltip_css', 'ab_chart' ) );
}


Expand All @@ -835,25 +847,25 @@ public static function add_dashboard_script() {
$plugin = get_plugin_data( __FILE__ );

wp_enqueue_script(
'raphael',
plugins_url( 'js/raphael.min.js', __FILE__ ),
'chartist_js',
plugins_url( 'js/chartist.min.js', __FILE__ ),
array(),
'2.1.0',
'1.3.0',
true
);

wp_enqueue_script(
'ab-raphael',
plugins_url( 'js/raphael.helper.min.js', __FILE__ ),
array( 'raphael' ),
$plugin['Version'],
'chartist_tooltip_js',
plugins_url( 'js/chartist-plugin-tooltip.min.js', __FILE__ ),
array( 'chartist_js' ),
'1.0.0',
true
);

wp_enqueue_script(
'ab_chart_js',
plugins_url( 'js/dashboard.min.js', __FILE__ ),
array( 'jquery', 'ab-raphael' ),
array( 'jquery', 'chartist_js' ),
$plugin['Version'],
true
);
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"npx stylelint css/dashboard.css css/styles.css"
],
"lint-js": [
"npx eslint js/dashboard.js js/raphael.helper.js js/scripts.js"
"npx eslint js/dashboard.js js/scripts.js"
],
"lint-php": [
"phpcs --standard=phpcs.xml -s"
Expand All @@ -78,7 +78,6 @@
"minifycss css/dashboard.css > css/dashboard.min.css",
"minifycss css/styles.css > css/styles.min.css",
"minifyjs js/dashboard.js > js/dashboard.min.js",
"minifyjs js/raphael.helper.js > js/raphael.helper.min.js",
"minifyjs js/scripts.js > js/scripts.min.js"
]
}
Expand Down
1 change: 1 addition & 0 deletions css/chartist-plugin-tooltip.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions css/chartist.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions css/dashboard.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
#ab_chart {
color: #a7aaad;
flex: 0 0 100%;
direction: rtl;
height: 140px;
margin: 0 -4px;
overflow-x: auto;
overflow-y: hidden;
text-align: center;
}

#ab_chart .ct-label.ct-vertical.ct-start {
justify-content: flex-start;
text-align: left;
text-anchor: start;
}

#ab_chart .ct-line {
stroke: #3582c4;
stroke-width: 2px;
}

#ab_chart .ct-point {
fill: #fff;
stroke: #3582c4;
stroke-width: 1.5px;
}

#ab_chart .ct-area {
fill: #3582c4;
}

.ab-chartist-tooltip {
border: 1px solid #000;
background-color: #fff;
border-radius: 0.2em;
padding: 0.1em 0.5em;
}

.ab-chartist-tooltip::before {
border-top-color: #0009;
}

.ab-chartist-tooltip .chartist-tooltip-meta {
color: #3582c4;
}

#ab_chart_data {
display: none;
}
Expand Down
7 changes: 7 additions & 0 deletions js/chartist-plugin-tooltip.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/chartist.min.js

Large diffs are not rendered by default.

Loading