Commit 609d9b28 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

change name to 'clip', move documentation to clip-lang.org

parent 47922783
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ cmake_install.cmake
*.so
*.dll
*.dylib
/fviz
/fviz_config.h
/clip
/clip_config.h
/.ninja_deps
/.ninja_log
/*.ninja
+21 −21
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.8)
project(fviz VERSION "0.5.0")
project(clip VERSION "0.5.0")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platform/cmake")


@@ -75,40 +75,40 @@ message(STATUS "Config Options: text_backend=${FVIZ_TEXT_BACKEND}")
message(STATUS "Config Options: text_enable_bidi=${FVIZ_TEXT_ENABLE_BIDI}")


# Build: fviz Library
# Build: clip Library
# -----------------------------------------------------------------------------
file(GLOB source_files "core/*.cc" "core/**/*.cc" "elements/*.cc" "elements/**/*.cc")
list(REMOVE_ITEM source_files "${CMAKE_SOURCE_DIR}/core/cli.cc")
add_library(fviz OBJECT ${source_files})
set_property(TARGET fviz PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(clip OBJECT ${source_files})
set_property(TARGET clip PROPERTY POSITION_INDEPENDENT_CODE 1)
set(FVIZ_LIB_LDFLAGS ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES} ${HARFBUZZ_ICU_LIBRARIES} ${PNG_LIBRARIES} ${FONTCONFIG_LIBRARIES} ${FRIBIDI_LIBRARIES} ${fmt_LIBRARY})
add_library(fviz-lib-a STATIC $<TARGET_OBJECTS:fviz>)
set_target_properties(fviz-lib-a PROPERTIES OUTPUT_NAME fviz)
add_library(fviz-lib-so SHARED $<TARGET_OBJECTS:fviz>)
target_link_libraries(fviz-lib-so ${FVIZ_LIB_LDFLAGS})
set_target_properties(fviz-lib-so PROPERTIES OUTPUT_NAME fviz)
set_target_properties(fviz-lib-so PROPERTIES PUBLIC_HEADER "core/api.h")
set_target_properties(fviz-lib-so PROPERTIES CXX_VISIBILITY_PRESET hidden)
add_library(clip-lib-a STATIC $<TARGET_OBJECTS:clip>)
set_target_properties(clip-lib-a PROPERTIES OUTPUT_NAME clip)
add_library(clip-lib-so SHARED $<TARGET_OBJECTS:clip>)
target_link_libraries(clip-lib-so ${FVIZ_LIB_LDFLAGS})
set_target_properties(clip-lib-so PROPERTIES OUTPUT_NAME clip)
set_target_properties(clip-lib-so PROPERTIES PUBLIC_HEADER "core/api.h")
set_target_properties(clip-lib-so PROPERTIES CXX_VISIBILITY_PRESET hidden)

# Build: CLI
# -----------------------------------------------------------------------------
add_executable(fviz-cli "core/cli.cc" $<TARGET_OBJECTS:fviz>)
target_link_libraries(fviz-cli ${FVIZ_LIB_LDFLAGS})
set_target_properties(fviz-cli PROPERTIES OUTPUT_NAME fviz)
add_executable(clip-cli "core/cli.cc" $<TARGET_OBJECTS:clip>)
target_link_libraries(clip-cli ${FVIZ_LIB_LDFLAGS})
set_target_properties(clip-cli PROPERTIES OUTPUT_NAME clip)


# Installation
# -----------------------------------------------------------------------------
install(TARGETS fviz-lib-a ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/fviz)
install(TARGETS fviz-lib-so LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/fviz)
install(TARGETS fviz-cli DESTINATION bin)
install(TARGETS clip-lib-a ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/clip)
install(TARGETS clip-lib-so LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/clip)
install(TARGETS clip-cli DESTINATION bin)


# Testing
# -----------------------------------------------------------------------------
add_custom_target(test
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_runner.sh
    DEPENDS fviz-cli)
    DEPENDS clip-cli)

add_custom_target(test-examples ${CMAKE_CURRENT_SOURCE_DIR}/examples/update_tests.sh)
add_dependencies(test test-examples)
@@ -117,16 +117,16 @@ add_dependencies(test test-examples)
# Examples
# -----------------------------------------------------------------------------
add_custom_target(examples)
file(GLOB example_files "examples/**/*.fvz")
file(GLOB example_files "examples/**/*.clp")
foreach(example_path ${example_files})
  get_filename_component(example_name ${example_path} NAME_WE)
  get_filename_component(example_srcdir ${example_path} DIRECTORY)
  add_custom_target(
      example_${example_name}
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      COMMAND ${CMAKE_CURRENT_BINARY_DIR}/fviz --in ${example_srcdir}/${example_name}.fvz --out ${example_srcdir}/${example_name}.svg)
      COMMAND ${CMAKE_CURRENT_BINARY_DIR}/clip --in ${example_srcdir}/${example_name}.clp --out ${example_srcdir}/${example_name}.svg)
  add_dependencies(examples example_${example_name})
  add_dependencies(example_${example_name} fviz-cli)
  add_dependencies(example_${example_name} clip-cli)
endforeach()


+2 −2
Original line number Diff line number Diff line
fviz -- Open-Source Data Visualization Toolkit 
https://fviz.org
clip -- The command line illustration processor
https://clip-lang.org

Copyright (c) 2018 Paul Asmuth, Laura Schlimmer

+62 −127
Original line number Diff line number Diff line
fviz
====
# clip

[![Build Status](https://travis-ci.org/asmuth/fviz.svg?branch=master)](https://travis-ci.org/asmuth/fviz)
[![License](https://img.shields.io/badge/license-Apache%202.0-green)](https://github.com/asmuth/fviz/blob/master/LICENSE)

fviz is a command line program for creating charts and other data-driven
clip (the _command line illustration processor_) is an open-source command line
program and software library for creating charts and other data-driven
illustrations.

It reads input data and styling information from text and CSV files and produces
the output graphic as a SVG or PNG file. All charts are highly customizable using
a simple s-expression based syntax.
In essence, clip consists of a library of composable graphical 'elements'. This
element library includes high-level building blocks for creating common chart types
as well as lower-level drawing primitives such as markers, arrows and lines. Users
create custom illustrations by combining and styling these elements.

In addition to the command line program, fviz is available as a software library
which can be embedded into any application that can link to C libraries.
When called from the command line, clip reads input data in text and CSV format
and produces the output chart as a SVG or PNG file. Additionaly, clip is available
as the libclip software library which can be embedded into any application that
supports a C FFI.

**BETA:** Please note that fviz is pre-1.0 software under active development;
It is usable, but things might generally still be a bit rough around the edges.
To see what already works, have a look at the [Examples](https://fviz.org/examples) page.

<h4>
  <a href="https://fviz.org/examples">Examples</a> &middot;
  <a href="https://fviz.org">Documentation</a>
  <a href="https://docs.clip-lang.org/getting-started">Getting Started</a> &middot;
  <a href="https://docs.clip-lang.org/examples">Examples</a> &middot;
  <a href="https://docs.clip-lang.org">Documentation</a>
</h4>


Example
-------

Being a highly visual tool, fviz is best explained by example. So here is an input
file that defines a simple scatterplot (`example_chart.fvz`). Note that this
example is only intended to give you an idea of what the syntax looks like and to
get you started quickly; for an in-depth description of all parameters, please refer
to the documentation.

    (chart/scatterplot
        data-x (csv tests/testdata/gauss2d.csv x)
        data-y (csv tests/testdata/gauss2d.csv y)
        limit-x (0 400)
        limit-y (0 200)
Being a highly visual tool, clip is best explained by example. So here is how to
draw a simple line chart using clip:

    $ clip --in example_chart.clp --out example_chart.svg

Output File (`example_chart.svg`):
[![A simple scatterplot](/examples/charts-basic/demo_timeseries.svg)](https://docs.clip-lang.org/examples/charts-basic/demo_timeseries)

Input File (`example_chart.clp`):

    (plot
      axes (bottom left)
        grid (color #fff)
        background #eee
        border none)
      axis-y-label-format (scientific)
      axis-x-label-format (datetime "%H:%M:%S")
      axis-x-label-placement (linear-align 1800)
      lines (
        data-x (csv "tests/testdata/measurement.csv" time)
        data-y (csv "tests/testdata/measurement.csv" value1)
        color #06c))

Here is how you can run the above example file through fviz:
Note that this example is only intended to give you an idea of what the syntax
looks like and to get you started quickly; for an in-depth description of all
parameters, please refer to [the documentation](https://docs.clip-lang.org).

    $ fviz --in example_chart.fvz --out example_chart.svg
More examples can be found on [the examples page](https://docs.clip-lang.org/examples).

When running the example locally, you can use your own input CSV file, or you
can download the example CSV file [from here](/tests/testdata/gauss2d.csv).
If everything works, you should get an output file similar to the one below
(`example_chart.svg`):
If you have any questions please don't hesitate to reach out via [GitHub issues](https://github.com/asmuth/clip).

[![A simple scatterplot](/examples/charts-basic/scatterplot.svg)](https://fviz.org/examples/charts-basic/scatterplot)

More examples can be found on [the examples page](https://fviz.org/examples).
For a more detailed introduction to fviz, see the [Getting Started](https://fviz.org/documentation/getting-started) page.
If you have any questions please don't hesitate to reach out via [GitHub issues](https://github.com/asmuth/fviz).
Documentation
-------------

You can find the full documentation at https://docs.clip-lang.org/


Example Gallery
---------------

A list of examples can be found on the [Examples](https://docs.clip-lang.org/examples)
page.


Building
--------

To build fviz, you need an up-to-date C++ compiler, cmake, fmtlib, libharfbuzz,
To build clip, you need an up-to-date C++ compiler, cmake, fmtlib, libharfbuzz,
libfreetype and cairo. Run:

    $ cmake .
    $ make -j

To install the `fviz` binary into your system, run `make install`:
To install the `clip` binary into your system, run `make install`:

    $ make install

@@ -77,105 +85,32 @@ To run the test suite, run `make test`:
    $ make test


For detailed installation instructions, have a look at the [Installation](https://fviz.org/documentation/installation/)
For detailed installation instructions, have a look at the [Installation](https://docs.clip-lang.org/documentation/installation/)
page.


Acknowledgements
----------------

Parts of fviz were inspired by ideas from the "Grammar of Graphics" [0] and the
ggplot2 project.

[0] Wilkinson, L. (1999). The Grammar of Graphics (Springer)


Example Gallery
---------------

Below are more examples to show you what's possible. Each example links to the
source code that generated it. Even more examples can be found on the
[Examples](https://fviz.org/examples) page.


### Examples: Scientific Charts

---
#### Example: [`examples/charts-scientific/vectorfield`](https://fviz.org/examples/charts-scientific/vectorfield)
[![vectorfield.svg](/examples/charts-scientific/vectorfield.svg)](https://fviz.org/examples/charts-scientific/vectorfield)

---
#### Example: [`examples/charts-scientific/line_markers`](https://fviz.org/examples/charts-scientific/line_markers)
[![line_markers.svg](/examples/charts-scientific/line_markers.svg)](https://fviz.org/examples/charts-scientific/line_markers)

---
#### Example: [`examples/charts-scientific/errorbars_log`](https://fviz.org/examples/charts-scientific/errorbars_log)
[![errorbars_log.svg](/examples/charts-scientific/errorbars_log.svg)](https://fviz.org/examples/charts-scientific/errorbars_log)

---
#### Example: [`examples/charts-scientific/barchart_ranges`](https://fviz.org/examples/charts-scientific/barchart_ranges)
[![barchart_ranges.svg](/examples/charts-scientific/barchart_ranges.svg)](https://fviz.org/examples/charts-scientific/barchart_ranges)

---
#### Example: [`examples/charts-scientific/multiple_y_axes`](https://fviz.org/examples/charts-scientific/multiple_y_axes)
[![multiple_y_axes.svg](/examples/charts-scientific/multiple_y_axes.svg)](https://fviz.org/examples/charts-scientific/multiple_y_axes)

---
#### Example: [`examples/charts-scientific/scatterplot_colors`](https://fviz.org/examples/charts-scientific/scatterplot_colors)
[![scatterplot_colors.svg](/examples/charts-scientific/scatterplot_colors.svg)](https://fviz.org/examples/charts-scientific/scatterplot_colors)

---
#### Example: [`examples/charts-scientific/streamgraph`](https://fviz.org/examples/charts-scientific/streamgraph)
[![streamgraph.svg](/examples/charts-scientific/streamgraph.svg)](https://fviz.org/examples/charts-scientific/streamgraph)


### Examples: Editorial Charts

---
#### Example: [`examples/charts-editorial/chart_i18n`](https://fviz.org/examples/charts-editorial/chart_i18n)
[![chart_i18n.svg](/examples/charts-editorial/chart_i18n.svg)](https://fviz.org/examples/charts-editorial/chart_i18n)

---
#### Example: [`examples/charts-editorial/stacked_areas`](https://fviz.org/examples/charts-editorial/stacked_areas)
[![stacked_areas.svg](/examples/charts-editorial/stacked_areas.svg)](https://fviz.org/examples/charts-editorial/stacked_areas)

---
#### Example: [`examples/charts-editorial/linechart_with_labels`](https://fviz.org/examples/charts-editorial/linechart_with_labels)
[![linechart_with_labels.svg](/examples/charts-editorial/linechart_with_labels.svg)](https://fviz.org/examples/charts-editorial/linechart_with_labels)

---
#### Example: [`examples/charts-editorial/stacked_bars`](https://fviz.org/examples/charts-editorial/stacked_bars)
[![stacked_bars.svg](/examples/charts-editorial/stacked_bars.svg)](https://fviz.org/examples/charts-editorial/stacked_bars)

---
#### Example: [`examples/charts-editorial/barchart_horizontal`](https://fviz.org/examples/charts-editorial/barchart_horizontal)
[![barchart_horizontal.svg](/examples/charts-editorial/barchart_horizontal.svg)](https://fviz.org/examples/charts-editorial/barchart_horizontal)


### Examples: Basic Charts

---
#### Example: [`examples/charts-basic/linechart_timeseries`](https://fviz.org/examples/charts-basic/linechart_timeseries)
[![linechart_timeseries.svg](/examples/charts-basic/linechart_timeseries.svg)](https://fviz.org/examples/charts-basic/linechart_timeseries)
  - The structure of the plot elements is based on ideas from [The Grammar of
    Graphics](https://www.springer.com/gp/book/9780387245447) and the
    [ggplot2](https://ggplot2.tidyverse.org/) library.

---
#### Example: [`examples/charts-basic/barchart_groups`](https://fviz.org/examples/charts-basic/barchart_groups)
[![barchart_groups.svg](/examples/charts-basic/barchart_groups.svg)](https://fviz.org/examples/charts-basic/barchart_groups)
  - A number of concepts in clip are heavily guided by the
    [CSS specification](https://www.w3.org/TR/CSS2/)

---
#### Example: [`examples/charts-basic/scatterplot_with_labels`](https://fviz.org/examples/charts-basic/scatterplot_with_labels)
[![scatterplot_with_labels.svg](/examples/charts-basic/scatterplot_with_labels.svg)](https://fviz.org/examples/charts-basic/scatterplot_with_labels)
  - Text rendering is based on the libre [freetype](https://www.freetype.org/)
    and [harfbuzz](https://harfbuzz.org) stack.

---
#### Example: [`examples/charts-basic/custom_font`](https://fviz.org/examples/charts-basic/custom_font)
[![custom_font.svg](/examples/charts-basic/custom_font.svg)](https://fviz.org/examples/charts-basic/custom_font)
  - Some naming choices are definitely inspired by Eddie Kohler's
    [click](https://github.com/kohler/click) software defined networking library


License
-------

    fviz -- Open-Source Data Visualization Toolkit 
    https://fviz.org
    clip -- The command line illustration processor
    https://clip-lang.org

    Copyright (c) 2018, Paul Asmuth, Laura Schlimmer
    All rights reserved.
+14 −14
Original line number Diff line number Diff line
/**
 * This file is part of the "fviz" project
 * This file is part of the "clip" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,45 +19,45 @@
#include <string.h>

using namespace std::placeholders;
using namespace fviz;
using namespace clip;

struct fviz_s {
struct clip_s {
  OutputFormat format;
  std::string buffer;
  ReturnCode error;
};

fviz_t* fviz_init() {
  auto ctx = std::make_unique<fviz_t>();
clip_t* clip_init() {
  auto ctx = std::make_unique<clip_t>();
  ctx->format = OutputFormat::SVG;
  return ctx.release();
}

void fviz_destroy(fviz_t* ctx) {
void clip_destroy(clip_t* ctx) {
  delete ctx;
}

const char* fviz_get_error(const fviz_t* ctx) {
const char* clip_get_error(const clip_t* ctx) {
  return ctx->error.message.c_str();
}

void fviz_set_error(fviz_t* ctx, const ReturnCode& err) {
void clip_set_error(clip_t* ctx, const ReturnCode& err) {
  ctx->error = err;
}

int fviz_eval(fviz_t* ctx, const char* expr) {
int clip_eval(clip_t* ctx, const char* expr) {
  Environment env;
  auto rc = fviz::eval(env, expr, ctx->format, &ctx->buffer);
  fviz_set_error(ctx, rc);
  auto rc = clip::eval(env, expr, ctx->format, &ctx->buffer);
  clip_set_error(ctx, rc);
  return rc;
}

void fviz_get_result(fviz_t* ctx, const void** data, size_t* data_len) {
void clip_get_result(clip_t* ctx, const void** data, size_t* data_len) {
  *data = ctx->buffer.data();
  *data_len = ctx->buffer.size();
}

int fviz_set_output_format(fviz_t* ctx, const char* path, const char* fmt) {
int clip_set_output_format(clip_t* ctx, const char* path, const char* fmt) {
  std::string format = fmt;

  if (format == "svg") {
@@ -70,7 +70,7 @@ int fviz_set_output_format(fviz_t* ctx, const char* path, const char* fmt) {
    return OK;
  }

  fviz_set_error(ctx, errorf(ERROR, "invalid output format: {}", format));
  clip_set_error(ctx, errorf(ERROR, "invalid output format: {}", format));
  return ERROR;
}
Loading