cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="abeamer-story" id=story>
  <div class="abeamer-scene" id=scene1>
    <div id=gallery></div>
  </div>
</div>
            
          
!
            
              $abeamer-width: 827;
$abeamer-height: 323;

body,
html,
.abeamer-story,
.abeamer-scene {
  width: $abeamer-width + px;
  height: $abeamer-height + px;
}

#scene1 {
  background: white;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
}

canvas {
  display: inline-block;
}
            
          
!
            
              // twitter: https://twitter.com/ABeamerJS
// website: https://www.abeamer.com

// support this animation framework by adding a star on github:
// https://github.com/a-bentofreire/abeamer

/* ---------------
* To generate a png file sequence, gif or .mp4 file of your work:
* 1. Install ABeamer, read the instructions: https://www.abeamer.com/#get-started
* 2. Create a project using abeamer: abeamer create foo
* 3. Copy the:
*     - scss code to css/main.scss   (compile it)
*     - ts code to js/main.ts or if it's javascript to js/main.js
*     - html code inside the story to code inside the story in index.html
*     - the dimensions code at the top of scss code to abeamer.ini
* 4. To generate a file sequence: abeamer render foo
* 5. To generate an animated gif file (after step 4): abeamer gif foo
* 6. To generate a .mp4 file (after step 4): abeamer movie foo
* ---------------- */

$(window).on("load", () => {

  const story = ABeamer.createStory(/*FPS:*/10);

  // ------------------------------------------------------------------------
  //                               Charts
  // ------------------------------------------------------------------------

  const scene1 = story.scenes[0];

  const duration = 3;

  const defData0 = [23000, 32000, 45000, 15000, 50400, 60000];
  const defData = [
    defData0,
    [30000, 42000, 50000, 16000, 48400, 65000],
    [20000, 45000, 51000, 18000, 49400, 45000],
  ];

  const defLabelsX = {
    captions: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
  };



  interface AxisChartTaskParamsEx extends ABeamer.AxisChartTaskParams {
    props?: ABeamer.AnimationProp[];
    chartWidth?: uint;
  }


  interface PieChartTaskParamsEx extends ABeamer.PieChartTaskParams {
    props?: ABeamer.AnimationProp[];
    chartWidth?: uint;
  }

  const firstOnly = false;
  const viewOnly = undefined;

  const charts: (AxisChartTaskParamsEx | PieChartTaskParamsEx)[] = [{

    chartType: ABeamer.ChartTypes.pie,
    // labelsX: defLabelsX,
    title: 'Government expenditure',
    data: [[36.7, 17.1, 13.8, 12.9, 8.2, 4.0, 2.7]],
    fillColors: [['#E82C0C', '#2204FF', '#FFB80D', '#0DFFB6', '#CE0EE8', '#E8E70E', '#E86378']],
    strokeColors: '#525252',
    angleStart: Math.PI,
    dispersionStart: 0.1,
    legend: {
      captions: ['Social Protection', 'General Services', 'Health', 'Education', 'Economic affairs',
        'Public order', 'Defence'],
    },
    props: [{
      prop: 'dispersion',
      value: 1,
    }],
  } as PieChartTaskParamsEx, {

    chartType: ABeamer.ChartTypes.bar,
    labelsX: defLabelsX,
    title: '2017 Sales',
    data: [[23000, 32000, 45000, 15000, 50400, 58000]],
    strokeWidth: 1,
    seriesSpacing: 8,
    chartWidth: 260,
    fillColors: '#ffecad',
    negativeFillColors: '#ffb0b0',
    strokeColors: '#9c9c9c',
    labelsY: {
      captions: "=v/1000 + 'k'",
    },
    pointHeightStart: 0.1,
    props: [{
      prop: 'point-height',
      value: 1,
    }],
  }, {
    chartType: ABeamer.ChartTypes.area,
    data: [
      [30, 42, 50, 50, 45, 60, 40],
      [13, 32, 35, 85, 35, 70, 65],
    ],
    title: 'Customer Satisfaction',
    labelsX: {
      captions: ['17Q1', '17Q2', '17Q3', '17Q4', '18Q1', '18Q2', '18Q3'],
    },
    labelsY: "=v + '%'",
    fillColors: ['rgba(53, 169, 192, 0.4392)', 'rgba(173, 255, 185, 0.4392)'],
    strokeColors: ['#9c9c9c', '#9c9c9c'],
    strokeWidth: [2, 2],
    sweepStart: 0.2,
    props: [{
      prop: 'sweep',
      value: 1,
    }],
  }, {
    chartType: ABeamer.ChartTypes.line,
    labelsX: "=2012 + v",
    data: [
      [230, 320, 450, 150, 504, 600],
      [180, 400, 400, 180, 404, 500]],
    strokeColors: ['#dd5252', '#5252dd'],
    strokeWidth: 2,
    chartWidth: 240,
    // sweepStart: 0.2,
    deviationStart: 0.1,
    props: [{
      prop: 'deviation',
      // prop: 'sweep',
      value: 1,
    }],
  }, {
    chartType: ABeamer.ChartTypes.mixed,
    data: defData,
    chartTypes: [ABeamer.ChartTypes.bar, ABeamer.ChartTypes.bar, ABeamer.ChartTypes.line],
    labelsX: defLabelsX,
    fillColors: ['#11ecad', '#adffb9', ''],
    strokeColors: ['#9c9c9c', '#9c9c9c', '#d05858'],
    strokeWidth: [1, 1, 2],
    legend: {
      captions: ['2016', '2017', 'Profit'],
    },
    // sweepStart: 0.2,
    pointHeightStart: 0.2,
    props: [{
      prop: 'point-height',
      // prop: 'sweep',
      value: 1,
    }],
    chartWidth: 320,
  }, {
    chartType: ABeamer.ChartTypes.marker,
    labelsX: defLabelsX,
    data: [[23000, 32000, 45000, 15000, 50400, 60000]],
    markers: {
      shape: ABeamer.ChartPointShape.circle,
      size: 10,
      color: 'red',
    },
    seriesSpacing: 1,
    title: 'Marker Chart',
    fillColors: '#ffecad',
    pointHeightStart: 0.1,
    chartWidth: 260,
    labelsY: {
      captions: "=v/1000 + 'k'",
    },
    props: [{
      prop: 'point-height',
      value: 1,
    }],
  }];

  // ------------------------------------------------------------------------
  //                               Factory
  // ------------------------------------------------------------------------

  const chartCount = !firstOnly ? charts.length : 1;

  const widths = [];
  charts.forEach((chart, i) => {
    widths.push(chart.chartWidth || 280);
  });

  scene1
    .addAnimations([{
      selector: '#gallery',
      tasks: [
        {
          handler: 'factory',
          params: {
            count: chartCount,
            tag: 'canvas',
            attrs: [
              {
                name: 'width',
                value: `=case(i, ${widths.join(',')})`,
              },
              {
                name: 'height',
                value: '160',
              },
            ],
          } as ABeamer.FactoryTaskParams,
        },
      ],
    }]);

  // ------------------------------------------------------------------------
  //                               Add Charts
  // ------------------------------------------------------------------------

  charts.forEach((chart, i) => {

    if (i >= chartCount || (viewOnly !== undefined && i !== viewOnly)) {
      return;
    }

    chart.animeSelector = `chart-${i}-anime`;

    scene1
      .addAnimations([{
        selector: `canvas:nth-child(${i + 1})`,
        tasks: [{
          handler: 'chart',
          params: chart,
        }],
      }]);
  });

  scene1
    .addAnimations(charts.map((chart, i) => chart.props ? {
      selector: `%chart-${i}-anime`,
      duration: `${duration}s`,
      props: chart.props,
    } : undefined).filter(anime => anime !== undefined))
    .addStills('0.5s');

  story.render(story.bestPlaySpeed());
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console