Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="app">
        <mds-section bold :title="chartAriaLabel" :aria-label="chartAriaLabel" aria-describedby="aria-description">
            <span id="aria-description" class="accessibly-hidden"> {{ chartAriaDescription }}</span>
            <mce-layout :plot-width="plotWidth" :plot-height="plotHeight" :legend-right-width="legendRightWidth">
                <template #legend-right>
                        <mce-legend-group title="Asset Allocation">
                            <mce-legend-item v-for="row in fullData" :key="" :label="row.label" :value="row.value | format" :color="chartColors[]" key-type="donut"></mce-legend-item>

                <!-- Main plot (default slot) -->
                <mce-donut-plot :color="chartColors" :data="chartData" :data-focused="focusedData" :height="plotHeight" :width="plotWidth" @mousemove-plot="onMousemovePlot"

        <!-- provide an accessible alternative for screen-readers -->
        <mds-table class="table">
            <div class="accessibly-hidden">
                <mds-th>Asset Class</mds-th>
                <mds-th right-aligned>Allocation %</mds-th>
                <mds-tr v-for="row in fullData" :key="">
                    <mds-td> {{ row.label }} </mds-td>
                    <mds-td right-aligned> {{ row.value | format }} </mds-td>


                // All mixins, constants, and typography from MDS are available for use

@mixin mds-accessibly-hidden() {
    clip: rect(0 0 0 0);
    left: 0;
    position: absolute;
    z-index: -1;

body {
    margin: $mds-space-1-x;
    padding: 0;

.accessibly-hidden {
    @include mds-accessibly-hidden();

.table {
    margin-top: $mds-space-4-x;
    max-width: 400px;



                // Locally we would import from the d3 package, e.g.
// import * as d3 from 'd3';
// In CodePen, we'll pull from instead.
import * as d3 from "";

// Locally we would import from the @mce/color package, e.g.
// import { assetAllocation } from '@mce/color';
// In CodePen, we'll pull from window.utilities.color instead.
const { assetAllocation } = window.utilities.color;

// Prepare chart source data
const rawData = [
        id: "AssetAllocCash",
        label: "Cash",
        value: 4.74688,
        id: "AssetAllocNotClassified",
        label: "Not Classified",
        value: 1.53654,
        id: "AssetAllocNonUSEquity",
        label: "Non-U.S. Equity",
        value: 27.24799,
        id: "AssetAllocOther",
        label: "Other",
        value: 0.0,
        id: "AssetAllocUSEquity",
        label: "U.S. Equity",
        value: 37.11866,
        id: "AssetAllocBond",
        label: "Fixed Income",
        value: 29.34991,

const chartColors = {
    AssetAllocNotClassified: assetAllocation['not-classified'],
    AssetAllocNonUSEquity: assetAllocation.alternative,
    AssetAllocOther: assetAllocation.other,
    AssetAllocUSEquity: assetAllocation.equity,
    AssetAllocBond: assetAllocation['fixed-income'],

// Initialize and render chart
const app = new Vue({
    el: "#app",
    data() {
        return {
            // Descriptive Labels
                "Vanguard Global Wellington Fund Admiral Shares (VGWAX)",
                "The allocation breakdown across asset classes for the Vanguard Global Wellington Fund Admiral Shares (VGWAX) fund. The fund is well diversified across asset classes with 37% allocated to U.S. Equity, 29% Fixed Income, 27% Non-U.S. Equity, and around 5% Cash.",
            // Dimensions
            plotHeight: 350,
            plotWidth: 350,
            legendRightWidth: 170,
            focusedData: null,
    computed: {
        fullData() {
            // Show all values, including zero, in the legend
            return rawData.sort((a, b) => b.value - a.value);
        chartData() {
            // Ignore zero values to avoid unwanted pie padAngle slices
            return this.fullData.filter((d) => d.value > 0);
    filters: {
        format(value) {
            return d3.format(",.2%")(value / 100);
    methods: {
        onMousemovePlot(e) {
            const { data } = e;
            this.focusedData = [data._itemId];
        onMouseleavePlot() {
            this.focusedData = null;