{"id":12418,"date":"2014-08-19T11:00:09","date_gmt":"2014-08-19T09:00:09","guid":{"rendered":"https:\/\/blog.trifork.com\/?p=12418"},"modified":"2014-08-19T11:00:09","modified_gmt":"2014-08-19T09:00:09","slug":"angularjs-directives-for-c3-js-chart-library","status":"publish","type":"post","link":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/","title":{"rendered":"AngularJS directives for C3.js chart library"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" style=\"float: left;margin-right: 10px\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png\" alt=\"Vagrant Logo\" width=\"95\" height=\"95\"><\/p>\n<p>For one of our projects we wanted to create some nice charts. Feels like something you often want but do not do because it takes to much time. This time we really needed it. I had prior experience with <a href=\"http:\/\/www.highcharts.com\">Highcharts<\/a>, which is also a nice library. But this time we wanted more control. We had a look at D3.js library, a very nice library but so many options and a lot to do yourself. Than we found c3.js, check the blog post by Roberto: <a href=\"https:\/\/blog.trifork.com\/2014\/07\/29\/creating-charts-with-c3-js\/\">Creating charts with C3.js<\/a>. Since I do a lot with AngularJS, I wanted to integrate these c3.js charts with AngularJS. I wrote another blogpost on that: <a href=\"http:\/\/www.gridshore.nl\/2014\/07\/29\/using-c3js-angularjs\/\">Using C3js with AngularJS<\/a>. Through twitter Abdullah Diaa mentioned that it would be great to have directives for these charts. That is were we start in this blogpost. I am going to describe the first version of a directive I have created to make it even easier to create these chart using AngularJS.<\/p>\n<p><!--more--><\/p>\n<h2>Using the directive<\/h2>\n<p>The goal for the Angularjs directive is to come up with some sort of DSL in the HTML language for creating charts with c3.js. I will go though the different aspects of creating a chart.<\/p>\n<p>You do not need a webserver to run the samples, the easiest way is to <a href=\"https:\/\/github.com\/jettro\/c3-angular-sample\">clone the repository from github<\/a> or download the zip.<\/p>\n<h3>The html page<\/h3>\n<p>When using a directive, you need to load some javascript libraries on your html page. We need the d3.js, c3.js and the angularjs libraries. Of course we need the directive javascript file and we need to initialise our AngularJS application. The following code block shows this code as well as the most basic chart.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;!doctype html&amp;gt;&lt;br&gt;\n&amp;lt;html ng-app=&quot;graphApp&quot;&amp;gt;&lt;br&gt;\n&amp;lt;head&amp;gt;&lt;br&gt;\n\t&amp;lt;meta charset=&quot;utf-8&quot;&amp;gt;&lt;\/p&gt;\n&lt;p&gt;\t&amp;lt;link href=&quot;css\/c3-0.2.4.css&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot;&amp;gt;&lt;br&gt;\n&amp;lt;\/head&amp;gt;&lt;br&gt;\n&amp;lt;body ng-controller=&quot;GraphCtrl&quot; &amp;gt;&lt;br&gt;\n\t&amp;lt;c3chart bindto-id=&quot;chart1&quot;&amp;gt;&lt;br&gt;\n\t\t&amp;lt;chart-column column-id=&quot;data-1&quot;&lt;br&gt;\n\t\t\t\t\t  column-values=&quot;30,200,100,400,150,250&quot;&lt;br&gt;\n\t\t\t\t\t  column-type=&quot;line&quot;\/&amp;gt;&lt;br&gt;\n \t&amp;lt;\/c3chart&amp;gt;&lt;br&gt;\n\t&amp;lt;!-- Load the javascript libraries --&amp;gt;&lt;br&gt;\n\t&amp;lt;script src=&quot;js\/d3\/d3-3.4.11.min.js&quot; charset=&quot;utf-8&quot;&amp;gt;&amp;lt;\/script&amp;gt;&lt;br&gt;\n\t&amp;lt;script src=&quot;js\/c3\/c3-0.2.4.min.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&lt;br&gt;\n\t&amp;lt;script src=&quot;js\/angular\/angular-1.2.21.min.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&lt;br&gt;\n\t&amp;lt;script src=&quot;js\/c3js-directive.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&lt;br&gt;\n\t&amp;lt;script src=&quot;js\/graph-app-directive-1.js&quot;&amp;gt;&amp;lt;\/script&amp;gt;&lt;br&gt;\n&amp;lt;\/body&amp;gt;&lt;br&gt;\n&amp;lt;\/html&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><em>Most basic chart with static data, notice initialising app with ng-app and the controller with ng-controller. Also checkout the c3js-directive.js file if you want to learn about the directive.<\/em><\/p>\n<p><pre class=\"brush: jscript; title: Initialize app and controller; notranslate\" title=\"Initialize app and controller\">&lt;br&gt;\nvar graphApp = angular.module('graphApp', &#x5B;'gridshore.c3js.chart']);&lt;br&gt;\ngraphApp.controller('GraphCtrl', function ($scope) {&lt;br&gt;\n});&lt;br&gt;\n<\/pre><\/p>\n<p><em>A very basic AngularJS application that loads the directive gridshore.c3js.chart and does nothing else.<\/em><\/p>\n<p>The main element is <strong>c3chart<\/strong>, with the attribute bindto-id we define the id of the html element the c3js chart is bound to. This makes it possible to add multiple charts to one page. In this sample we provide the data using a predifined set of numbers. This is done by the <strong>chart-column<\/strong> element. In this element we can define the id of the line, which is used in the tooltip and the legenda. Also you can change the type of the column by changing the column-type, change it to spline for instance. Below is the chart created with this code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-1.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-1.png\" alt=\"C3js directive 1\" width=\"600\" height=\"290\" border=\"0\"><\/p>\n<h3>Use AngularJS to provide the datapoints<\/h3>\n<p>Another way of providing data is using a more angular approach. Now we provide the data using the $scope of the controller.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;c3chart bindto-id=&quot;chart&quot; chart-data=&quot;datapoints&quot; chart-columns=&quot;datacolumns&quot;&amp;gt;&lt;br&gt;\n&amp;lt;\/c3chart&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p>&nbsp;<\/p>\n<p><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;br&gt;\ngraphApp.controller('GraphCtrl', function ($scope) {&lt;br&gt;\n    $scope.datapoints=&#x5B;{&quot;x&quot;:10,&quot;top-1&quot;:10,&quot;top-2&quot;:15},&lt;br&gt;\n                       {&quot;x&quot;:20,&quot;top-1&quot;:100,&quot;top-2&quot;:35},&lt;br&gt;\n                       {&quot;x&quot;:30,&quot;top-1&quot;:15,&quot;top-2&quot;:75},&lt;br&gt;\n                       {&quot;x&quot;:40,&quot;top-1&quot;:50,&quot;top-2&quot;:45}];&lt;br&gt;\n    $scope.datacolumns=&#x5B;{&quot;id&quot;:&quot;top-1&quot;,&quot;type&quot;:&quot;line&quot;},&lt;br&gt;\n                        {&quot;id&quot;:&quot;top-2&quot;,&quot;type&quot;:&quot;spline&quot;}];&lt;br&gt;\n    $scope.datax={&quot;id&quot;:&quot;x&quot;};&lt;br&gt;\n});&lt;br&gt;\n<\/pre><\/p>\n<p><em>Notice that we put three objects in the $scope, two of which we also have in the html directive (<strong>datapoints<\/strong> and <strong>datacolumns<\/strong>). This time we have 2 lines: top-1 and top-2. As you can see we can configure the type again, this time I configured two different types, <strong>line<\/strong> and <strong>spline<\/strong>.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-2.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-2.png\" alt=\"C3js directive 2\" width=\"600\" height=\"281\" border=\"0\"><\/p>\n<p>If you look closely at the datapoints, you can see we have an additional property called x as well as a different object on the $scope called <strong>datax<\/strong>. We can add an attribute to the directive called <strong>chart-x<\/strong> that tells c3js to use the values from x as values on the x axis. We can also change the name top-1 to a nicer version and we can change the colors of the lines if we want to. The following code shows the changes.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;c3chart bindto-id=&quot;chart&quot; chart-data=&quot;datapoints&quot; chart-columns=&quot;datacolumns&quot; chart-x=&quot;datax&quot;&amp;gt;&lt;br&gt;\n&amp;lt;\/c3chart&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p>&nbsp;<\/p>\n<p><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;br&gt;\ngraphApp.controller('GraphCtrl', function ($scope) {&lt;br&gt;\n    $scope.datapoints=&#x5B;{&quot;x&quot;:10,&quot;top-1&quot;:10,&quot;top-2&quot;:15},&lt;br&gt;\n                       {&quot;x&quot;:20,&quot;top-1&quot;:100,&quot;top-2&quot;:35},&lt;br&gt;\n                       {&quot;x&quot;:30,&quot;top-1&quot;:15,&quot;top-2&quot;:75},&lt;br&gt;\n                       {&quot;x&quot;:40,&quot;top-1&quot;:50,&quot;top-2&quot;:45}];&lt;br&gt;\n    $scope.datacolumns=&#x5B;{&quot;id&quot;:&quot;top-1&quot;,&quot;type&quot;:&quot;line&quot;,&quot;name&quot;:&quot;Top one&quot;,&quot;color&quot;:&quot;green&quot;},&lt;br&gt;\n                        {&quot;id&quot;:&quot;top-2&quot;,&quot;type&quot;:&quot;spline&quot;,&quot;name&quot;:&quot;Top two&quot;,&quot;color&quot;:&quot;blue&quot;}];&lt;br&gt;\n    $scope.datax={&quot;id&quot;:&quot;x&quot;};&lt;br&gt;\n});&lt;br&gt;\n<\/pre><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-3.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-3.png\" alt=\"C3js directive 3\" width=\"600\" height=\"275\" border=\"0\"><\/p>\n<p><em>Notice that the colours of the lines changed as well as the names in the legenda.<\/em><\/p>\n<p>Now the data is coming from an AngularJS model object. We can use AngularJS features to obtain the data from a service for instance, or we can even do something with an update of the data using $interval. The directive listens for changes to the datapoints model, it does not change when datacolumns or datax changes. If the datapoints changes, the graph is redrawn. This is what we are going to use in the next bit.<\/p>\n<h3>A time based horizontal axis.<\/h3>\n<p>In this sample we are going to show you the <strong>timeseries<\/strong> chart, as available from c3.js. To do this, you need to add information about the x-axis. We need to tell it to be of type timeseries and we define the format of the tick (meaning the values on the x-axis). The following code block shows the html.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;c3chart bindto-id=&quot;chart&quot; chart-data=&quot;datapoints&quot; chart-columns=&quot;datacolumns&quot; chart-x=&quot;datax&quot;&amp;gt;&lt;br&gt;\n    &amp;lt;chart-axis&amp;gt;&lt;br&gt;\n        &amp;lt;chart-axis-x axis-id=&quot;x&quot; axis-type=&quot;timeseries&quot;&amp;gt;&lt;br&gt;\n            &amp;lt;chart-axis-x-tick tick-format=&quot;%Y-%m-%d&quot;\/&amp;gt;&lt;br&gt;\n        &amp;lt;\/chart-axis-x&amp;gt;&lt;br&gt;\n    &amp;lt;\/chart-axis&amp;gt;&lt;br&gt;\n&amp;lt;\/c3chart&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><em>Notice the attribute <strong>axis-type<\/strong><\/em><\/p>\n<p>Next the trick to update the data in the chart. What we do is change the model parameter in the $scope called datapoints. Than in the directive we watch the datapoints collection and redraw the chart if changes.<\/p>\n<p><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;br&gt;\nvar graphApp = angular.module('graphApp', &#x5B;'gridshore.c3js.chart','graphApp.services']);&lt;\/p&gt;\n&lt;p&gt;graphApp.controller('GraphCtrl', function ($scope, $interval,dataService) {&lt;br&gt;\n    $scope.datapoints=&#x5B;];&lt;br&gt;\n    $scope.datacolumns=&#x5B;{&quot;id&quot;:&quot;top-1&quot;,&quot;type&quot;:&quot;line&quot;,&quot;name&quot;:&quot;Top one&quot;,&quot;color&quot;:&quot;black&quot;},&lt;br&gt;\n                        {&quot;id&quot;:&quot;top-2&quot;,&quot;type&quot;:&quot;spline&quot;,&quot;name&quot;:&quot;Top two&quot;}];&lt;br&gt;\n    $scope.datax={&quot;id&quot;:&quot;x&quot;};&lt;\/p&gt;\n&lt;p&gt;    $interval(function(){&lt;br&gt;\n        dataService.loadData(function(data){&lt;br&gt;\n            $scope.datapoints.push(data);&lt;br&gt;\n        });&lt;br&gt;\n    },1000,10);&lt;br&gt;\n});&lt;\/p&gt;\n&lt;p&gt;var services = angular.module('graphApp.services', &#x5B;]);&lt;br&gt;\nservices.factory('dataService', function() {&lt;br&gt;\n    function DataService() {&lt;br&gt;\n        var maxNumber = 200;&lt;\/p&gt;\n&lt;p&gt;        this.loadData = function(callback) {&lt;br&gt;\n            callback({&quot;x&quot;:new Date(),&quot;top-1&quot;:randomNumber(),&quot;top-2&quot;:randomNumber()});&lt;br&gt;\n        };&lt;\/p&gt;\n&lt;p&gt;        function randomNumber() {&lt;br&gt;\n            return Math.floor((Math.random() * maxNumber) + 1);&lt;br&gt;\n        }&lt;br&gt;\n    }&lt;br&gt;\n    return new DataService();&lt;br&gt;\n});&lt;br&gt;\n<\/pre><\/p>\n<p><em>Notice how we use <strong>$interval<\/strong> to load a new datapoint using the service every second 10 times. Check the object that the service returns with three properties: x, top-1 and top-2<\/em><\/p>\n<p>The dataService is used to generate a new object with three properties, the current datetime for the x axis and two random values for the different lines. Notice the $interval which helps us to wait one second before creating a new point. It will do this 10 times. The most important part here is that you do not need to change the directive to make the data dynamic. This is purely done in the controller for the page you are on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-4.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-4.png\" alt=\"C3js directive 4\" width=\"600\" height=\"274\" border=\"0\"><\/p>\n<p>Next up are more features made available by the very nice c3.js library.<\/p>\n<h3>Some extra features provided by c3js<\/h3>\n<p>I am not going to show all the code in this case. I am focussing on changes. First one is setting the name of the column and the color of the column (or line) from the html instead of json.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;chart-column column-id=&quot;data 1&quot;&lt;br&gt;\n              column-name=&quot;Data 1&quot;&lt;br&gt;\n              column-color=&quot;red&quot;&lt;br&gt;\n              column-values=&quot;30,200,100,400,150,250&quot;&lt;br&gt;\n              column-type=&quot;spline&quot;\/&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p>Next up is adding a second verticle axis. First part is specifying which columns belong to x, y and y2. Next part is configuring things like range, padding and labels for the axis. Padding is placing empty space on top of the y-axis using the scale of the axis.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;chart-axes values-x=&quot;x&quot; y=&quot;data1,data3&quot; y2=&quot;data2&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;chart-axis&amp;gt;&lt;br&gt;\n    &amp;lt;chart-axis-x axis-position=&quot;outer-center&quot;&lt;br&gt;\n                  axis-label=&quot;Number by 10&quot;&lt;br&gt;\n                  axis-type=&quot;category&quot;&amp;gt;&lt;br&gt;\n        &amp;lt;chart-axis-x-tick tick-rotate=&quot;50&quot;\/&amp;gt;&lt;br&gt;\n    &amp;lt;\/chart-axis-x&amp;gt;&lt;br&gt;\n    &amp;lt;chart-axis-y axis-id=&quot;y&quot;&lt;br&gt;\n                  axis-position=&quot;outer-right&quot;&lt;br&gt;\n                  axis-label=&quot;Higher numbers&quot;&lt;br&gt;\n                  padding-top=&quot;100&quot;&lt;br&gt;\n                  padding-bottom=&quot;0&quot;&lt;br&gt;\n                  range-min=&quot;0&quot;\/&amp;gt;&lt;br&gt;\n    &amp;lt;chart-axis-y axis-id=&quot;y2&quot;&lt;br&gt;\n                  axis-position=&quot;outer-right&quot;&lt;br&gt;\n                  axis-label=&quot;Lower numbers&quot;&lt;br&gt;\n                  padding-top=&quot;10&quot;&lt;br&gt;\n                  padding-bottom=&quot;0&quot;&lt;br&gt;\n                  range-max=&quot;100&quot;&lt;br&gt;\n                  range-min=&quot;0&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;\/chart-axis&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-5.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-5.png\" alt=\"C3js directive 5\" width=\"600\" height=\"280\" border=\"0\"><\/p>\n<p>Notice the <strong>chart-axis-x-tick<\/strong>, this shows the cool feature to rotate the labels on the x-axis. Next up is adding a grid to the chart. You can configure to show the x and y grid. But you can also position one grid line on a specific value.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;chart-grid show-x=&quot;false&quot; show-y=&quot;true&quot;&amp;gt;&lt;br&gt;\n    &amp;lt;chart-grid-optional axis-id=&quot;x&quot; grid-value=&quot;1&quot; grid-text=&quot;Start&quot;\/&amp;gt;&lt;br&gt;\n    &amp;lt;chart-grid-optional axis-id=&quot;y&quot; grid-value=&quot;20&quot; grid-text=&quot;Minimum&quot;\/&amp;gt;&lt;br&gt;\n    &amp;lt;chart-grid-optional axis-id=&quot;y&quot; grid-value=&quot;200&quot; grid-text=&quot;Maximum&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;\/chart-grid&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-6.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-6.png\" alt=\"C3js directive 6\" width=\"600\" height=\"278\" border=\"0\"><\/p>\n<p>Another really cool feature is adding the subchart, with this you can select just a selection of the datapoints in the chart. Together with the zoom functionality this makes a very interactive chart. You have to try it to believe it.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;c3chart bindto-id=&quot;chart5&quot; show-labels=&quot;true&quot; show-subchart=&quot;true&quot; enable-zoom=&quot;true&quot;&amp;gt;&lt;br&gt;\n&amp;lt;\/c3chart&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><em>Notice the attributes <strong>show-subchart<\/strong> and <strong>enable-zoom<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-7.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-7.png\" alt=\"C3js directive 7\" width=\"600\" height=\"297\" border=\"0\"><\/p>\n<p>The last thing to show for now is putting the legenda at another location, changing the tooltip, change the size of the chart and provide an array of colors to use for the lines.<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;br&gt;\n&amp;lt;chart-legend show-legend=&quot;true&quot; legend-position=&quot;right&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;chart-colors color-pattern=&quot;#1f77b4,#ffbb78,#2ca02c,#ff7f0e&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;chart-size chart-height=&quot;600&quot; chart-width=&quot;600&quot;\/&amp;gt;&lt;br&gt;\n&amp;lt;chart-tooltip show-tooltip=&quot;true&quot; group-tooltip=&quot;false&quot;\/&amp;gt;&lt;br&gt;\n<\/pre><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"c3js-directive-8.png\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/08\/c3js-directive-8.png\" alt=\"C3js directive 8\" width=\"389\" height=\"400\" border=\"0\"><\/p>\n<p>That is it for now, if you have ideas, improvements or bugs please use github (check code samples at references)<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/jettro\/c3-angular-sample\">Code samples<\/a> &#8211; These are the code samples used in the blog.<\/li>\n<li><a href=\"http:\/\/c3js.org\">http:\/\/c3js.org<\/a> &#8211; Homepage of c3.js, wrapper around D3<\/li>\n<li><a href=\"http:\/\/d3js.org\">http:\/\/d3js.org<\/a> &#8211; Home page of D3.js, a very advanced charting library.<\/li>\n<li><a href=\"https:\/\/blog.trifork.com\/2014\/07\/29\/creating-charts-with-c3-js\/\">Creating charts with C3.js<\/a> &#8211; Blogpost by Roberto about c3.js<\/li>\n<li><a href=\"http:\/\/www.gridshore.nl\/2014\/07\/29\/using-c3js-angularjs\/\">Using C3js with AngularJS<\/a> &#8211; Blogpost by me about angularjs and c3.js<\/li>\n<li><a href=\"https:\/\/blog.trifork.com\/2014\/04\/17\/angular-directives-a-beginners-guide-part-1\/\">Directives for beginners (part I)<\/a> &#8211; Blogpost by Dennis about angularjs directives<\/li>\n<li><a href=\"https:\/\/blog.trifork.com\/2014\/07\/22\/angular-directives-a-beginners-guide-part-2\/\">Directives for beginners (part II)<\/a><\/li>\n<\/ul>\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/bit.ly\/3BAo305\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"256\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-1024x256.png\" alt=\"\" class=\"wp-image-20303\" srcset=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-1024x256.png 1024w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-300x75.png 300w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-768x192.png 768w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-1536x384.png 1536w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-2048x512.png 2048w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2022\/02\/Blog-Banner-1-1920x480.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>For one of our projects we wanted to create some nice charts. Feels like something you often want but do not do because it takes to much time. This time we really needed it. I had prior experience with Highcharts, which is also a nice library. But this time we wanted more control. We had [&hellip;]<\/p>\n","protected":false},"author":60,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[366,78,10],"tags":[109,390,395,396,392,381],"class_list":["post-12418","post","type-post","status-publish","format-standard","hentry","category-angularjs-development","category-frontend","category-development","tag-angularjs","tag-c3-js","tag-c3js","tag-d3","tag-d3-js","tag-directives"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AngularJS directives for C3.js chart library - Trifork Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AngularJS directives for C3.js chart library - Trifork Blog\" \/>\n<meta property=\"og:description\" content=\"For one of our projects we wanted to create some nice charts. Feels like something you often want but do not do because it takes to much time. This time we really needed it. I had prior experience with Highcharts, which is also a nice library. But this time we wanted more control. We had [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/\" \/>\n<meta property=\"og:site_name\" content=\"Trifork Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-08-19T09:00:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png\" \/>\n<meta name=\"author\" content=\"Jettro Coenradie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jettro Coenradie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/\",\"url\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/\",\"name\":\"AngularJS directives for C3.js chart library - Trifork Blog\",\"isPartOf\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png\",\"datePublished\":\"2014-08-19T09:00:09+00:00\",\"author\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/198c00ea654e6a5e38e33511d983613d\"},\"breadcrumb\":{\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage\",\"url\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png\",\"contentUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/trifork.nl\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AngularJS directives for C3.js chart library\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/trifork.nl\/blog\/#website\",\"url\":\"https:\/\/trifork.nl\/blog\/\",\"name\":\"Trifork Blog\",\"description\":\"Keep updated on the technical solutions Trifork is working on!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/trifork.nl\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/198c00ea654e6a5e38e33511d983613d\",\"name\":\"Jettro Coenradie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/bfce5dacae07c9ed6b0283448d22fee7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/bfce5dacae07c9ed6b0283448d22fee7?s=96&d=mm&r=g\",\"caption\":\"Jettro Coenradie\"},\"url\":\"https:\/\/trifork.nl\/blog\/author\/jettro\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AngularJS directives for C3.js chart library - Trifork Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/","og_locale":"en_US","og_type":"article","og_title":"AngularJS directives for C3.js chart library - Trifork Blog","og_description":"For one of our projects we wanted to create some nice charts. Feels like something you often want but do not do because it takes to much time. This time we really needed it. I had prior experience with Highcharts, which is also a nice library. But this time we wanted more control. We had [&hellip;]","og_url":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/","og_site_name":"Trifork Blog","article_published_time":"2014-08-19T09:00:09+00:00","og_image":[{"url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png","type":"","width":"","height":""}],"author":"Jettro Coenradie","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jettro Coenradie","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/","url":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/","name":"AngularJS directives for C3.js chart library - Trifork Blog","isPartOf":{"@id":"https:\/\/trifork.nl\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage"},"image":{"@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage"},"thumbnailUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png","datePublished":"2014-08-19T09:00:09+00:00","author":{"@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/198c00ea654e6a5e38e33511d983613d"},"breadcrumb":{"@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#primaryimage","url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png","contentUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2014\/07\/angularjs-logo.png.pagespeed.ce_.2SfPGmgT_b.png"},{"@type":"BreadcrumbList","@id":"https:\/\/trifork.nl\/blog\/angularjs-directives-for-c3-js-chart-library\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/trifork.nl\/blog\/"},{"@type":"ListItem","position":2,"name":"AngularJS directives for C3.js chart library"}]},{"@type":"WebSite","@id":"https:\/\/trifork.nl\/blog\/#website","url":"https:\/\/trifork.nl\/blog\/","name":"Trifork Blog","description":"Keep updated on the technical solutions Trifork is working on!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/trifork.nl\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/198c00ea654e6a5e38e33511d983613d","name":"Jettro Coenradie","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/bfce5dacae07c9ed6b0283448d22fee7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bfce5dacae07c9ed6b0283448d22fee7?s=96&d=mm&r=g","caption":"Jettro Coenradie"},"url":"https:\/\/trifork.nl\/blog\/author\/jettro\/"}]}},"_links":{"self":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/12418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/users\/60"}],"replies":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/comments?post=12418"}],"version-history":[{"count":0,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/12418\/revisions"}],"wp:attachment":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media?parent=12418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/categories?post=12418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/tags?post=12418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}