它托管在 GitHub Pages 上,在我的笔记本电脑上运行完全正常:

我在这里复制了代码。这可能有什么问题吗?
async function drawLineChart() {
const pathToCsv = 'https://raw.githubusercontent.com/dsibi/portfolio/main/projects/line-graph-2/data/time_entries.csv';
let rawDataset = await d3.dsv(";", pathToCsv);
const record = {
date: '',
duration: ''
};
let dataset = [];
for (let i = 0; i < rawDataset.length; i++) {
let currRecord = Object.create(record);
const [day, month, year] = rawDataset[i]['Start date'].split('.');
currRecord.date = new Date(+year, +month - 1, +day);
const [hours, minutes, seconds] = rawDataset[i]['Duration'].split(':');
currRecord.duration = …Run Code Online (Sandbox Code Playgroud)我在 Python 中绘制了 scatter_geo 图。
import plotly.express as px
import pandas as pd
rows=[['501-600','65','122.58333','45.36667'],
['till 500','54','12.5','27.5'],
['more 1001','51','-115.53333','38.08'],
['601-1000','54','120.54167','21.98'],
]
colmns=['bins','data','longitude','latitude']
df=pd.DataFrame(data=rows, columns=colmns)
fig=px.scatter_geo(df,lon='longitude', lat='latitude',color='bins',
opacity=0.5,
projection="natural earth")
fig.show()
Run Code Online (Sandbox Code Playgroud)
如果我只有一条数据痕迹,是否有可能在图例标签中自定义顺序?
因为现在图例中的标签如下所示:
501-600
till 500
more 1001
601-1000
Run Code Online (Sandbox Code Playgroud)
我需要让它们看起来像这样:
till 500
501-600
601-1000
more 1001
Run Code Online (Sandbox Code Playgroud) 我想修改悬停数据并将其保留为仅bins数据。我编写了以下代码,但hover_data参数不起作用。修改哈弗数据的方法是什么?
import plotly.express as px
import plotly.graph_objs as go
import pandas as pd
rows=[['501-600','15','122.58333','45.36667'],
['till 500','4','12.5','27.5'],
['more 1001','41','-115.53333','38.08'],
]
colmns=['bins','data','longitude','latitude']
df=pd.DataFrame(data=rows, columns=colmns)
df = df.astype({"data": int})
fig=px.scatter_geo(df,lon='longitude', lat='latitude',
color='bins',
opacity=0.5,
size='data',
projection="natural earth", hover_data=(['bins']))
fig.add_trace(go.Scattergeo(lon=df["longitude"],
lat=df["latitude"],
text=df["data"],
textposition="middle center",
mode='text',
showlegend=False))
fig.show()
Run Code Online (Sandbox Code Playgroud)