Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Live Chart over ISS #5730

Open
mortezabarzkar opened this issue Sep 11, 2024 · 5 comments
Open

Problem with Live Chart over ISS #5730

mortezabarzkar opened this issue Sep 11, 2024 · 5 comments

Comments

@mortezabarzkar
Copy link

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
Copy link
Author

mortezabarzkar commented Sep 12, 2024

it work after change

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

@stsrki
Copy link
Collaborator

stsrki commented Sep 12, 2024

Thanks for posting the solution.

@mortezabarzkar
Copy link
Author

@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
Copy link
Collaborator

stsrki commented Sep 12, 2024

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

@mortezabarzkar
Copy link
Author

mortezabarzkar commented Sep 12, 2024

@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 },
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants