rhoconnect 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +208 -0
- data/CREDITS +38 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +97 -0
- data/LICENSE +75 -0
- data/README.md +10 -0
- data/Rakefile +82 -0
- data/bench/bench +7 -0
- data/bench/bench_runner.rb +112 -0
- data/bench/benchapp/Gemfile +21 -0
- data/bench/benchapp/Gemfile.lock +76 -0
- data/bench/benchapp/Rakefile +22 -0
- data/bench/benchapp/application.rb +39 -0
- data/bench/benchapp/config.ru +36 -0
- data/bench/benchapp/settings/license.key +1 -0
- data/bench/benchapp/settings/settings.yml +20 -0
- data/bench/benchapp/sources/mock_adapter.rb +55 -0
- data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
- data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/spec_helper.rb +42 -0
- data/bench/blobapp/Gemfile +31 -0
- data/bench/blobapp/Gemfile.lock +103 -0
- data/bench/blobapp/Rakefile +25 -0
- data/bench/blobapp/application.rb +44 -0
- data/bench/blobapp/config.ru +36 -0
- data/bench/blobapp/settings/license.key +1 -0
- data/bench/blobapp/settings/settings.yml +16 -0
- data/bench/blobapp/sources/blob_adapter.rb +71 -0
- data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
- data/bench/blobapp/spec/spec_helper.rb +42 -0
- data/bench/lib/bench/cli.rb +16 -0
- data/bench/lib/bench/logging.rb +13 -0
- data/bench/lib/bench/mock_client.rb +41 -0
- data/bench/lib/bench/result.rb +50 -0
- data/bench/lib/bench/runner.rb +107 -0
- data/bench/lib/bench/session.rb +67 -0
- data/bench/lib/bench/statistics.rb +56 -0
- data/bench/lib/bench/test_data.rb +98 -0
- data/bench/lib/bench/timer.rb +10 -0
- data/bench/lib/bench/utils.rb +49 -0
- data/bench/lib/bench.rb +129 -0
- data/bench/lib/testdata/100-data.txt +148 -0
- data/bench/lib/testdata/5-data.txt +9 -0
- data/bench/lib/testdata/images/icon.ico +0 -0
- data/bench/lib/testdata/images/icon.png +0 -0
- data/bench/lib/testdata/images/loading-Landscape.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
- data/bench/lib/testdata/images/loading-Portrait.png +0 -0
- data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
- data/bench/lib/testdata/images/loading.png +0 -0
- data/bench/lib/testdata/images/loading@2x.png +0 -0
- data/bench/run_bench.sh +42 -0
- data/bench/run_blob_script.sh +3 -0
- data/bench/run_cud_script.sh +3 -0
- data/bench/run_query_md_script.sh +3 -0
- data/bench/run_query_only_script.sh +3 -0
- data/bench/run_query_script.sh +3 -0
- data/bench/scripts/blob_cud_script.rb +98 -0
- data/bench/scripts/cud_script.rb +92 -0
- data/bench/scripts/helpers.rb +101 -0
- data/bench/scripts/query_md_script.rb +45 -0
- data/bench/scripts/query_only_script.rb +51 -0
- data/bench/scripts/query_script.rb +45 -0
- data/bench/spec/bench_spec_helper.rb +33 -0
- data/bench/spec/logging_spec.rb +15 -0
- data/bench/spec/mock_adapter_spec.rb +61 -0
- data/bench/spec/mock_client_spec.rb +65 -0
- data/bench/spec/result_spec.rb +61 -0
- data/bench/spec/utils_spec.rb +36 -0
- data/bin/rhoconnect +34 -0
- data/bin/rhoconnect-setup +84 -0
- data/doc/async-jobs.txt +69 -0
- data/doc/authentication.txt +76 -0
- data/doc/benchmarks.txt +168 -0
- data/doc/blob-sync.txt +130 -0
- data/doc/bulk-sync.txt +102 -0
- data/doc/client.txt +432 -0
- data/doc/command-line.txt +210 -0
- data/doc/contributing.txt +60 -0
- data/doc/deploying.txt +82 -0
- data/doc/install.txt +28 -0
- data/doc/introduction.txt +20 -0
- data/doc/licensing.txt +18 -0
- data/doc/metadata.txt +458 -0
- data/doc/migration.txt +182 -0
- data/doc/public/css/print.css +29 -0
- data/doc/public/css/screen.css +257 -0
- data/doc/public/css/style.css +20 -0
- data/doc/push.txt +135 -0
- data/doc/release.txt +41 -0
- data/doc/rest-api.txt +367 -0
- data/doc/source-adapters.txt +325 -0
- data/doc/stats-middleware.txt +69 -0
- data/doc/testing.txt +222 -0
- data/doc/tutorial.txt +315 -0
- data/doc/web-console.txt +35 -0
- data/examples/simple/Rakefile +14 -0
- data/examples/simple/application.rb +27 -0
- data/examples/simple/config.ru +49 -0
- data/examples/simple/settings/license.key +1 -0
- data/examples/simple/settings/settings.yml +23 -0
- data/examples/simple/sources/sample_adapter.rb +5 -0
- data/examples/simple/sources/simple_adapter.rb +5 -0
- data/generators/rhoconnect.rb +119 -0
- data/generators/templates/application/Gemfile +21 -0
- data/generators/templates/application/Rakefile +22 -0
- data/generators/templates/application/application.rb +39 -0
- data/generators/templates/application/config.ru +36 -0
- data/generators/templates/application/settings/license.key +1 -0
- data/generators/templates/application/settings/settings.yml +14 -0
- data/generators/templates/application/spec/spec_helper.rb +42 -0
- data/generators/templates/source/source_adapter.rb +47 -0
- data/generators/templates/source/source_spec.rb +25 -0
- data/install.sh +408 -0
- data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
- data/installer/unix-like/rho_connect_install_constants.rb +51 -0
- data/installer/unix-like/rho_connect_install_debian.rb +63 -0
- data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
- data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
- data/installer/unix-like/rho_connect_install_installers.rb +142 -0
- data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
- data/installer/unix-like/rho_connect_install_yum.rb +63 -0
- data/installer/unix-like/rhoinstaller.rb +89 -0
- data/installer/utils/create_texts.rb +366 -0
- data/installer/utils/install_test.rb +140 -0
- data/installer/windows/EnvVarUpdate.nsh +328 -0
- data/installer/windows/ServiceLib.nsh +369 -0
- data/installer/windows/configUi.ini +44 -0
- data/installer/windows/icon.ico +0 -0
- data/installer/windows/rhosync.nsi +418 -0
- data/installer/windows/uninstall.bat +7 -0
- data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
- data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
- data/lib/rhoconnect/api/admin/login.rb +6 -0
- data/lib/rhoconnect/api/admin/reset.rb +10 -0
- data/lib/rhoconnect/api/admin/stats.rb +21 -0
- data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
- data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
- data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
- data/lib/rhoconnect/api/application/clientregister.rb +6 -0
- data/lib/rhoconnect/api/application/clientreset.rb +6 -0
- data/lib/rhoconnect/api/application/query.rb +7 -0
- data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
- data/lib/rhoconnect/api/application/search.rb +6 -0
- data/lib/rhoconnect/api/client/create_client.rb +3 -0
- data/lib/rhoconnect/api/client/delete_client.rb +5 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
- data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
- data/lib/rhoconnect/api/client/list_clients.rb +3 -0
- data/lib/rhoconnect/api/client/ping.rb +7 -0
- data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
- data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
- data/lib/rhoconnect/api/source/list_sources.rb +15 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
- data/lib/rhoconnect/api/source/push_objects.rb +8 -0
- data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
- data/lib/rhoconnect/api/source/upload_file.rb +4 -0
- data/lib/rhoconnect/api/user/create_user.rb +7 -0
- data/lib/rhoconnect/api/user/delete_user.rb +9 -0
- data/lib/rhoconnect/api/user/list_users.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +4 -0
- data/lib/rhoconnect/api_token.rb +19 -0
- data/lib/rhoconnect/app.rb +76 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
- data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
- data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
- data/lib/rhoconnect/bulk_data.rb +2 -0
- data/lib/rhoconnect/client.rb +96 -0
- data/lib/rhoconnect/client_sync.rb +412 -0
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
- data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
- data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
- data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
- data/lib/rhoconnect/console/app/public/home.css +438 -0
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
- data/lib/rhoconnect/console/app/public/main.css +7 -0
- data/lib/rhoconnect/console/app/public/reset.css +76 -0
- data/lib/rhoconnect/console/app/public/style.css +2201 -0
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
- data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
- data/lib/rhoconnect/console/app/routes/client.rb +31 -0
- data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
- data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
- data/lib/rhoconnect/console/app/routes/home.rb +63 -0
- data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
- data/lib/rhoconnect/console/app/routes/user.rb +117 -0
- data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
- data/lib/rhoconnect/console/app/views/client.erb +30 -0
- data/lib/rhoconnect/console/app/views/content.erb +14 -0
- data/lib/rhoconnect/console/app/views/doc.erb +8 -0
- data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
- data/lib/rhoconnect/console/app/views/docs.erb +30 -0
- data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
- data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
- data/lib/rhoconnect/console/app/views/home.erb +24 -0
- data/lib/rhoconnect/console/app/views/index.erb +58 -0
- data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
- data/lib/rhoconnect/console/app/views/layout.erb +165 -0
- data/lib/rhoconnect/console/app/views/login.erb +26 -0
- data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
- data/lib/rhoconnect/console/app/views/ping.erb +28 -0
- data/lib/rhoconnect/console/app/views/result.erb +11 -0
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
- data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
- data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
- data/lib/rhoconnect/console/app/views/user.erb +29 -0
- data/lib/rhoconnect/console/app/views/users.erb +12 -0
- data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
- data/lib/rhoconnect/console/server.rb +32 -0
- data/lib/rhoconnect/console.rb +3 -0
- data/lib/rhoconnect/cors.rb +229 -0
- data/lib/rhoconnect/credential.rb +9 -0
- data/lib/rhoconnect/db_adapter.rb +46 -0
- data/lib/rhoconnect/document.rb +49 -0
- data/lib/rhoconnect/dynamic_adapter.rb +91 -0
- data/lib/rhoconnect/generator.rb +1 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
- data/lib/rhoconnect/jobs/ping_job.rb +46 -0
- data/lib/rhoconnect/jobs/source_job.rb +16 -0
- data/lib/rhoconnect/license.rb +86 -0
- data/lib/rhoconnect/lock_ops.rb +11 -0
- data/lib/rhoconnect/model.rb +414 -0
- data/lib/rhoconnect/ping/android.rb +56 -0
- data/lib/rhoconnect/ping/apple.rb +52 -0
- data/lib/rhoconnect/ping/blackberry.rb +56 -0
- data/lib/rhoconnect/ping.rb +3 -0
- data/lib/rhoconnect/read_state.rb +31 -0
- data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
- data/lib/rhoconnect/server/views/index.erb +13 -0
- data/lib/rhoconnect/server.rb +286 -0
- data/lib/rhoconnect/source.rb +289 -0
- data/lib/rhoconnect/source_adapter.rb +123 -0
- data/lib/rhoconnect/source_sync.rb +302 -0
- data/lib/rhoconnect/stats/middleware.rb +20 -0
- data/lib/rhoconnect/stats/record.rb +108 -0
- data/lib/rhoconnect/store.rb +232 -0
- data/lib/rhoconnect/tasks.rb +350 -0
- data/lib/rhoconnect/test_methods.rb +220 -0
- data/lib/rhoconnect/user.rb +95 -0
- data/lib/rhoconnect/version.rb +3 -0
- data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
- data/lib/rhoconnect.rb +285 -0
- data/rhoconnect.gemspec +67 -0
- data/spec/api/admin/api_token_spec.rb +14 -0
- data/spec/api/admin/get_api_token_spec.rb +36 -0
- data/spec/api/admin/get_license_info_spec.rb +38 -0
- data/spec/api/admin/reset_spec.rb +22 -0
- data/spec/api/admin/stats_spec.rb +66 -0
- data/spec/api/api_helper.rb +21 -0
- data/spec/api/application/rhoconnect_api_spec.rb +548 -0
- data/spec/api/client/create_client_spec.rb +13 -0
- data/spec/api/client/delete_client_spec.rb +13 -0
- data/spec/api/client/get_client_params_spec.rb +18 -0
- data/spec/api/client/list_client_docs_spec.rb +32 -0
- data/spec/api/client/list_clients_spec.rb +22 -0
- data/spec/api/client/ping_spec.rb +23 -0
- data/spec/api/rhosync_api_spec.rb.orig +606 -0
- data/spec/api/source/adapter_spec.rb +29 -0
- data/spec/api/source/get_db_doc_spec.rb +21 -0
- data/spec/api/source/get_source_params_spec.rb +32 -0
- data/spec/api/source/list_source_docs_spec.rb +25 -0
- data/spec/api/source/list_sources_spec.rb +26 -0
- data/spec/api/source/push_deletes_spec.rb +18 -0
- data/spec/api/source/push_objects_spec.rb +27 -0
- data/spec/api/source/set_db_doc_spec.rb +19 -0
- data/spec/api/source/set_refresh_time_spec.rb +43 -0
- data/spec/api/source/upload_file_spec.rb +26 -0
- data/spec/api/user/create_user_spec.rb +16 -0
- data/spec/api/user/delete_user_spec.rb +36 -0
- data/spec/api/user/list_users_spec.rb +30 -0
- data/spec/api/user/update_user_spec.rb +31 -0
- data/spec/api_token_spec.rb +14 -0
- data/spec/app_spec.rb +18 -0
- data/spec/apps/emptyapp/application.rb +27 -0
- data/spec/apps/emptyapp/settings/license.key +1 -0
- data/spec/apps/emptyapp/settings/settings.yml +14 -0
- data/spec/apps/rhotestapp/Rakefile +1 -0
- data/spec/apps/rhotestapp/application.rb +19 -0
- data/spec/apps/rhotestapp/config.ru +1 -0
- data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
- data/spec/apps/rhotestapp/settings/license.key +1 -0
- data/spec/apps/rhotestapp/settings/settings.yml +36 -0
- data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
- data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
- data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
- data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
- data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
- data/spec/bulk_data/bulk_data_spec.rb +97 -0
- data/spec/client_spec.rb +124 -0
- data/spec/client_sync_spec.rb +774 -0
- data/spec/doc/base.html +72 -0
- data/spec/doc/doc_spec.rb +376 -0
- data/spec/doc/footer.html +4 -0
- data/spec/doc/header.html +30 -0
- data/spec/document_spec.rb +31 -0
- data/spec/dynamic_adapter_spec.rb +43 -0
- data/spec/factories/factories.rb +17 -0
- data/spec/generator/generator_spec.rb +58 -0
- data/spec/generator/generator_spec_helper.rb +9 -0
- data/spec/jobs/bulk_data_job_spec.rb +125 -0
- data/spec/jobs/ping_job_spec.rb +102 -0
- data/spec/jobs/source_job_spec.rb +29 -0
- data/spec/license_spec.rb +66 -0
- data/spec/model_spec.rb +273 -0
- data/spec/perf/bulk_data_perf_spec.rb +32 -0
- data/spec/perf/perf_spec_helper.rb +50 -0
- data/spec/perf/store_perf_spec.rb +27 -0
- data/spec/ping/android_spec.rb +91 -0
- data/spec/ping/apple_spec.rb +70 -0
- data/spec/ping/blackberry_spec.rb +62 -0
- data/spec/read_state_spec.rb +35 -0
- data/spec/rhosync_spec.rb +75 -0
- data/spec/server/cors_spec.rb +287 -0
- data/spec/server/server_spec.rb +470 -0
- data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
- data/spec/source_adapter_spec.rb +125 -0
- data/spec/source_spec.rb +114 -0
- data/spec/source_sync_spec.rb +328 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +231 -0
- data/spec/stats/middleware_spec.rb +53 -0
- data/spec/stats/record_spec.rb +92 -0
- data/spec/store_spec.rb +251 -0
- data/spec/support/shared_examples.rb +168 -0
- data/spec/sync_states_spec.rb +72 -0
- data/spec/test_methods_spec.rb +134 -0
- data/spec/testdata/1000-data.txt +1414 -0
- data/spec/testdata/compressed/compress-data.txt +1 -0
- data/spec/testdata/upload1.txt +1 -0
- data/spec/testdata/upload2.txt +1 -0
- data/spec/user_spec.rb +139 -0
- data/tasks/redis.rake +206 -0
- metadata +706 -0
@@ -0,0 +1,187 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 - 2010 Chris Leonello
|
3
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
4
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
5
|
+
* choose the license that best suits your project and use it accordingly.
|
6
|
+
*
|
7
|
+
* The author would appreciate an email letting him know of any substantial
|
8
|
+
* use of jqPlot. You can reach the author at: chris at jqplot dot com
|
9
|
+
* or see http://www.jqplot.com/info.php . This is, of course,
|
10
|
+
* not required.
|
11
|
+
*
|
12
|
+
* If you are feeling kind and generous, consider supporting the project by
|
13
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
14
|
+
*
|
15
|
+
* Thanks for using jqPlot!
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
(function($) {
|
19
|
+
/**
|
20
|
+
* Class: $.jqplot.CanvasAxisLabelRenderer
|
21
|
+
* Renderer to draw axis labels with a canvas element to support advanced
|
22
|
+
* featrues such as rotated text. This renderer uses a separate rendering engine
|
23
|
+
* to draw the text on the canvas. Two modes of rendering the text are available.
|
24
|
+
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
25
|
+
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
26
|
+
* You do so by setting the "enableFontSupport" option to true.
|
27
|
+
*
|
28
|
+
* Browsers lacking native font support will have the text drawn on the canvas
|
29
|
+
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
30
|
+
* non-supporting browsers will still render with the Hershey font.
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
$.jqplot.CanvasAxisLabelRenderer = function(options) {
|
34
|
+
// Group: Properties
|
35
|
+
|
36
|
+
// prop: angle
|
37
|
+
// angle of text, measured clockwise from x axis.
|
38
|
+
this.angle = 0;
|
39
|
+
// name of the axis associated with this tick
|
40
|
+
this.axis;
|
41
|
+
// prop: show
|
42
|
+
// wether or not to show the tick (mark and label).
|
43
|
+
this.show = true;
|
44
|
+
// prop: showLabel
|
45
|
+
// wether or not to show the label.
|
46
|
+
this.showLabel = true;
|
47
|
+
// prop: label
|
48
|
+
// label for the axis.
|
49
|
+
this.label = '';
|
50
|
+
// prop: fontFamily
|
51
|
+
// CSS spec for the font-family css attribute.
|
52
|
+
// Applies only to browsers supporting native font rendering in the
|
53
|
+
// canvas tag. Currently Mozilla 3.5 and Safari 4.
|
54
|
+
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
55
|
+
// prop: fontSize
|
56
|
+
// CSS spec for font size.
|
57
|
+
this.fontSize = '11pt';
|
58
|
+
// prop: fontWeight
|
59
|
+
// CSS spec for fontWeight: normal, bold, bolder, lighter or a number 100 - 900
|
60
|
+
this.fontWeight = 'normal';
|
61
|
+
// prop: fontStretch
|
62
|
+
// Multiplier to condense or expand font width.
|
63
|
+
// Applies only to browsers which don't support canvas native font rendering.
|
64
|
+
this.fontStretch = 1.0;
|
65
|
+
// prop: textColor
|
66
|
+
// css spec for the color attribute.
|
67
|
+
this.textColor = '#666666';
|
68
|
+
// prop: enableFontSupport
|
69
|
+
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
70
|
+
// If true, label will be drawn with canvas tag native support for fonts.
|
71
|
+
// If false, label will be drawn with Hershey font metrics.
|
72
|
+
this.enableFontSupport = true;
|
73
|
+
// prop: pt2px
|
74
|
+
// Point to pixel scaling factor, used for computing height of bounding box
|
75
|
+
// around a label. The labels text renderer has a default setting of 1.4, which
|
76
|
+
// should be suitable for most fonts. Leave as null to use default. If tops of
|
77
|
+
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
78
|
+
// This is an issue only with the native font renderering capabilities of Mozilla
|
79
|
+
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
80
|
+
this.pt2px = null;
|
81
|
+
|
82
|
+
this._elem;
|
83
|
+
this._ctx;
|
84
|
+
this._plotWidth;
|
85
|
+
this._plotHeight;
|
86
|
+
this._plotDimensions = {height:null, width:null};
|
87
|
+
|
88
|
+
$.extend(true, this, options);
|
89
|
+
|
90
|
+
if (options.angle == null && this.axis != 'xaxis' && this.axis != 'x2axis') {
|
91
|
+
this.angle = -90;
|
92
|
+
}
|
93
|
+
|
94
|
+
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
95
|
+
if (this.pt2px) {
|
96
|
+
ropts.pt2px = this.pt2px;
|
97
|
+
}
|
98
|
+
|
99
|
+
if (this.enableFontSupport) {
|
100
|
+
|
101
|
+
function support_canvas_text() {
|
102
|
+
return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
|
103
|
+
}
|
104
|
+
|
105
|
+
if (support_canvas_text()) {
|
106
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
107
|
+
}
|
108
|
+
|
109
|
+
else {
|
110
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.init = function(options) {
|
119
|
+
$.extend(true, this, options);
|
120
|
+
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
121
|
+
};
|
122
|
+
|
123
|
+
// return width along the x axis
|
124
|
+
// will check first to see if an element exists.
|
125
|
+
// if not, will return the computed text box width.
|
126
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getWidth = function(ctx) {
|
127
|
+
if (this._elem) {
|
128
|
+
return this._elem.outerWidth(true);
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
var tr = this._textRenderer;
|
132
|
+
var l = tr.getWidth(ctx);
|
133
|
+
var h = tr.getHeight(ctx);
|
134
|
+
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
135
|
+
return w;
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
// return height along the y axis.
|
140
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getHeight = function(ctx) {
|
141
|
+
if (this._elem) {
|
142
|
+
return this._elem.outerHeight(true);
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
var tr = this._textRenderer;
|
146
|
+
var l = tr.getWidth(ctx);
|
147
|
+
var h = tr.getHeight(ctx);
|
148
|
+
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
149
|
+
return w;
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.getAngleRad = function() {
|
154
|
+
var a = this.angle * Math.PI/180;
|
155
|
+
return a;
|
156
|
+
};
|
157
|
+
|
158
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.draw = function(ctx) {
|
159
|
+
// create a canvas here, but can't draw on it untill it is appended
|
160
|
+
// to dom for IE compatability.
|
161
|
+
var domelem = document.createElement('canvas');
|
162
|
+
this._textRenderer.setText(this.label, ctx);
|
163
|
+
var w = this.getWidth(ctx);
|
164
|
+
var h = this.getHeight(ctx);
|
165
|
+
domelem.width = w;
|
166
|
+
domelem.height = h;
|
167
|
+
domelem.style.width = w;
|
168
|
+
domelem.style.height = h;
|
169
|
+
// domelem.style.textAlign = 'center';
|
170
|
+
domelem.style.position = 'absolute';
|
171
|
+
this._domelem = domelem;
|
172
|
+
this._elem = $(domelem);
|
173
|
+
this._elem.addClass('jqplot-'+this.axis+'-label');
|
174
|
+
|
175
|
+
return this._elem;
|
176
|
+
};
|
177
|
+
|
178
|
+
$.jqplot.CanvasAxisLabelRenderer.prototype.pack = function() {
|
179
|
+
if ($.browser.msie) {
|
180
|
+
window.G_vmlCanvasManager.init_(document);
|
181
|
+
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
182
|
+
}
|
183
|
+
var ctx = this._elem.get(0).getContext("2d");
|
184
|
+
this._textRenderer.draw(ctx, this.label);
|
185
|
+
};
|
186
|
+
|
187
|
+
})(jQuery);
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 - 2010 Chris Leonello
|
3
|
+
* jqPlot is currently available for use in all personal or commercial projects
|
4
|
+
* under both the MIT and GPL version 2.0 licenses. This means that you can
|
5
|
+
* choose the license that best suits your project and use it accordingly.
|
6
|
+
*
|
7
|
+
* The author would appreciate an email letting him know of any substantial
|
8
|
+
* use of jqPlot. You can reach the author at: chris at jqplot dot com
|
9
|
+
* or see http://www.jqplot.com/info.php . This is, of course,
|
10
|
+
* not required.
|
11
|
+
*
|
12
|
+
* If you are feeling kind and generous, consider supporting the project by
|
13
|
+
* making a donation at: http://www.jqplot.com/donate.php .
|
14
|
+
*
|
15
|
+
* Thanks for using jqPlot!
|
16
|
+
*
|
17
|
+
*/
|
18
|
+
(function($) {
|
19
|
+
/**
|
20
|
+
* Class: $.jqplot.CanvasAxisTickRenderer
|
21
|
+
* Renderer to draw axis ticks with a canvas element to support advanced
|
22
|
+
* featrues such as rotated text. This renderer uses a separate rendering engine
|
23
|
+
* to draw the text on the canvas. Two modes of rendering the text are available.
|
24
|
+
* If the browser has native font support for canvas fonts (currently Mozila 3.5
|
25
|
+
* and Safari 4), you can enable text rendering with the canvas fillText method.
|
26
|
+
* You do so by setting the "enableFontSupport" option to true.
|
27
|
+
*
|
28
|
+
* Browsers lacking native font support will have the text drawn on the canvas
|
29
|
+
* using the Hershey font metrics. Even if the "enableFontSupport" option is true
|
30
|
+
* non-supporting browsers will still render with the Hershey font.
|
31
|
+
*/
|
32
|
+
$.jqplot.CanvasAxisTickRenderer = function(options) {
|
33
|
+
// Group: Properties
|
34
|
+
|
35
|
+
// prop: mark
|
36
|
+
// tick mark on the axis. One of 'inside', 'outside', 'cross', '' or null.
|
37
|
+
this.mark = 'outside';
|
38
|
+
// prop: showMark
|
39
|
+
// wether or not to show the mark on the axis.
|
40
|
+
this.showMark = true;
|
41
|
+
// prop: showGridline
|
42
|
+
// wether or not to draw the gridline on the grid at this tick.
|
43
|
+
this.showGridline = true;
|
44
|
+
// prop: isMinorTick
|
45
|
+
// if this is a minor tick.
|
46
|
+
this.isMinorTick = false;
|
47
|
+
// prop: angle
|
48
|
+
// angle of text, measured clockwise from x axis.
|
49
|
+
this.angle = 0;
|
50
|
+
// prop: markSize
|
51
|
+
// Length of the tick marks in pixels. For 'cross' style, length
|
52
|
+
// will be stoked above and below axis, so total length will be twice this.
|
53
|
+
this.markSize = 4;
|
54
|
+
// prop: show
|
55
|
+
// wether or not to show the tick (mark and label).
|
56
|
+
this.show = true;
|
57
|
+
// prop: showLabel
|
58
|
+
// wether or not to show the label.
|
59
|
+
this.showLabel = true;
|
60
|
+
// prop: labelPosition
|
61
|
+
// 'auto', 'start', 'middle' or 'end'.
|
62
|
+
// Whether tick label should be positioned so the start, middle, or end
|
63
|
+
// of the tick mark.
|
64
|
+
this.labelPosition = 'auto';
|
65
|
+
this.label = '';
|
66
|
+
this.value = null;
|
67
|
+
this._styles = {};
|
68
|
+
// prop: formatter
|
69
|
+
// A class of a formatter for the tick text.
|
70
|
+
// The default $.jqplot.DefaultTickFormatter uses sprintf.
|
71
|
+
this.formatter = $.jqplot.DefaultTickFormatter;
|
72
|
+
// prop: formatString
|
73
|
+
// string passed to the formatter.
|
74
|
+
this.formatString = '';
|
75
|
+
// prop: prefix
|
76
|
+
// string appended to the tick label if no formatString is specified.
|
77
|
+
this.prefix = '';
|
78
|
+
// prop: fontFamily
|
79
|
+
// css spec for the font-family css attribute.
|
80
|
+
this.fontFamily = '"Trebuchet MS", Arial, Helvetica, sans-serif';
|
81
|
+
// prop: fontSize
|
82
|
+
// CSS spec for font size.
|
83
|
+
this.fontSize = '10pt';
|
84
|
+
// prop: fontWeight
|
85
|
+
// CSS spec for fontWeight
|
86
|
+
this.fontWeight = 'normal';
|
87
|
+
// prop: fontStretch
|
88
|
+
// Multiplier to condense or expand font width.
|
89
|
+
// Applies only to browsers which don't support canvas native font rendering.
|
90
|
+
this.fontStretch = 1.0;
|
91
|
+
// prop: textColor
|
92
|
+
// css spec for the color attribute.
|
93
|
+
this.textColor = '#666666';
|
94
|
+
// prop: enableFontSupport
|
95
|
+
// true to turn on native canvas font support in Mozilla 3.5+ and Safari 4+.
|
96
|
+
// If true, tick label will be drawn with canvas tag native support for fonts.
|
97
|
+
// If false, tick label will be drawn with Hershey font metrics.
|
98
|
+
this.enableFontSupport = true;
|
99
|
+
// prop: pt2px
|
100
|
+
// Point to pixel scaling factor, used for computing height of bounding box
|
101
|
+
// around a label. The labels text renderer has a default setting of 1.4, which
|
102
|
+
// should be suitable for most fonts. Leave as null to use default. If tops of
|
103
|
+
// letters appear clipped, increase this. If bounding box seems too big, decrease.
|
104
|
+
// This is an issue only with the native font renderering capabilities of Mozilla
|
105
|
+
// 3.5 and Safari 4 since they do not provide a method to determine the font height.
|
106
|
+
this.pt2px = null;
|
107
|
+
|
108
|
+
this._elem;
|
109
|
+
this._ctx;
|
110
|
+
this._plotWidth;
|
111
|
+
this._plotHeight;
|
112
|
+
this._plotDimensions = {height:null, width:null};
|
113
|
+
|
114
|
+
$.extend(true, this, options);
|
115
|
+
|
116
|
+
var ropts = {fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily};
|
117
|
+
if (this.pt2px) {
|
118
|
+
ropts.pt2px = this.pt2px;
|
119
|
+
}
|
120
|
+
|
121
|
+
if (this.enableFontSupport) {
|
122
|
+
|
123
|
+
function support_canvas_text() {
|
124
|
+
return !!(document.createElement('canvas').getContext && typeof document.createElement('canvas').getContext('2d').fillText == 'function');
|
125
|
+
}
|
126
|
+
|
127
|
+
if (support_canvas_text()) {
|
128
|
+
this._textRenderer = new $.jqplot.CanvasFontRenderer(ropts);
|
129
|
+
}
|
130
|
+
|
131
|
+
else {
|
132
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
else {
|
136
|
+
this._textRenderer = new $.jqplot.CanvasTextRenderer(ropts);
|
137
|
+
}
|
138
|
+
};
|
139
|
+
|
140
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.init = function(options) {
|
141
|
+
$.extend(true, this, options);
|
142
|
+
this._textRenderer.init({fontSize:this.fontSize, fontWeight:this.fontWeight, fontStretch:this.fontStretch, fillStyle:this.textColor, angle:this.getAngleRad(), fontFamily:this.fontFamily});
|
143
|
+
};
|
144
|
+
|
145
|
+
// return width along the x axis
|
146
|
+
// will check first to see if an element exists.
|
147
|
+
// if not, will return the computed text box width.
|
148
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getWidth = function(ctx) {
|
149
|
+
if (this._elem) {
|
150
|
+
return this._elem.outerWidth(true);
|
151
|
+
}
|
152
|
+
else {
|
153
|
+
var tr = this._textRenderer;
|
154
|
+
var l = tr.getWidth(ctx);
|
155
|
+
var h = tr.getHeight(ctx);
|
156
|
+
var w = Math.abs(Math.sin(tr.angle)*h) + Math.abs(Math.cos(tr.angle)*l);
|
157
|
+
return w;
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
// return height along the y axis.
|
162
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getHeight = function(ctx) {
|
163
|
+
if (this._elem) {
|
164
|
+
return this._elem.outerHeight(true);
|
165
|
+
}
|
166
|
+
else {
|
167
|
+
var tr = this._textRenderer;
|
168
|
+
var l = tr.getWidth(ctx);
|
169
|
+
var h = tr.getHeight(ctx);
|
170
|
+
var w = Math.abs(Math.cos(tr.angle)*h) + Math.abs(Math.sin(tr.angle)*l);
|
171
|
+
return w;
|
172
|
+
}
|
173
|
+
};
|
174
|
+
|
175
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.getAngleRad = function() {
|
176
|
+
var a = this.angle * Math.PI/180;
|
177
|
+
return a;
|
178
|
+
};
|
179
|
+
|
180
|
+
|
181
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.setTick = function(value, axisName, isMinor) {
|
182
|
+
this.value = value;
|
183
|
+
if (isMinor) {
|
184
|
+
this.isMinorTick = true;
|
185
|
+
}
|
186
|
+
return this;
|
187
|
+
};
|
188
|
+
|
189
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.draw = function(ctx) {
|
190
|
+
if (!this.label) {
|
191
|
+
this.label = this.formatter(this.formatString, this.value);
|
192
|
+
}
|
193
|
+
// add prefix if needed
|
194
|
+
if (this.prefix && !this.formatString) {
|
195
|
+
this.label = this.prefix + this.label;
|
196
|
+
}
|
197
|
+
// create a canvas here, but can't draw on it untill it is appended
|
198
|
+
// to dom for IE compatability.
|
199
|
+
var domelem = document.createElement('canvas');
|
200
|
+
this._textRenderer.setText(this.label, ctx);
|
201
|
+
var w = this.getWidth(ctx);
|
202
|
+
var h = this.getHeight(ctx);
|
203
|
+
domelem.width = w;
|
204
|
+
domelem.height = h;
|
205
|
+
domelem.style.width = w;
|
206
|
+
domelem.style.height = h;
|
207
|
+
domelem.style.textAlign = 'left';
|
208
|
+
domelem.style.position = 'absolute';
|
209
|
+
this._domelem = domelem;
|
210
|
+
this._elem = $(domelem);
|
211
|
+
this._elem.css(this._styles);
|
212
|
+
this._elem.addClass('jqplot-'+this.axis+'-tick');
|
213
|
+
|
214
|
+
return this._elem;
|
215
|
+
};
|
216
|
+
|
217
|
+
$.jqplot.CanvasAxisTickRenderer.prototype.pack = function() {
|
218
|
+
if ($.browser.msie) {
|
219
|
+
window.G_vmlCanvasManager.init_(document);
|
220
|
+
this._domelem = window.G_vmlCanvasManager.initElement(this._domelem);
|
221
|
+
}
|
222
|
+
var ctx = this._elem.get(0).getContext("2d");
|
223
|
+
this._textRenderer.draw(ctx, this.label);
|
224
|
+
};
|
225
|
+
|
226
|
+
})(jQuery);
|