简体   繁体   中英

ShieldUI will not accept updated attributes

I have the following code:

protected void SetChartToItem(Item item)
    {
        ShieldChart1 = new ShieldChart();
        ShieldChart1.Width = Unit.Percentage(100);
        ShieldChart1.Height = Unit.Pixel(400);
        ShieldChart1.CssClass = "chart";
        ShieldChart1.PrimaryHeader.Text = item.name;
        ShieldChart1.TooltipSettings.AxisMarkers.Enabled = true;
        ShieldChart1.TooltipSettings.AxisMarkers.Mode = ChartXYMode.XY;
        ShieldChart1.TooltipSettings.AxisMarkers.Width = new Unit(1);
        ShieldChart1.TooltipSettings.AxisMarkers.ZIndex = 3;
        ChartAxisX axisX = new ChartAxisX();
        axisX.Title.Text = "Times";
        ShieldChart1.Axes.Add(axisX);
        ChartAxisY axisY = new ChartAxisY();
        axisY.Title.Text = "Prices";
        ShieldChart1.Axes.Add(axisY);
        ShieldChart1.Axes.SetDirty();
}

And the following code:

<shield:ShieldChart ID="ShieldChart1" Width="700px" Height="380px" runat="server" OnTakeDataSource="ShieldChart1_TakeDataSource" CssClass="chart">
        <PrimaryHeader Text="TestHeader"></PrimaryHeader>
        <ExportOptions AllowExportToImage="true" AllowPrint="false" />
        <Axes>
            <shield:ChartAxisX>
                <Title Text="Time"></Title>
            </shield:ChartAxisX>
            <shield:ChartAxisY>
                <Title Text="Price"></Title>
            </shield:ChartAxisY>
        </Axes>
        <DataSeries>
            <shield:ChartLineSeries DataFieldY="Volume" DataFieldX="Timer" CollectionAlias="Volume">
                <Settings EnablePointSelection="true">
                    <PointMark>
                        <ActiveSettings>
                            <PointSelectedState DrawWidth="4" DrawRadius="4" />
                        </ActiveSettings>
                    </PointMark>
                </Settings>
            </shield:ChartLineSeries>
            <shield:ChartLineSeries DataFieldY="Price" DataFieldX="Timer" CollectionAlias="Price">
                <Settings EnablePointSelection="true">
                    <PointMark>
                        <ActiveSettings>
                            <PointSelectedState DrawWidth="4" DrawRadius="4" />
                        </ActiveSettings>
                    </PointMark>
                </Settings>
            </shield:ChartLineSeries>
        </DataSeries>
    </shield:ShieldChart>

When I call SetChartToItem, it looks like it works when I watch it go through step by step, but when the page renders there are no changes to the actual ShieldChart. More information that might help is when I remove the line ShieldChart1 = new ShieldChart(); then the entire ShieldChart will disappear instead.

I believe there are two ways to try and address this. One would be to recreate the chart, as demonstrated in this sample: https://demos.shieldui.com/aspnet/rangebar-chart/related-charts You can check out the asp.net tab.

Another alternative would be to recreate the controls collection (and clear it before this) in a nested panel, which hosts the chart. Then, on a specific event, you can recreate the chart, clear the controls collection of the container and add the new instance.

It took me 3 months, but I figured out what the problem was. I was causing some of the chart to build itself in the 'Page_Load' function. The solution to this was to make sure everyone was done only if the page is a postback page, which is not included in my code above but fixed the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM