Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.32k stars 535 forks source link

Problem with Live Chart over ISS #5730

Open mortezabarzkar opened 2 months ago

mortezabarzkar commented 2 months ago

Hi, i have live chart on my page, and it workes perfectly on IISExpress , but when i published it on IIS chart dataset dose not loaded.

Is it a known feature in the trial version?

mortezabarzkar commented 2 months ago

it work after change

<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> to <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />

stsrki commented 2 months ago

Thanks for posting the solution.

mortezabarzkar commented 2 months ago

@stsrki After restarting the application pool, it works for the first time at startup, but when I refresh it, the chart still does not appear.

stsrki commented 2 months ago

We host our web and demos on IIS, so it should work.

mortezabarzkar commented 2 months ago

@stsrki am I doing something wrong somewhere?

@using Blazorise.Charts.Streaming
<Card>
    <CardBody>

        <Grid>
            <LineChart @ref="horizontalLineChart" TItem="LiveDataPoint" OptionsObject="@horizontalLineChartOptions">
                <ChartStreaming TItem="LiveDataPoint"
                                Options="new ChartStreamingOptions { Delay = 0,Duration = 900000,Refresh=5000 }"
                                Refreshed="@OnHorizontalLineRefreshed" />
            </LineChart>
        </Grid>
    </CardBody>
</Card>

LineChart<LiveDataPoint> horizontalLineChart;
List<LiveDataPoint> liveDataPoints = new List<LiveDataPoint>();`
protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        try
        {
            var data = await GetInitData.Invoke();
            foreach( var item in data)
            logger.Info($"{Title} {item.time} -> {item.cnt}");
            if (data?.Any() ?? false)
            {
                foreach (var item in data.OrderBy(c => c.time).ToList())
                {
                    liveDataPoints.Add(new LiveDataPoint
                    {
                        X = item.time,
                        Y = item.cnt,
                    });
                }
                lastRecive = data.Max(c => c.time);
            }
            await Task.WhenAll(
                HandleRedraw(horizontalLineChart, GetLineChartDataset1));

            await horizontalLineChart.Resize();
            await InvokeAsync(StateHasChanged);
        }
        catch (Exception ex)
        {
            logger.Error(ex);
        }
    }
}
async Task HandleRedraw<TDataSet, TItem, TOptions, TModel>(BaseChart<TDataSet, TItem, TOptions, TModel> chart, params Func<TDataSet>[] getDataSets)
    where TDataSet : ChartDataset<TItem>
    where TOptions : ChartOptions
    where TModel : ChartModel
{
    await chart.Clear();

    await chart.AddLabelsDatasetsAndUpdate(Labels, getDataSets.Select(x => x.Invoke()).ToArray());
}
LineChartDataset<LiveDataPoint> GetLineChartDataset1()
{

    return new LineChartDataset<LiveDataPoint>
    {
        Data = liveDataPoints,
        Label = Title,
        BackgroundColor = backgroundColors[1],
        BorderColor = borderColors[1],
        //Fill = true,
        Tension = 0,
        ShowLine = true,
        SpanGaps = true,

        //BorderDash = new List<int> { 8, 4 },
    };
}