JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums Charts & Data Viz Update Chart – always showing first graph, and not new graph

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #108974
    salasidis
    Participant

    Another issue I am having is that the graph is created OK, but any new graph that is created of a different variable, does not graph the new graph but displays the old graph

    My graph is defined in html within a window

     

    <Window @ref=”graphWindow” IsOpened=”@graphOpened” label=”Graph” ResizeMode=”WindowResizeMode.Both” OnClose=”GraphButtonOnClickClose” Modal=”true”>

    <div id=”article”>
    <section>
    <Button id=”GraphOpenButton” OnClick=”GraphButtonOnClickClose”>Close</Button>
    </section>
    <section>
    <Chart @ref=”lineChart” DataSource=”chartData” Animation=”Animation.None” Caption=”” Description=””
    ShowLegend=”false” ShowBorderLine=”false” Padding=”new Padding() { Left = 5, Top = 15, Right = 25, Bottom = 5 }”
    XAxis=”xAxis” SeriesGroups=”seriesGroups” ColorScheme=”ChartColorScheme.Scheme01″ OnReady=”OnChartReady” @key=”updateChart”/>
    </section>
    </div>
    </Window>

     

    I have an @key value that uses a variable I change when I change the data in the graph

     

     

    The chart lists are defined as

    ChartXAxis xAxis = new ChartXAxis()

    {
    DataField = “DateTm”,
    DisplayText = “Date”,
    DateFormat = “yyyy-mm-dd hh:mm”,
    TextRotationAngle = 90,
    BaseUnit = ChartBaseUnit.Hour,
    };

    IEnumerable<object> chartData;

    List<ChartSeriesGroup> seriesGroups = new List<ChartSeriesGroup>(){
    new ChartSeriesGroup()
    {

    Type = ChartType.Line,
    ValueAxis = new ChartValueAxis()
    {
    //UnitInterval = 10,
    //MinValue = 0,
    //MaxValue = 100,

    AxisSize = “auto”,
    Description = “Val”
    },

    Bands = new List<ChartSeriesGroupBand>()
    {
    new ChartSeriesGroupBand()
    {
    Opacity = (float)0.05,
    MinValue = 10,
    MaxValue = 20
    }
    },

    Series = new List<ChartSeriesGroupSerie>()
    {
    new ChartSeriesGroupSerie()
    {
    DataField = “”,
    DisplayText = “”,

    }
    }
    }

    };

     

     

    Finally, the data is acquired from the SQL database, and then the chartData variable is equated to this list, and the graph is enabled, teh chartFlag upfdated, and StatusHasChanged() is called.

     

    EWparData = await Http.GetFromJsonAsync<List<Ewdata>>($”/api/Ewdata?pId={Uri.EscapeDataString(pId.ToString())}”);

    // insert the data into the drop down list

    if (EWparData != null)
    {
    // data to graph
    // Use a regular chart, nor range area, as more data present – the min max values area will be the last entry’s min max values (in devParam)
    chartData = EWparData;

    seriesGroups.ElementAt(0).Series.ElementAt(0).DataField = “Result”;
    seriesGroups.ElementAt(0).Series.ElementAt(0).DisplayText = par;

    seriesGroups.ElementAt(0).ValueAxis.Description = par;

    seriesGroups.ElementAt(0).Bands.ElementAt(0).Opacity = (float)0.05;
    seriesGroups.ElementAt(0).Bands.ElementAt(0).MinValue = (float)minN;
    seriesGroups.ElementAt(0).Bands.ElementAt(0).MaxValue = (float)maxN;

    dispChart = true;
    //updateFlag++;
    updateChart++;
    graphOpened = true;
    StateHasChanged();
    }

     

    The graph is created, but not wit hthe new data (just with the old data)

     

     

    ********** second small issue

    (Also another matter – ValueAxis.AxisSize = “auto” works, but I would prefer to have a slightly wider Value axis range – maybe 25% higher and 25% lower than the range of the data = hopefully this is settable to see what looks best)

     

    (ie if my data spans 10-20 on the Y axis – I would like 7.5 – 22.5 to be my Va1lue axis range)

     

    #108981
    salasidis
    Participant

    I managed to get the graph to update by using the DataSource directly with EWparData (the data comoing directly from SQL)

     

    Then I set the – each time the chart is opened

    lineChart.DataSource = EWparData;

     

    However the seriesGroups are not updated, even though new values are entered into them.

     

    I am not sure if the entire seriesGroup class/lists needs to be recreated each time, or if there is an easier way.

    • This reply was modified 4 months, 1 week ago by salasidis.
    #108990
    salasidis
    Participant

    After the first update, I tried this

     

    if (updateChart > 0)
    {
    lineChart.Update();
    }
    dispChart = true;
    //updateFlag++;
    updateChart++;
    graphOpened = true;
    StateHasChanged();

     

    The results are inconsistent, most of the time the wrong label is present on the Value axis. Sometimes the scale is not present, but if move the range Selector, then the axis values are correct. Othertimes, the scale is always displayed correctly

    #109010

    Hi,

    Could you try using the Refresh or Render method of the chart? They may also help

    Best Regards,
    Svetoslav Borislavov

    Smart UI Team
    https://www.htmlelements.com/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.