Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <script src="https://cdn.anychart.com/releases/8.11.0/js/anychart-base.min.js"></script>

<div id="container"></div>
              
            
!

CSS

              
                 html,
    body,
    #container {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }
              
            
!

JS

              
                anychart.onDocumentReady(function () {
  
  // add data
  var data = [
    ["2003", 1, 0, 0],
    ["2004", 4, 0, 0],
    ["2005", 6, 0, 0],
    ["2006", 9, 1, 0],
    ["2007", 12, 2, 0],
    ["2008", 13, 5, 1],
    ["2009", 15, 6, 1],
    ["2010", 16, 9, 1],
    ["2011", 16, 10, 4],
    ["2012", 17, 11, 5],
    ["2013", 17, 13, 6],
    ["2014", 17, 14, 7],
    ["2015", 17, 14, 10],
    ["2016", 17, 14, 12],
    ["2017", 19, 16, 12],
    ["2018", 20, 17, 14],
    ["2019", 20, 19, 16],
    ["2020", 20, 20, 17],
    ["2021", 20, 20, 20],
    ["2022", 20, 22, 20]
  ];
  
  // create a data set
  var dataSet = anychart.data.set(data);

  // map the data for all series
  var firstSeriesData = dataSet.mapAs({x: 0, value: 1});
  var secondSeriesData = dataSet.mapAs({x: 0, value: 2});
  var thirdSeriesData = dataSet.mapAs({x: 0, value: 3});

  // create a stepped line chart
  var chart = anychart.stepLine();

  // create the series and name them
  var firstSeries = chart.stepLine(firstSeriesData);
  firstSeries.name("Roger Federer");
  var secondSeries = chart.stepLine(secondSeriesData);
  secondSeries.name("Rafael Nadal");
  var thirdSeries = chart.stepLine(thirdSeriesData);
  thirdSeries.name("Novak Djokovic");

  // add a legend and customize it
  chart.legend().enabled(true).fontSize(14).padding([10, 0, 10, 0]);
  
  // add a title and customize it
  chart
    .title()
    .enabled(true)
    .useHtml(true)
    .text(
      '<span style="color: #006331; font-size:20px;">Big Three&#39;s Grand Slam Title Race</span>' +
        '<br/><span style="font-size: 16px;">(Triumphs at Australian Open, French Open, Wimbledon, U.S. Open)</span>'
    );
  
  // name the axes
  chart.yAxis().title("Titles won");
  chart.xAxis().title("Year");
  
  // customize the series markers
  firstSeries.hovered().markers().type("circle").size(4);
  secondSeries.hovered().markers().type("circle").size(4);
  thirdSeries.hovered().markers().type("circle").size(4);
  
  // turn on crosshairs and remove the y hair
  chart.crosshair().enabled(true).yStroke(null).yLabel(false);
  
  // change the tooltip position
  chart.tooltip().positionMode("point");
  chart.tooltip().position("right").anchor("left-center").offsetX(5).offsetY(5);
  
  // customize the series stroke in the normal state
  firstSeries.normal().stroke("#7b60a2", 2.5);
  secondSeries.normal().stroke("#db7346", 2.5);
  thirdSeries.normal().stroke("#43a7dc", 2.5);
  
  // specify where to display the chart
  chart.container("container");
  
  // draw the resulting chart
  chart.draw();
  
});
              
            
!
999px

Console