[英]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. 当我调用SetChartToItem时,当我逐步查看SetChartToItem时,它似乎可以工作,但是当页面呈现时,实际的ShieldChart并没有更改。 More information that might help is when I remove the line ShieldChart1 = new ShieldChart();
当我删除ShieldChart1 = new ShieldChart();行时,可能会有更多帮助。 then the entire ShieldChart will disappear instead.
那么整个ShieldChart将会消失。
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.
如本示例所示,一种方法是重新创建图表: https : //demos.shieldui.com/aspnet/rangebar-chart/related-charts您可以签出asp.net选项卡。
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. 我花了3个月的时间,但我发现了问题所在。 I was causing some of the chart to build itself in the 'Page_Load' function.
我导致某些图表在“ Page_Load”函数中自行构建。 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.
解决方案是确保仅当该页面是回发页面时才完成所有工作,该页面未包含在上面的代码中,但为我解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.