kandy 0.6.0 Help

Kandy in Kotlin Notebook

Kotlin Notebook represent interactive notebooks equipped with rich output capabilities, allowing you to explore and experiment with Kotlin code without the need for additional environment setup. The Kotlin Notebook plugin facilitates the creation and editing of notebooks directly within IntelliJ IDEA. This plugin not only encapsulates the various functionalities available in regular Kotlin files in the IDE but also incorporates additional extensions exclusive to Kotlin notebooks. These features include advanced syntax highlighting, code insertion hints, checks, and the utilization of search and refactoring functions, all aiding in enhancing your Kotlin coding efficiency.

The Kotlin Notebook plugin infuses IntelliJ IDEA with interactive development capacities, complementing the robust language support Kotlin offers within the IDE, paired with the versatile visualization potentials browsers provide.

Install Kotlin Notebook and Use Kandy

  1. To start, install IntelliJ IDEA Ultimate

  2. The plugin can be installed through IDEA settings, from the marketplace, or from a local archive file (ZIP or JAR).

  • Open IDEA and press Cmd+comma to open the IDE settings

  • Select Plugins

  • Navigate to the Marketplace tab

    Marketplace Tab
  • In the search bar, type Kotlin Notebook

  • Locate the plugin and initiate the installation by clicking the Install button

    Install Kotlin Notebook plugin
  • Click Ok to apply the changes and restart your IDE if prompted

  • Open the plugin page in JetBrains Marketplace

  • Click on Install to IntelliJ IDEA

    Kotlin Notebook on JetBrains Marketplace
  • Restart your IDE if prompted

  • Open the plugin page in JetBrains Marketplace

  • Go to the Versions tab

  • Download the specific version of plugin

    Kotlin Notebook Versions on JetBrains Marketplace
  • Open IDEA and press Cmd+comma to open the IDE settings

  • Select Plugins

  • On the Plugins page, click on The Settings button and then click on Install Plugin from Disk…

    Install Plugin from Disk
  • Restart your IDE if prompted

    1. Create a New Project in IDEA

    • From the main menu, select File | New | Project.

    • In the panel on the left, select New Project. Select Kotlin language as language for the new project.

    New Project in IDEA
    • Click Create button.

    • In the newly opened project, create a new Kotlin Notebook file. To do this, press Cmd+N in the project tree or right-click with your mouse. Select Kotlin Notebook file.

    Create Kotlin Notebook file
      1. In the notebook, execute the following cell to add the Kandy library:

      %use kandy

      You now have access to the Kandy library within your Kotlin Notebook.

      Plotting a Simple Example

      Let's create data that will be used to construct the plot. This data will represent the average annual temperatures in various cities. When working in interactive notebooks, it is advisable to divide the data creation and plot construction into two separate cells. This approach ensures that extension properties are generated for our columns in the DataFrame, allowing us to reference them easily.

      First, create a DataFrame containing data on the average temperatures in different cities as follows:

      // Create a DataFrame with data on average temperatures in various cities val averageTemperature = dataFrameOf( "city" to listOf("New York", "London", "Berlin", "Yerevan", "Tokyo"), "average temperature" to listOf(12.5, 11.0, 9.6, 11.5, 16.0) )

      Next, construct a simple plot using the data from the DataFrame:

      // Construct a plot using the data from the DataFrame averageTemperature.plot { // Add bars to the plot // Each bar represents the average temperature in a city bars { x(city) // Set the cities' data on the X-axis y(`average temperature`) { // Set the temperatures' data on the Y-axis axis.name = "Average Temperature (°C)" // Assign a name to the Y-axis } } // Set the title of the plot layout.title = "Kandy Getting Started Example" }
      Kandy Getting Started Example

      This supplementary schema outlines the key elements of Kandy's DSL, providing a quick reference to assist you in building your visualizations.

      For more examples, please see the Examples section.

      Last modified: 27 March 2024