Giter VIP home page Giter VIP logo

vizzuhq / ipyvizzu-story Goto Github PK

View Code? Open in Web Editor NEW
319.0 8.0 32.0 38.73 MB

Build, present and share animated data stories in Jupyter Notebook and similar environments.

Home Page: https://ipyvizzu-story.vizzuhq.com

License: Apache License 2.0

Python 10.50% HTML 0.41% Jupyter Notebook 89.09%
data-visualization interactive presentation template charting datastory datastorytelling notebook python

ipyvizzu-story's People

Contributors

blackary avatar khuyentran1401 avatar m1lk4 avatar parkerkain avatar petervidos avatar ravipiplani avatar simzer avatar veghdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipyvizzu-story's Issues

python and js development: support anim options

I'm trying to redo this example from ipyvizzu and get it working in ipyvizzu-story:
https://ipyvizzu.vizzuhq.com/examples/stories/musicformats/musicformats.html

I'm interested with this model because it looks to be the most complex out of all the examples available in vizzuhq website.

However in the first block of code, I encountered error:
NotImplementedError: Anim options are not supported.

the error came from these lines of code which I modify in order to make it work with ipyvizzu-story:

for year in range(1973, 2021):
    config["title"] = f"Music Revenue by Format - Year by Year {year}"
    slide1 = Slide(Step(
        Data.filter(f"parseInt(record.Year) == {year}"),
        Config(config),
        # duration=0.2,
        # x={"easing": "linear", "delay": 0},
        # y={"delay": 0},
        # show={"delay": 0},
        # hide={"delay": 0},
        # title={"duration": 0, "delay": 0},
    )
    )

    story.add_slide(slide1)

story.add_slide(slide1)
story.export_to_html('musicformats.html')

Those I comment-out were the lines that causing the error.
Without them I was able to export to html.

So is it possible to remake all the examples from ipyvizzu in ipyvizzu-story?
Or are there limitations in ipyvizzu-story library in terms of features compared to the ipyvizzu?

documentation: enable search box

mkdocs-jupyter adds notebook outputs into search index - wait for mkdocs-jupyter to be fixed or replace notebooks with js backend

python development: add vizzu property to Story class

Before implementation, it must be developed in the vizzu-story javascript package.

  • add vizzu_story url property to Story class
  • modify the html template
  • add unit tests

This property is used to change the url of the vizzu javascript package.

question: Colab issues

  • The chart appears but its horizontal and vertical size are both too big by default. -> added Story.set_size(width, height) method in 0.2.0 (for example: story.set_size("800px", "480px"))
  • PgUp, PgDn buttons scroll the notebook even after the chart is clicked vizzuhq/vizzu-story-js#43
  • Full screen button has no effect -> disabled in Colab, but there is a built-in view output fullscreen option

test compatibility in different platforms

test compatibility in different platforms,
create example and specify restrictions in docs/environments

  • H2O Wave
  • Plotly Dash/Dash
  • PyWebIO
  • EMR notebook (Pyspark kernel)
  • Anaconda Notebooks
  • Flask
  • JupyterLab
  • Voila
  • Noteable
  • Streamlit
  • Panel
  • Mercury (mljar)
  • Databricks
  • DataCamp
  • Deepnote
  • Google Colab
  • JupyterLite
  • Kaggle
  • Mode
  • PyCharm (Pro)
  • VSCode

question: story hangs if provided invalid Style Configuration, how to the check error

If an invalid Style is passed as part of a Story - the Story will infinitely generate a loading spinner when loading, rather than throwing an error. Not sure what happens on the backend here - but perhaps some validation of Styles may be needed to provide user friendly feedback if a style breaks.

image

The example I have below is obviously extreme, but I actually discovered this when trying to input what I thought might work as valid CSS, using "logo": {"display": "none"} to hide the logo. If I do this - I get the same infinitely spinning behavior. However, just changing the width to 0em produces the correct effect.

Reproducible code

import pandas as pd

from ipyvizzu import Data, Config, Style
from ipyvizzustory import Story, Slide, Step

# Create data object, read csv to data frame and add data frame to data object.
example_data = Data()
example_df = pd.read_csv(
    "complex.csv",
    dtype={"Year": str},
)
example_data.add_data_frame(example_df)

# Set the style of the charts in the story
example_style = Style(
    {
        "logo": {"BLAH": "BLAHBLAH"},
        # Replace above line with this and it will work again
        # "logo": {"width": "5em"},
    }
)

# Create story object, add data and style settings to it
# and set the size of the HTML element
# that appears within the notebook.
story = Story(data=example_data, style=example_style)
story.set_size("100%", "400px")


# Add the first slide,
# containing a single animation step that sets the initial chart.
slide1 = Slide(
    Step(
        # Only include rows where the Function value != Defense
        # Note, filters currently only accept JavaScript style filters,
        # hence the "!==", rather than "!="
        Data.filter("record.Function !== 'Defense'"),
        Config(
            {
                "channels": {
                    "y": {
                        "set": ["Amount[B$]", "Function"],
                        # Set the range of the y-axis
                        # to the min and max of the data being shown
                        # default value is 110% of the maximum value.
                        "range": {"min": "0%", "max": "100%"},
                    },
                    "x": {"set": ["Year"]},
                    "color": "Function",
                },
                "title": "Stacked Area Chart - U.S. R&D Budget in 1955-2020",
                "geometry": "area",
            }
        ),
    )
)
# Add the slide to the story
story.add_slide(slide1)

story.play()

question: Deepnote issues

  • The chart appears but its vertical size is constantly growing for some time -> added Story.set_size(width, height) method in 0.2.0 (for example: story.set_size("800px", "480px"))
  • PgUp, PgDn buttons scroll the notebook even after the chart is clicked vizzuhq/vizzu-story-js#43
  • Full screen button has no effect -> disabled in Deepnote

environment issues: ipyvizzu-story implementation in Flask

I want to share how I implemented ipyvizzu-story in Flask, please note since majority of the code is very similar to the complex template in vizzuhq website, the one I write here is how to implement in Flask and how to get the output in the HTML page:

## Starts with
from ipyvizzu import Data, Config, Chart, Style
from ipyvizzustory import Story, Slide, Step
import pandas as pd

DATA = Data()
df = pd.read_csv('filepath/filename')

DATA.add_data_frame(df)

## Placeholder where you set the Styling and add slides to the Story. This part of the code is exactly the same with the example in vizzuhq website

## Ends with
story.export_to_html('filepath/mystory.html')    # This is the most important line of code

In the HTML file for your Flask website, simply place this HTML tag:

<div class="container" id="timeseries">
    <iframe src=" {{url_for('static', filename='mystory.html')}}" seamless></iframe>
</div>

the id = 'timeseries' is just me naming the CSS styling for the iframe container. It can be named however you want.

There is actually a more efficient method to call the html without the need to export to html.
to_html() enables this however I cannot set a custom Style when using this to_html() method as it produces blank page.
So if I use default Style, the chart will appear correctly as expected.

Below is the code when using to_html() method:

## Ends with
vizzu = story.to_html()

return render_template(vizzu = vizzu)

The code for HTML file for the Flask website:

<div class="container" id="timeseries">
    <iframe src="data:text/html, {{ vizzu }}" seamless></iframe>
</div>

Hope this helps, cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.