Exemplo n.º 1
0
 def _get_deltas_that_melt_dataframes(self):
     return [
         lambda df: st._legacy_line_chart(df),
         lambda df: st._legacy_bar_chart(df),
         lambda df: st._legacy_area_chart(df),
     ]
Exemplo n.º 2
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from datetime import date

import pandas as pd
import streamlit as st

df = pd.DataFrame({
    "index": [
        date(2019, 8, 9),
        date(2019, 8, 10),
        date(2019, 8, 11),
        date(2019, 8, 12),
    ],
    "numbers": [10, 50, 30, 40],
})

df.set_index("index", inplace=True)

# st._legacy_area/_legacy_bar/_legacy_line_chart all use Altair/Vega-Lite under the hood.
# By default, Vega-Lite displays time values in the browser's local
# time zone. In `altair.generate_chart`, we explicitly set the time
# display to UTC, so that our results are consistent. This test verifies
# that change!
st._legacy_area_chart(df)
st._legacy_bar_chart(df)
st._legacy_line_chart(df)
Exemplo n.º 3
0
data = pd.DataFrame({"a": [1, 2, 3, 4], "b": [1, 3, 2, 4]})

spec = {
    "mark": "line",
    "encoding": {
        "x": {"field": "a", "type": "quantitative"},
        "y": {"field": "b", "type": "quantitative"},
    },
}

# 5 empty charts
st._legacy_vega_lite_chart(spec, use_container_width=True)
fig, ax = plt.subplots()
st.pyplot(fig, use_container_width=True)
st._legacy_line_chart()
st._legacy_bar_chart()
st._legacy_area_chart()

# 1 empty map
# comment this one out to avoid this Cypress-Mapbox related error.
# ref: https://github.com/cypress-io/cypress/issues/4322
# st.pydeck_chart()
# st.map()

# 6 errors
try:
    st._legacy_vega_lite_chart({}, use_container_width=True)
except Exception as e:
    st.write(e)

try: