Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/#921-bulder-api-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhlongviolin1 committed Oct 3, 2023
2 parents 7967b76 + 4fbff73 commit 335ac38
Show file tree
Hide file tree
Showing 112 changed files with 3,479 additions and 1,277 deletions.
30 changes: 8 additions & 22 deletions doc/examples/charts/advanced-annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy import Gui
from taipy.gui import Gui


# Function to plot: x^3/3 - x
def f(x):
return x*x*x/3-x
return x * x * x / 3 - x


# x values: [-2.2, ..., 2.2]
x = [(x-10)/4.5 for x in range(0, 21)]
x = [(x - 10) / 4.5 for x in range(0, 21)]

data = {
"x": x,
# y: [f(-2.2), ..., f(2.2)]
"y": [f(x) for x in x]
"y": [f(x) for x in x],
}


Expand All @@ -35,25 +36,10 @@ def f(x):
"title": "Local extrema",
"annotations": [
# Annotation for local maximum (x = -1)
{
"text": "Local <b>max</b>",
"font": {
"size": 20
},
"x": -1,
"y": f(-1)
},
{"text": "Local <b>max</b>", "font": {"size": 20}, "x": -1, "y": f(-1)},
# Annotation for local minimum (x = 1)
{
"text": "Local <b>min</b>",
"font": {
"size": 20
},
"x": 1,
"y": f(1),
"xanchor": "left"
}
]
{"text": "Local <b>min</b>", "font": {"size": 20}, "x": 1, "y": f(1), "xanchor": "left"},
],
}

page = """
Expand Down
10 changes: 6 additions & 4 deletions doc/examples/charts/advanced-selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy import Gui
from taipy.gui import Gui
import numpy
import random

Expand All @@ -23,14 +23,14 @@
data = {
"x": x,
# A list of random values within [1, 10]
"y": [random.uniform(1, 10) for _ in x]
"y": [random.uniform(1, 10) for _ in x],
}

layout = {
# Force the Box select tool
"dragmode": "select",
# Remove all margins around the plot
"margin": {"l":0,"r":0,"b":0,"t":0}
"margin": {"l": 0, "r": 0, "b": 0, "t": 0},
}

config = {
Expand All @@ -40,12 +40,14 @@

selected_indices = []

mean_value = 0.
mean_value = 0.0


def on_change(state, var, val):
if var == "selected_indices":
state.mean_value = numpy.mean([data["y"][idx] for idx in val]) if len(val) else 0


page = """
# Advanced - Selection
Expand Down
32 changes: 17 additions & 15 deletions doc/examples/charts/advanced-shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy import Gui
from taipy,gui import Gui


# Function to plot: x^3/3-x
def f(x):
return x*x*x/3-x
return x * x * x / 3 - x


# x values: [-2.2, ..., 2.2]
x = [(x-10)/4.5 for x in range(0, 21)]
x = [(x - 10) / 4.5 for x in range(0, 21)]

data = {
"x": x,
# y: [f(-2.2), ..., f(2.2)]
"y": [f(x) for x in x]
"y": [f(x) for x in x],
}

shape_size = 0.1
Expand All @@ -34,22 +36,22 @@ def f(x):
"shapes": [
# Shape for local maximum (x = -1)
{
"x0": -1-shape_size,
"y0": f(-1)-2*shape_size,
"x1": -1+shape_size,
"y1": f(-1)+2*shape_size,
"x0": -1 - shape_size,
"y0": f(-1) - 2 * shape_size,
"x1": -1 + shape_size,
"y1": f(-1) + 2 * shape_size,
"fillcolor": "green",
"opacity": 0.5
"opacity": 0.5,
},
# Shape for local minimum (x = 1)
{
"x0": 1-shape_size,
"y0": f(1)-2*shape_size,
"x1": 1+shape_size,
"y1": f(1)+2*shape_size,
"x0": 1 - shape_size,
"y0": f(1) - 2 * shape_size,
"x1": 1 + shape_size,
"y1": f(1) + 2 * shape_size,
"fillcolor": "red",
"opacity": 0.5
}
"opacity": 0.5,
},
]
}

Expand Down
16 changes: 5 additions & 11 deletions doc/examples/charts/advanced-unbalanced-datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,22 @@
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy import Gui
from taipy.gui import Gui

# The first data set uses the x interval [-10..10],
# with one point at every other unit
x1_range = [x*2 for x in range(-5, 6)]
x1_range = [x * 2 for x in range(-5, 6)]

# The second data set uses the x interval [-4..4],
# with ten point between every unit
x2_range = [x/10 for x in range(-40, 41)]
x2_range = [x / 10 for x in range(-40, 41)]

# Definition of the two data sets
data = [
# Coarse data set
{
"x": x1_range,
"Coarse": [x*x for x in x1_range]
},
{"x": x1_range, "Coarse": [x * x for x in x1_range]},
# Fine data set
{
"x": x2_range,
"Fine": [x*x for x in x2_range]
}
{"x": x2_range, "Fine": [x * x for x in x2_range]},
]

page = """
Expand Down
49 changes: 30 additions & 19 deletions doc/examples/charts/bar-facing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# python <script>
# -----------------------------------------------------------------------------------------
# Face-to-face bar charts example
from taipy import Gui
from taipy.gui import Gui
import numpy

n_years = 10
Expand All @@ -26,33 +26,44 @@
proportions_female[0] = 0.4
proportions_male[0] = proportions_female[0] * (1 + numpy.random.normal(0, 0.1))

for i in range(1,n_years):
mean_i = (0.5-proportions_female[i-1])/5
new_value = proportions_female[i-1] + numpy.random.normal(mean_i, 0.1)
new_value = min(max(0,new_value),1)
for i in range(1, n_years):
mean_i = (0.5 - proportions_female[i - 1]) / 5
new_value = proportions_female[i - 1] + numpy.random.normal(mean_i, 0.1)

new_value = min(max(0, new_value), 1)
proportions_female[i] = new_value
proportions_male[i] = proportions_female[i] * (1 + numpy.random.normal(0, 0.1))


data = {
"Hobbies" : ["Archery", "Tennis", "Football", "Basket", "Volley", "Golf", "Video-Games", "Reading", "Singing", "Music"],
"Female" : proportions_female,
# Negate these values so they appear to the left side
"Male" : -proportions_male
"Hobbies": [
"Archery",
"Tennis",
"Football",
"Basket",
"Volley",
"Golf",
"Video-Games",
"Reading",
"Singing",
"Music",
],
"Female": proportions_female,
# Negate these values so they appear to the left side
"Male": -proportions_male,
}

properties = {
# Shared y values
"y": "Hobbies",
"y": "Hobbies",
# Bars for the female data set
"x[1]": "Female",
"color[1]": "#c26391",
"x[1]": "Female",
"color[1]": "#c26391",
# Bars for the male data set
"x[2]": "Male",
"color[2]": "#5c91de",
"x[2]": "Male",
"color[2]": "#5c91de",
# Both data sets are represented with an horizontal orientation
"orientation": "h",
"orientation": "h",
#
"layout": {
# This makes left and right bars aligned on the same y value
Expand All @@ -61,8 +72,8 @@
"xaxis": {"title": "Gender"},
# Hide the legend
"showlegend": False,
"margin" : { "l": 100 }
}
"margin": {"l": 100},
},
}

page = """
Expand Down
31 changes: 26 additions & 5 deletions doc/examples/charts/bar-multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,35 @@
# python <script>
# -----------------------------------------------------------------------------------------
# Two data sets as a bar chart
from taipy import Gui
from taipy.gui import Gui
import pandas

# Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin
percentages=[(1852,50.83), (1856,45.29), (1860,39.65), (1864,55.03), (1868,52.66), (1872,55.58), (1876,47.92), (1880,48.31), (1884,48.85), (1888,47.80), (1892,46.02), (1896.,51.02), (1900,51.64), (1904,56.42), (1908,51.57), (1912,41.84), (1916,49.24), (1920,60.32), (1924,54.04), (1928,58.21)]
data = pandas.DataFrame(percentages, columns=['Year', 'Won'])
lost=[100-t[1] for t in percentages]
data['Lost'] = lost
percentages = [
(1852, 50.83),
(1856, 45.29),
(1860, 39.65),
(1864, 55.03),
(1868, 52.66),
(1872, 55.58),
(1876, 47.92),
(1880, 48.31),
(1884, 48.85),
(1888, 47.80),
(1892, 46.02),
(1896.0, 51.02),
(1900, 51.64),
(1904, 56.42),
(1908, 51.57),
(1912, 41.84),
(1916, 49.24),
(1920, 60.32),
(1924, 54.04),
(1928, 58.21),
]
data = pandas.DataFrame(percentages, columns=["Year", "Won"])
lost = [100 - t[1] for t in percentages]
data["Lost"] = lost

page = """
# Bar - Multiple
Expand Down
50 changes: 47 additions & 3 deletions doc/examples/charts/bar-simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,56 @@
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy import Gui
from taipy.gui import Gui
import pandas

# Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin
percentages=[(1852,50.83), (1856,45.29), (1860,39.65), (1864,55.03), (1868,52.66), (1872,55.58), (1876,47.92), (1880,48.31), (1884,48.85), (1888,47.80), (1892,46.02), (1896.,51.02), (1900,51.64), (1904,56.42), (1908,51.57), (1912,41.84), (1916,49.24), (1920,60.32), (1924,54.04), (1928,58.21), (1932,57.41), (1936,60.80), (1940,54.74), (1944,53.39), (1948,49.55), (1952,55.18), (1956,57.37), (1960,49.72), (1964,61.05), (1968,43.42), (1972,60.67), (1976,50.08), (1980,50.75), (1984,58.77), (1988,53.37), (1992,43.01), (1996,49.23), (2000,47.87), (2004,50.73), (2008,52.93), (2012,51.06), (2016,46.09), (2020,51.31)]
data = pandas.DataFrame(percentages, columns= ['Year','%'])
percentages = [
(1852, 50.83),
(1856, 45.29),
(1860, 39.65),
(1864, 55.03),
(1868, 52.66),
(1872, 55.58),
(1876, 47.92),
(1880, 48.31),
(1884, 48.85),
(1888, 47.80),
(1892, 46.02),
(1896.0, 51.02),
(1900, 51.64),
(1904, 56.42),
(1908, 51.57),
(1912, 41.84),
(1916, 49.24),
(1920, 60.32),
(1924, 54.04),
(1928, 58.21),
(1932, 57.41),
(1936, 60.80),
(1940, 54.74),
(1944, 53.39),
(1948, 49.55),
(1952, 55.18),
(1956, 57.37),
(1960, 49.72),
(1964, 61.05),
(1968, 43.42),
(1972, 60.67),
(1976, 50.08),
(1980, 50.75),
(1984, 58.77),
(1988, 53.37),
(1992, 43.01),
(1996, 49.23),
(2000, 47.87),
(2004, 50.73),
(2008, 52.93),
(2012, 51.06),
(2016, 46.09),
(2020, 51.31),
]
data = pandas.DataFrame(percentages, columns=["Year", "%"])

page = """
# Bar - Simple
Expand Down
Loading

0 comments on commit 335ac38

Please sign in to comment.