Skip to content

Commit

Permalink
Merge branch 'master' into v4.2.X
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Dec 29, 2021
2 parents c81877f + d44c148 commit f654bbe
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion altair/__init__.py
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = "4.2.0rc1"
__version__ = "4.2.0"

from .vegalite import *
from . import examples
Expand Down
2 changes: 1 addition & 1 deletion altair/examples/line_with_log_scale.py
@@ -1,7 +1,7 @@
"""
Line Chart with Logarithmic Scale
---------------------------------
How to make a line chart on a `<Logarithmic scale> https://en.wikipedia.org/wiki/Logarithmic_scale`_.
How to make a line chart on a `Logarithmic scale <https://en.wikipedia.org/wiki/Logarithmic_scale>`_.
"""
# category: line charts
import altair as alt
Expand Down
19 changes: 19 additions & 0 deletions altair/examples/pyramid.py
@@ -0,0 +1,19 @@
"""
Pyramid Pie Chart
-----------------
Altair reproduction of http://robslink.com/SAS/democd91/pyramid_pie.htm
"""
import altair as alt
import pandas as pd

category = ['Sky', 'Shady side of a pyramid', 'Sunny side of a pyramid']
color = ["#416D9D", "#674028", "#DEAC58"]
df = pd.DataFrame({'category': category, 'value': [75, 10, 15]})

alt.Chart(df).mark_arc(outerRadius=80).encode(
alt.Theta('value:Q', scale=alt.Scale(range=[2.356, 8.639])),
alt.Color('category:N',
scale=alt.Scale(domain=category, range=color),
legend=alt.Legend(title=None, orient='none', legendX=160, legendY=50)),
order='value:Q'
).properties(width=150, height=150).configure_view(strokeOpacity=0)
33 changes: 19 additions & 14 deletions altair/utils/html.py
Expand Up @@ -85,6 +85,7 @@
"""
<div id="{{ output_div }}"></div>
<script type="text/javascript">
var VEGA_DEBUG = (typeof VEGA_DEBUG == "undefined") ? {} : VEGA_DEBUG;
(function(spec, embedOpt){
let outputDiv = document.currentScript.previousElementSibling;
if (outputDiv.id !== "{{ output_div }}") {
Expand All @@ -97,15 +98,21 @@
"vega-embed": "{{ base_url }}/vega-embed@{{ vegaembed_version }}?noext",
};
function loadScript(lib) {
return new Promise(function(resolve, reject) {
var s = document.createElement('script');
s.src = paths[lib];
s.async = true;
s.onload = () => resolve(paths[lib]);
s.onerror = () => reject(`Error loading script: ${paths[lib]}`);
document.getElementsByTagName("head")[0].appendChild(s);
});
function maybeLoadScript(lib, version) {
var key = `${lib.replace("-", "")}_version`;
return (VEGA_DEBUG[key] == version) ?
Promise.resolve(paths[lib]) :
new Promise(function(resolve, reject) {
var s = document.createElement('script');
document.getElementsByTagName("head")[0].appendChild(s);
s.async = true;
s.onload = () => {
VEGA_DEBUG[key] = version;
return resolve(paths[lib]);
};
s.onerror = () => reject(`Error loading script: ${paths[lib]}`);
s.src = paths[lib];
});
}
function showError(err) {
Expand All @@ -121,12 +128,10 @@
if(typeof define === "function" && define.amd) {
requirejs.config({paths});
require(["vega-embed"], displayChart, err => showError(`Error loading script: ${err.message}`));
} else if (typeof vegaEmbed === "function") {
displayChart(vegaEmbed);
} else {
loadScript("vega")
.then(() => loadScript("vega-lite"))
.then(() => loadScript("vega-embed"))
maybeLoadScript("vega", "{{vega_version}}")
.then(() => maybeLoadScript("vega-lite", "{{vegalite_version}}"))
.then(() => maybeLoadScript("vega-embed", "{{vegaembed_version}}"))
.catch(showError)
.then(() => displayChart(vegaEmbed));
}
Expand Down
3 changes: 3 additions & 0 deletions doc/Makefile
Expand Up @@ -67,18 +67,21 @@ clean-all: clean clean-generated clean-images

.PHONY: html
html:
mkdir -p _images
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

.PHONY: dirhtml
dirhtml:
mkdir -p _images
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

.PHONY: singlehtml
singlehtml:
mkdir -p _images
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Expand Up @@ -73,7 +73,7 @@
# built documents.
#
# The short X.Y version.
version = "4.2.0rc1"
version = "4.2.0"
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
4 changes: 2 additions & 2 deletions doc/releases/changes.rst
Expand Up @@ -3,8 +3,8 @@
Altair Change Log
=================

Version 4.2.0 (unreleased)
--------------------------
Version 4.2.0 (released Dec 29, 2021)
-------------------------------------
- Update Vega-Lite from version 4.8.1 to version 4.17.0;
see `Vega-Lite Release Notes <https://github.com/vega/vega-lite/releases>`_.

Expand Down
4 changes: 0 additions & 4 deletions doc/user_guide/customization.rst
Expand Up @@ -512,10 +512,6 @@ Here is an example of setting the step width for a discrete scale:

The width of the bars are set using ``mark_bar(size=30)`` and the width that is allocated for each bar bar in the the chart is set using ``width=alt.Step(100)``

.. note::

If both ``width`` and ``rangeStep`` are specified, then ``rangeStep`` will be ignored.


.. _customization-chart-size:

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,6 +1,6 @@
entrypoints
jinja2
jsonschema>=3.0,<4.0
jsonschema>=3.0
numpy
pandas>=0.18
toolz
1 change: 1 addition & 0 deletions requirements_dev.txt
Expand Up @@ -4,6 +4,7 @@ ipython
flake8
pytest
sphinx
mistune<2.0.0 # necessary for m2r v0.2
m2r
vega_datasets
recommonmark

0 comments on commit f654bbe

Please sign in to comment.