Replies: 9 comments 1 reply
-
@ice6 Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem. |
Beta Was this translation helpful? Give feedback.
-
@ice6 please show the detail about |
Beta Was this translation helpful? Give feedback.
-
private async Task<ChartDataSource> OnInitAspectRatio(bool stacked)
{
var products = await WarehouseService.GetAllProductsAsync();
products = products.Where(p => !p.Hide).ToList();
var topLabels = new string[] { "SKU数量", "库存数量" };
var ds = new ChartDataSource();
ds.Options.Title = "SKU/库存 统计";
ds.Options.X.Title = "产品分类";
ds.Options.Y.Title = "件数";
ds.Options.X.Stacked = stacked;
ds.Options.Y.Stacked = stacked;
ds.Labels = products.Select(p => p.Name);
for (var labelIndex = 0; labelIndex < topLabels.Length; labelIndex++)
{
int index = labelIndex;// prevent closure(闭包)
var label = topLabels[index];
ds.Data.Add(new ChartDataset()
{
Label = label,
Data = products.Select(p => index == 0 ? p.SkuCount : p.TotalStock).Cast<object>()
});
}
return ds;
} before narrow the windowafter narrow the windowuntil I narrow it down as mobile, it becomes
|
Beta Was this translation helpful? Give feedback.
-
@ice6 hi. could you submit a mini-pro-project for this? I think there are other problems. I can find the cause based on your project. https://www.blazor.zone/chart/line works fine. |
Beta Was this translation helpful? Give feedback.
-
@ArgoZhang Hi, I finally fix my problem. I changed the <div class="row g-3 mt-2">
<div class="col-12 d-flex justify-content-center">
<Chart ChartType="ChartType.Bar" Responsive="true" OnInitAsync="() => OnInitAspectRatio(true)" Title="SKU/库存 统计" Height="500px" Width="99%" />
</div>
</div> Nothing else changed. |
Beta Was this translation helpful? Give feedback.
-
@ice6 Although the problem is solved, I don't think it is the best solution. :) |
Beta Was this translation helpful? Give feedback.
-
@ArgoZhang sure, it is not. I'm catching up. I am quite sure it is a bug, because the same problem occurs on the |
Beta Was this translation helpful? Give feedback.
-
@ice6 The followingcharts are made in this way. The above charts are responsive, you can take a closer look |
Beta Was this translation helpful? Give feedback.
-
@ArgoZhang ok, thank you. I will take a source code level closer look :) |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Describe the bug
my code:
when the window become wider, it works very well.
but when the window become narrow, the chart keep same size.
Expected Behavior
when the window become narrow, the chart can also change its own size to fit the parent container.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions