0

网站上的 Web.UI.Data.Visualisation.Charting 库。我运行以下代码(删节):

Series s = new Series();

string[] xValues = points.Select(x => x.Key.ToString("MMM-yy")).ToArray<string>();
double[] yValues = points.Select(y => (double)y.Value).ToArray<double>();

s.Points.DataBindXY(xValues, yValues);

由于某种原因,月份(“MMM-yy”)出现在 Y(垂直)轴上。谁能明白为什么?在系列或图表类上找不到方向命令。

4

2 回答 2

0

错字。错误选择栏类型而不是列类型

s.ChartType = SeriesChartType.Bar;
于 2012-09-18T18:27:53.483 回答
0

问题可能出在 aspx 方面。就我个人而言,我宁愿在 aspx 端绑定数据,然后使用硬代码。看看我的示例,您可以在其中设置方向(XValueMember="Date" YValueMembers="Counter"):

<asp:Chart ID="SiteVisitChart" runat="server" DataSourceID="StartedProcessesObjectDataSource"
    Width="700px" Height="400px" >
    <Series>
        <asp:Series ToolTip="#VALX (#VALY)" Name="Series1" Color="112, 162, 213" BorderColor="164, 164, 164" ChartType="Column"
            BorderDashStyle="Solid" BorderWidth="1" ShadowColor="128, 128, 128, 128" ShadowOffset="1"
            IsValueShownAsLabel="true" XValueMember="Date" YValueMembers="Counter" Font="Tahoma, 8.0pt"
            BackSecondaryColor="0, 102, 153" LabelForeColor="100, 100, 100">
            <SmartLabelStyle  Enabled="true" />
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1" BackColor="White" BorderColor="26, 59, 105" BorderWidth="0"
            BorderDashStyle="Solid">
            <AxisX Title='<% $resources:AppResource,Date %>' LineColor="204, 204, 204" TitleFont="Tahoma, 8pt"
                TitleForeColor="100, 100, 100" LabelAutoFitMaxFontSize="8" LabelAutoFitMinFontSize="8">
                <MajorTickMark LineColor="Gray" />
                <MajorGrid Enabled="false" />
                <LabelStyle Font="Tahoma, 8.0pt" ForeColor="100, 100, 100" />
            </AxisX>
            <AxisY Title='<% $resources:AppResource,Counter %>' LineColor="204, 204, 204"
                TitleFont="Tahoma, 8pt" TitleForeColor="100, 100, 100" LabelAutoFitMaxFontSize="8"
                LabelAutoFitMinFontSize="8">
                <MajorTickMark LineColor="Gray" />
                <MajorGrid Enabled="false" />
                <LabelStyle Font="Tahoma, 8.0pt" ForeColor="100, 100, 100" />
            </AxisY>
        </asp:ChartArea>
    </ChartAreas>
</asp:Chart>
<asp:ObjectDataSource ID="StartedProcessesObjectDataSource" runat="server" SelectMethod="GetAllStartedProcessesStatistics"
    TypeName="GP.Solutions.WF.Services.GPWFManager">
    <SelectParameters>
        <asp:Parameter Name="dateFrom" Type="DateTime" />
        <asp:Parameter Name="dateTo" Type="DateTime" />
    </SelectParameters>
</asp:ObjectDataSource>
于 2012-09-18T18:17:24.547 回答