Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <link href="https://cdn.webdatarocks.com/latest/webdatarocks.min.css" rel="stylesheet"/>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.toolbar.min.js"></script>
<script src="https://cdn.webdatarocks.com/latest/webdatarocks.js"></script>
<script src="https://cdn.webdatarocks.com/1.3.1/webdatarocks.amcharts.js"></script>
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>


<div id="app">
  <div ref="wdrComponent"></div>
  <div id="chartContainer"></div>
</div>

              
            
!

CSS

              
                #chartContainer {
  margin-top: 30px;
  width: 100%;
  height: 500px;
}

              
            
!

JS

              
                new Vue({
  el: "#app",
  data() {
    return {
      report: null
    };
  },
  mounted() {
    this.report = new WebDataRocks({
      container: this.$refs.wdrComponent,
      toolbar: true,
      height: 380,
      width: "100%",
      report: {
        dataSource: {
          dataSourceType: "csv",
          filename: "https://cdn.webdatarocks.com/data/data.csv"
        },
        slice: {
          rows: [
            {
              uniqueName: "Country"
            },
            {
              uniqueName: "Category"
            }
          ],
          columns: [
            {
              uniqueName: "Business Type"
            },
            {
              uniqueName: "Measures"
            }
          ],
          measures: [
            {
              uniqueName: "Price",
              aggregation: "sum"
            }
          ]
        },
        conditions: [
          {
            formula: "#value > 2000000",
            measure: "Price",
            format: {
              backgroundColor: "#0598df",
              color: "#FFFFFF",
              fontFamily: "Arial",
              fontSize: "12px"
            }
          }
        ]
      },
      reportcomplete: function () {
        createColumnAmChart();
      }
    });
    var chart;

    function createColumnAmChart() {
      /* Get all the data from the pivot grid (alternatively, a slice can be passed to getData() as the first argument) */
      this.webdatarocks.amcharts.getData({}, drawChart, updateChart);
    }

    function drawChart(chartData, rawData) {
      /* Create chart instance */
      chart = am4core.create("chartContainer", am4charts.XYChart);
      /* Add data processed by WebDataRocks to the chart */
      chart.data = chartData.data;
      /* Create axes */
      /* Category axis */
      var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
      categoryAxis.dataFields.category = this.webdatarocks.amcharts.getCategoryName(
        rawData
      );
      /* Value axis */
      var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
      valueAxis.numberFormatter = new am4core.NumberFormatter();
      /* Get number formatting from WebDataRocks prepared to a format required by amCharts */
      var numberFormat = this.webdatarocks.amcharts.getNumberFormatPattern(
        rawData.meta.formats[0]
      );
      /* Apply number formatting to the chart */
      valueAxis.numberFormatter.numberFormat = numberFormat;
      /* Create and configure series */
      var series = chart.series.push(new am4charts.ColumnSeries());
      series.dataFields.categoryX = this.webdatarocks.amcharts.getCategoryName(
        rawData
      );
      series.dataFields.valueY = this.webdatarocks.amcharts.getMeasureNameByIndex(
        rawData,
        0
      );
      series.columns.template.tooltipText =
        "{valueY.value.formatNumber('" + numberFormat + "')}";
    }

    function updateChart(chartData, rawData) {
      chart.dispose();
      drawChart(chartData, rawData);
    }
  }
});

              
            
!
999px

Console