{"id":1001,"date":"2014-05-13T12:27:42","date_gmt":"2014-05-13T10:27:42","guid":{"rendered":"http:\/\/www.speich.net\/articles\/?p=1001"},"modified":"2019-10-06T11:49:35","modified_gmt":"2019-10-06T09:49:35","slug":"how-to-import-c3-js-with-the-dojo-amd-loader","status":"publish","type":"post","link":"https:\/\/www.speich.net\/articles\/en\/2014\/05\/13\/how-to-import-c3-js-with-the-dojo-amd-loader\/","title":{"rendered":"How to import c3.js with the dojo AMD loader"},"content":{"rendered":"\n<p>I came across the nice chart library <a title=\"c3.js\" href=\"http:\/\/c3js.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">c3.js<\/a>, which is based on <a title=\"d3.js\" href=\"http:\/\/d3js.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">d3.js<\/a>. In order to load it via an AMD require call with dojo, you also need to set the <a title=\"AMD Module identifiers\" href=\"http:\/\/dojotoolkit.org\/reference-guide\/1.9\/loader\/amd.html#id6\" target=\"_blank\" rel=\"noopener noreferrer\">main property<\/a> in the dojoConfig, e.g.:<\/p>\n\n\n\n<pre><code class=\"language-javascript\">dojoConfig = {\n    packages: [\n        { name: 'd3', location: '..\/..\/..\/d3', main: 'd3' }\n        { name: 'c3', location: '..\/..\/..\/c3', main: 'c3' }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>This will let you load c3.js in your module, e.g.:<\/p>\n\n\n\n<pre><code class=\"language-javascript\">define(['d3', 'c3', ...], function(d3, c3, ...) {\n    ...\n}<\/code><pre>\n","protected":false},"excerpt":{"rendered":"<p>I came across the nice chart library c3.js, which is based on d3.js. In order to load it via an AMD require call with dojo, you also need to set the main property in the dojoConfig, e.g.: dojoConfig = { packages: [ { name: &#8216;d3&#8217;, location: &#8216;..\/..\/..\/d3&#8217;, main: &#8216;d3&#8217; } { name: &#8216;c3&#8217;, location: &#8216;..\/..\/..\/c3&#8217;, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.speich.net\/articles\/en\/2014\/05\/13\/how-to-import-c3-js-with-the-dojo-amd-loader\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to import c3.js with the dojo AMD loader&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,14,21,26],"class_list":["post-1001","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-amd","tag-c3js","tag-d3js","tag-dojo","entry"],"_links":{"self":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/comments?post=1001"}],"version-history":[{"count":1,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1001\/revisions"}],"predecessor-version":[{"id":1671,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1001\/revisions\/1671"}],"wp:attachment":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/media?parent=1001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/categories?post=1001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/tags?post=1001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}