<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python visuals doesn't work on online reading view but on desktop does in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4310241#M11841</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since a couple of day maybe week, i didn't noticed that one of my own python visual didn't work on the online version. On my dekstop app, nothing, it work well but only when i share the link and open it via my workspace the visual doesn't work anymore.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;there erreur that i have is this one :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Script Runtime Error

[S-12c5e384-a869-4a16-9c4a-12dd6770c94c][S-12c5e384-a869-4a16-9c4a-12dd6770c94c]AttributeError: 'NoneType' object has no attribute 'points_to_pixels'
Please try again later or contact support. If you contact support, please provide these details.

Activity ID: fb2167c7-a9c2-4229-ba95-dd2df542479d
Request ID: d0f51534-072d-4d2e-a767-651859b64a82
Correlation ID: 101ac569-2fa3-434e-5997-79102e36e5a0
Time: Mon Dec 02 2024 18:25:33 GMT+0100 (Central European Standard Time)
Service version: 13.0.24766.27
Client version: 2411.3.21845-train
Cluster URI: https://wabi-west-europe-b-primary-redirect.analysis.windows.net/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is but i am not sure that it come from him because nothing change since a couple of months...&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.dates as mdates
from matplotlib.dates import DateFormatter, MonthLocator

# Supposons que dataset soit un DataFrame pandas déjà défini
dataset['Date update'] = pd.to_datetime(dataset['Date update'])
dataset['Forecast'] = pd.to_datetime(dataset['Forecast'])

# Pivot table
pivot = pd.pivot_table(dataset, aggfunc='first', index='Date update', values='Forecast', columns='Milestones name')
fig, ax = plt.subplots(figsize=(12, 8))

# Plot each column
for column in pivot.columns:
    clean = pivot[[column]].dropna()
    ax.plot_date(clean.index, clean[column], xdate=True, ydate=True, ls='-', lw=1, label=column)

# Ajuster les limites des axes pour découpler Date update (axe x) et Forecast (axe y)
min_date_update = dataset['Date update'].min()
max_date_update = dataset['Date update'].max()

min_forecast = dataset['Forecast'].min()
max_forecast = dataset['Forecast'].max()

# Dates limites pour les axes
max_date_forecast = max(dataset['Forecast'])
next_year_forecast = max_date_forecast.year + 1
q1_next_year_forecast = pd.Timestamp(year=next_year_forecast, month=1, day=1)

min_date_forecast = min(dataset['Forecast'])
min_year_forecast = min_date_forecast.year
q1_actual_year_forecast = pd.Timestamp(year=min_year_forecast, month=1, day=1)

min_date_update = min(dataset['Date update'])
min_year_dateupdate = min_date_update.year
q1_actual_year_dateupdate = pd.Timestamp(year=min_year_dateupdate, month=1, day=1)

# Ajouter la ligne 45 degrés (y=x)
# Créer des listes de dates pour la ligne 45 degrés
line_dates = pd.date_range(start=q1_actual_year_dateupdate, end=q1_next_year_forecast, freq='D')
ax.plot(line_dates, line_dates, color='black', linestyle='--', label='')

# Coloration après les courbes
adjusted_min_date_update = q1_actual_year_dateupdate
adjusted_max_forecast = q1_next_year_forecast
if len(line_dates) &amp;gt; 0:
    ax.fill_between(line_dates, adjusted_min_date_update, line_dates, color='white', zorder=2)

# -----------------------------------------------------------------------------------------------

# Définir les localisateurs pour les mois (trimestres)

month_locator = MonthLocator(bymonth=[1, 4, 7, 10])

plt.gca().xaxis.set_major_locator(month_locator)
plt.gca().yaxis.set_major_locator(month_locator)

# Création du formateur personnalisé pour afficher les trimestres
class QuarterFormatter(DateFormatter):
    def __init__(self, fmt='%Y-%m', **kwargs):
        super().__init__(fmt, **kwargs)

    def __call__(self, x, pos=0):
        date = mdates.num2date(x)
        # Si c'est janvier, afficher l'année en dessous de Q1
        if date.month == 1:
            return f'{date.year} - Q1'
        elif date.month == 4:
            return 'Q2'
        elif date.month == 7:
            return 'Q3'
        elif date.month == 10:
            return 'Q4'
        return ''

# Appliquer le formateur de trimestre personnalisé
quarter_formatter = QuarterFormatter()
plt.gca().xaxis.set_major_formatter(quarter_formatter)
plt.gca().yaxis.set_major_formatter(quarter_formatter)

# -----------------------------------------------------------------------------------------------

# Rotation des étiquettes pour une meilleure lisibilité
plt.xticks(rotation=90, ha='center')

# Ajouter les lignes de grille pour les années uniquement
start_date_update = pd.Timestamp(year=q1_actual_year_dateupdate.year, month=1, day=1)
end_date_forecast = pd.Timestamp(year=q1_next_year_forecast.year, month=1, day=1)
for year in range(start_date_update.year, end_date_forecast.year):
    january_start = pd.Timestamp(year=year, month=1, day=1)
    ax.axvline(x=january_start, color='gray', linestyle='--', linewidth=0.5)
    ax.axhline(y=january_start, color='gray', linestyle='--', linewidth=0.5)

# -----------------------------------------------------------------------------------------------

# Ajuster les limites des axes
plt.xlim(q1_actual_year_dateupdate, q1_next_year_forecast)  # Limites pour l'axe des x (Date update)
plt.ylim(q1_actual_year_dateupdate, q1_next_year_forecast)   # Limites pour l'axe des y (Forecast)

# -----------------------------------------------------------------------------------------------
legend = ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1), frameon=False)
# Ajuster la légende
def adjust_legend_fontsize(ax):
    legend = ax.get_legend()  # Récupère la légende existante
    if legend is None:  # Si aucune légende n'est définie, arrêter
        return 10

    fig = ax.get_window_extent()
    fig_height = fig.height 
    fontsize = 10
    adjusted = False
    while not adjusted:
        legend = ax.legend(loc='upper left', bbox_to_anchor=(1, 1), fontsize=fontsize)
        legend_bbox = legend.get_window_extent()
        legend_height = legend_bbox.height
        if legend_height &amp;lt;= fig_height:
            adjusted = True
        else:
            fontsize -= 1
            if fontsize &amp;lt; 8:
                break
    return fontsize
ax = plt.gca()
fontsize = adjust_legend_fontsize(ax)
myLegend = ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1), frameon=False, fontsize=fontsize)

# Désactiver les ajustements automatiques des marges
plt.subplots_adjust(left=0.08, right=0.75, top=0.95, bottom=0.1)

# Afficher le graphique
plt.show()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have an idea, that coudl help me !!&amp;nbsp;&lt;BR /&gt;thanks you very much in advance, and have a nice day !&lt;/P&gt;&lt;P&gt;Flan&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2024 17:33:09 GMT</pubDate>
    <dc:creator>Flan</dc:creator>
    <dc:date>2024-12-02T17:33:09Z</dc:date>
    <item>
      <title>Python visuals doesn't work on online reading view but on desktop does</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4310241#M11841</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since a couple of day maybe week, i didn't noticed that one of my own python visual didn't work on the online version. On my dekstop app, nothing, it work well but only when i share the link and open it via my workspace the visual doesn't work anymore.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;there erreur that i have is this one :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Script Runtime Error

[S-12c5e384-a869-4a16-9c4a-12dd6770c94c][S-12c5e384-a869-4a16-9c4a-12dd6770c94c]AttributeError: 'NoneType' object has no attribute 'points_to_pixels'
Please try again later or contact support. If you contact support, please provide these details.

Activity ID: fb2167c7-a9c2-4229-ba95-dd2df542479d
Request ID: d0f51534-072d-4d2e-a767-651859b64a82
Correlation ID: 101ac569-2fa3-434e-5997-79102e36e5a0
Time: Mon Dec 02 2024 18:25:33 GMT+0100 (Central European Standard Time)
Service version: 13.0.24766.27
Client version: 2411.3.21845-train
Cluster URI: https://wabi-west-europe-b-primary-redirect.analysis.windows.net/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is but i am not sure that it come from him because nothing change since a couple of months...&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.dates as mdates
from matplotlib.dates import DateFormatter, MonthLocator

# Supposons que dataset soit un DataFrame pandas déjà défini
dataset['Date update'] = pd.to_datetime(dataset['Date update'])
dataset['Forecast'] = pd.to_datetime(dataset['Forecast'])

# Pivot table
pivot = pd.pivot_table(dataset, aggfunc='first', index='Date update', values='Forecast', columns='Milestones name')
fig, ax = plt.subplots(figsize=(12, 8))

# Plot each column
for column in pivot.columns:
    clean = pivot[[column]].dropna()
    ax.plot_date(clean.index, clean[column], xdate=True, ydate=True, ls='-', lw=1, label=column)

# Ajuster les limites des axes pour découpler Date update (axe x) et Forecast (axe y)
min_date_update = dataset['Date update'].min()
max_date_update = dataset['Date update'].max()

min_forecast = dataset['Forecast'].min()
max_forecast = dataset['Forecast'].max()

# Dates limites pour les axes
max_date_forecast = max(dataset['Forecast'])
next_year_forecast = max_date_forecast.year + 1
q1_next_year_forecast = pd.Timestamp(year=next_year_forecast, month=1, day=1)

min_date_forecast = min(dataset['Forecast'])
min_year_forecast = min_date_forecast.year
q1_actual_year_forecast = pd.Timestamp(year=min_year_forecast, month=1, day=1)

min_date_update = min(dataset['Date update'])
min_year_dateupdate = min_date_update.year
q1_actual_year_dateupdate = pd.Timestamp(year=min_year_dateupdate, month=1, day=1)

# Ajouter la ligne 45 degrés (y=x)
# Créer des listes de dates pour la ligne 45 degrés
line_dates = pd.date_range(start=q1_actual_year_dateupdate, end=q1_next_year_forecast, freq='D')
ax.plot(line_dates, line_dates, color='black', linestyle='--', label='')

# Coloration après les courbes
adjusted_min_date_update = q1_actual_year_dateupdate
adjusted_max_forecast = q1_next_year_forecast
if len(line_dates) &amp;gt; 0:
    ax.fill_between(line_dates, adjusted_min_date_update, line_dates, color='white', zorder=2)

# -----------------------------------------------------------------------------------------------

# Définir les localisateurs pour les mois (trimestres)

month_locator = MonthLocator(bymonth=[1, 4, 7, 10])

plt.gca().xaxis.set_major_locator(month_locator)
plt.gca().yaxis.set_major_locator(month_locator)

# Création du formateur personnalisé pour afficher les trimestres
class QuarterFormatter(DateFormatter):
    def __init__(self, fmt='%Y-%m', **kwargs):
        super().__init__(fmt, **kwargs)

    def __call__(self, x, pos=0):
        date = mdates.num2date(x)
        # Si c'est janvier, afficher l'année en dessous de Q1
        if date.month == 1:
            return f'{date.year} - Q1'
        elif date.month == 4:
            return 'Q2'
        elif date.month == 7:
            return 'Q3'
        elif date.month == 10:
            return 'Q4'
        return ''

# Appliquer le formateur de trimestre personnalisé
quarter_formatter = QuarterFormatter()
plt.gca().xaxis.set_major_formatter(quarter_formatter)
plt.gca().yaxis.set_major_formatter(quarter_formatter)

# -----------------------------------------------------------------------------------------------

# Rotation des étiquettes pour une meilleure lisibilité
plt.xticks(rotation=90, ha='center')

# Ajouter les lignes de grille pour les années uniquement
start_date_update = pd.Timestamp(year=q1_actual_year_dateupdate.year, month=1, day=1)
end_date_forecast = pd.Timestamp(year=q1_next_year_forecast.year, month=1, day=1)
for year in range(start_date_update.year, end_date_forecast.year):
    january_start = pd.Timestamp(year=year, month=1, day=1)
    ax.axvline(x=january_start, color='gray', linestyle='--', linewidth=0.5)
    ax.axhline(y=january_start, color='gray', linestyle='--', linewidth=0.5)

# -----------------------------------------------------------------------------------------------

# Ajuster les limites des axes
plt.xlim(q1_actual_year_dateupdate, q1_next_year_forecast)  # Limites pour l'axe des x (Date update)
plt.ylim(q1_actual_year_dateupdate, q1_next_year_forecast)   # Limites pour l'axe des y (Forecast)

# -----------------------------------------------------------------------------------------------
legend = ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1), frameon=False)
# Ajuster la légende
def adjust_legend_fontsize(ax):
    legend = ax.get_legend()  # Récupère la légende existante
    if legend is None:  # Si aucune légende n'est définie, arrêter
        return 10

    fig = ax.get_window_extent()
    fig_height = fig.height 
    fontsize = 10
    adjusted = False
    while not adjusted:
        legend = ax.legend(loc='upper left', bbox_to_anchor=(1, 1), fontsize=fontsize)
        legend_bbox = legend.get_window_extent()
        legend_height = legend_bbox.height
        if legend_height &amp;lt;= fig_height:
            adjusted = True
        else:
            fontsize -= 1
            if fontsize &amp;lt; 8:
                break
    return fontsize
ax = plt.gca()
fontsize = adjust_legend_fontsize(ax)
myLegend = ax.legend(loc='upper left', bbox_to_anchor=(1.01, 1), frameon=False, fontsize=fontsize)

# Désactiver les ajustements automatiques des marges
plt.subplots_adjust(left=0.08, right=0.75, top=0.95, bottom=0.1)

# Afficher le graphique
plt.show()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have an idea, that coudl help me !!&amp;nbsp;&lt;BR /&gt;thanks you very much in advance, and have a nice day !&lt;/P&gt;&lt;P&gt;Flan&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 17:33:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4310241#M11841</guid>
      <dc:creator>Flan</dc:creator>
      <dc:date>2024-12-02T17:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python visuals doesn't work on online reading view but on desktop does</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4310480#M11842</link>
      <description>&lt;P&gt;Maybe read through the release notes of these two libraries - could be that a recent version update has caused that.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 22:17:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4310480#M11842</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-12-02T22:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python visuals doesn't work on online reading view but on desktop does</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4311416#M11844</link>
      <description>&lt;P&gt;Hi !&amp;nbsp;&lt;BR /&gt;Unfortunately, even with librabries updated, it still doesn't work.&lt;BR /&gt;It's weird because others visual work so i guess there is an issue with this one in particular... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 10:17:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4311416#M11844</guid>
      <dc:creator>Flan</dc:creator>
      <dc:date>2024-12-03T10:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Python visuals doesn't work on online reading view but on desktop does</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4311677#M11845</link>
      <description>&lt;P&gt;If you have a Pro license you can open a Pro ticket at &lt;A href="https://admin.powerplatform.microsoft.com/newsupportticket/powerbi" target="_blank"&gt;https://admin.powerplatform.microsoft.com/newsupportticket/powerbi&lt;/A&gt;&lt;BR /&gt;Otherwise you can raise an issue at &lt;A href="https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues&lt;/A&gt; .&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 13:45:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Python-visuals-doesn-t-work-on-online-reading-view-but-on/m-p/4311677#M11845</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-12-03T13:45:58Z</dc:date>
    </item>
  </channel>
</rss>

