Hoorah for modular code

Let's get to it. Go to lib/main.js and add the following line to the imports section:

import westerosChart from './chapter7/index';

Create a folder called chapter7 and create a file called index.js. Add the following code to it:

import * as d3 from 'd3'; 
import * as legend from 'd3-svg-legend';
import baseChart from '../chapter6/';
import './chapter7.css';
import {
colorScale as color,
tooltip,
connectionMatrix,
uniques,
} from '../common';

We import our westerosChart object from the last chapter as baseChart, so we can just extend it here.

That's all there is to it; we're ready for our first chart.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset