0

Shield UI Bar Chart があり、グラフ自体に表示されていないデータから値を取得したいと考えています。この例では、"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 に答える