質問

3列のテーブルがあり、後者の2列には値が入っています。各データを表示する2つの円グラフを出力しようとしています。何らかの理由で、2番目の円グラフは表示されず、代わりに灰色の四角形として表示されます。また、凡例は2回連続して表示されますが、私にとって意味のない単一の凡例にすぎません。

マークアップは次のとおりです。

<asp:Chart Height="500" Width="500" ID="ClientModelChart" runat="server">
    <Series>
       <asp:Series ChartType="Pie" IsValueShownAsLabel="true" Name="PortfolioActual"></asp:Series>
       <asp:Series ChartType="Pie" IsValueShownAsLabel="true" Name="ModelActual"></asp:Series>
    </Series>
    <Legends>
       <asp:Legend Name="PortfolioActual"></asp:Legend>
       <asp:Legend Name="ModelActual"></asp:Legend>
    </Legends>
    <ChartAreas>
       <asp:ChartArea Area3DStyle-Enable3D="true" Area3DStyle-LightStyle="Realistic" Name="PortfolioActual"></asp:ChartArea>
       <asp:ChartArea Area3DStyle-Enable3D="true" Name="ModelActual"></asp:ChartArea>
    </ChartAreas>
</asp:Chart>

次に、 DataSet を埋めるために使用される SqlDataAdapter を取得し、 DataTableCollection IEnumerable リストタイプなので、チャートシリーズをデータバインドするときに使用できます。少し毛深いようですが、これを行う理由は、 DataSet が後でXSLT出力に使用されるためです。 need / want。

Dim sectorList As IList = CType(ds.Tables(1), IListSource).GetList()

ClientModelChart.Series("PortfolioActual").Points.DataBind(sectorList, "Sector", "Model", Nothing)
ClientModelChart.Series("ModelActual").Points.DataBind(sectorList, "Sector", "Client", Nothing)

したがって、2番目の円グラフ(ModelActual)はまったく表示されず、灰色の四角形にすぎません。私は何時間も無駄にいじっていました。編集動作しない理由)

ありがとう。

役に立ちましたか?

解決

さて、私はそれを馬鹿に過ごしましたが、すべての問題を解決しました。凡例の問題は、次のようにシリーズに対して凡例を指定する必要があるため解決されました。

      <asp:Chart Height="500" Width="500" ID="ClientModelChart" runat="server">
        <Legends>
          <asp:Legend Name="PortfolioActual"></asp:Legend>
          <asp:Legend Enabled="false" Name="ModelActual"></asp:Legend>
        </Legends>
        <Series>
          <asp:Series ChartType="Pie" Legend="PortfolioActual" ChartArea="PortfolioActual" IsValueShownAsLabel="true" Name="PortfolioActual"></asp:Series>
          <asp:Series ChartType="Pie" Legend="ModelActual" ChartArea="ModelActual" IsValueShownAsLabel="true" Name="ModelActual"></asp:Series>
        </Series>
        <ChartAreas>
          <asp:ChartArea Area3DStyle-Enable3D="true" Area3DStyle-LightStyle="Realistic" Name="PortfolioActual"></asp:ChartArea>
          <asp:ChartArea Area3DStyle-Enable3D="true" Area3DStyle-LightStyle="Realistic" Name="ModelActual"></asp:ChartArea>
        </ChartAreas>
      </asp:Chart>

およびデータのバインドは、代わりに次のように行う必要があります。

Dim sectorList As IList = CType(ds.Tables(1), IListSource).GetList()

ClientModelChart.Series("PortfolioActual").Points.DataBindXY(sectorList, "Sector", sectorList, "Model")
ClientModelChart.Series("ModelActual").Points.DataBindXY(sectorList, "Sector", sectorList, "Client")
ClientModelChart.Series("PortfolioActual")("PieLabelStyle") = "Outside"
ClientModelChart.Series("ModelActual")("PieLabelStyle") = "Outside"

最後にそこに行きました。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top