0

我有一个 Shield UI 条形图,我想从图表本身未显示的数据中获得一个值。在此示例中,我希望能够访问“strTest”的数据值。

var dataHours = new List<HoursType>()
        {
            //This month
            new HoursType() { Billable = Math.Round(billThisMonth / totalThisMonth * 100, 2), NonBillable = Math.Round(nonBillThisMonth / totalThisMonth * 100, 2), strTest = nonBillThisMonth},
            //Last month
            new HoursType() { Billable = Math.Round(billLastMonth / totalLastMonth * 100, 2), NonBillable = Math.Round(nonBillLastMonth / totalLastMonth * 100, 2), strTest = nonBillLastMonth},
            //YTD
            new HoursType() { Billable = Math.Round(billYTD / totalYTD * 100, 2), NonBillable = Math.Round(nonBillYTD / totalYTD * 100, 2), strTest = nonBillYTD}
        };
        chtBillableNonBillable.DataSource = dataHours;
        chtBillableNonBillable.DataBind();

这是asp前端。我尝试在“CustomPointText”属性中使用 point.strTest,但它没有获取数据。

<shield:ShieldChart ID="chtBillableNonBillable" Width="100%" Height="400px" runat="server" CssClass="chart">
            <PrimaryHeader Text="Billable/Non-Billable Hours"></PrimaryHeader>
            <TooltipSettings CustomPointText="{point.strTest} / {point.y}"  >
            </TooltipSettings>
            <ExportOptions AllowExportToImage="true" AllowPrint="true" />
            <Axes>
                <shield:ChartAxisX CategoricalValues="Current Month, Last Month, YTD"></shield:ChartAxisX>
                <shield:ChartAxisY>
                    <Title Text="% of Hours"></Title>
                </shield:ChartAxisY>
            </Axes>
            <DataSeries>
                <shield:ChartBarSeries DataFieldY="Billable" CollectionAlias="Billable Hours" >
                </shield:ChartBarSeries>
                <shield:ChartBarSeries DataFieldY="NonBillable" CollectionAlias="Non-Billable Hours">
                </shield:ChartBarSeries>
            </DataSeries>
        </shield:ShieldChart>

任何帮助,将不胜感激。谢谢!

4

1 回答 1

1

要在BarChart系列工具提示中显示自定义未绑定值,您需要使用客户端上的所有 strTest 值序列化数组,并在工具提示中显示自定义点文本的值。例如:

protected void chtBillableNonBillable_TakeDataSource(object sender, Shield.Web.UI.ChartTakeDataSourceEventArgs e)

{

var dataHours = new List<HoursType>()
{
    //This month
    new HoursType() { Billable = Math.Round(billThisMonth / totalThisMonth * 100, 2),
        NonBillable = Math.Round(nonBillThisMonth / totalThisMonth * 100, 2), strTest = nonBillThisMonth},
    //Last month
    new HoursType() { Billable = Math.Round(billLastMonth / totalLastMonth * 100, 2), 
        NonBillable = Math.Round(nonBillLastMonth / totalLastMonth * 100, 2), strTest = nonBillLastMonth},
    //YTD
    new HoursType() { Billable = Math.Round(billYTD / totalYTD * 100, 2), 
        NonBillable = Math.Round(nonBillYTD / totalYTD * 100, 2), strTest = nonBillYTD}
};
chtBillableNonBillable.DataSource = dataHours;

Page.RegisterArrayDeclaration("strTests", string.Join(",", dataHours.Select(s => s.strTest.ToString(CultureInfo.InvariantCulture))));

}

<shield:ShieldChart ID="chtBillableNonBillable" Width="100%" Height="400px" OnTakeDataSource="chtBillableNonBillable_TakeDataSource" runat="server" CssClass="chart">
            <PrimaryHeader Text="Billable/Non-Billable Hours"></PrimaryHeader>
            <TooltipSettings PointClientCallbackFunction="PointClientCallbackFunction" CustomPointText="{point.strTest} / {point.y}">

<script type="text/javascript">
    function PointClientCallbackFunction(point, chart) {

        return "strTest: " + strTests[point.x];
    }
</script>

您还可以在此处找到有关 PointClientCallbackFunction 的更多信息: customPointText

请尝试一下,如果建议对您有帮助,请告诉我。我还向您发送了一个简单的示例来演示它。

于 2015-01-21T19:48:19.687 回答