Asp NET system.web.helpers GRÁFICO DE PIE

programación


Estoy intentando reemplazar MSCHART de mis proyectos con ayudantes de gráficos (System.Web.Helpers) pero tengo muchas dificultades:

1) ¿Cómo puedo insertar valores porcentuales en un gráfico PIE?
2) ¿Puedo mover el valor del gráfico fuera del pastel?

Lo que he probado:

C#
Chart myChart = new Chart(width: 800, height: 400, themePath: "~/xml/hst_pie_tech.xml",  theme: ChartTheme.Vanilla3D)
           .AddTitle("Volume ")
           .AddSeries("Volume",
                   chartType: "Pie",
                   xValue: dataView, xField: "Technology",
                   yValues: dataView, yFields: "Qty",
                   markerStep: 1

                   );
XML
<?xml version="1.0" encoding="utf-8" ?>
<Chart>
	
	<ChartAreas>

		<ChartArea Name="Default" _Template_="All">
			<AxisY
				LineColor="0, 0, 0"
				TitleFont="{0}, 14pt, style=Bold"
				TitleForeColor="0, 0, 0"
				
				>
				<LabelStyle Font="{0}, 6.75pt, GdiCharSet=0" ForeColor="0, 0, 0" />
			</AxisY>
			
			<AxisX 
				Interval="1"
				TitleFont="{0}, 18pt, GdiCharSet=0"	>
				
				<LabelStyle Font="{0}, 6.75pt, GdiCharSet=0" ForeColor="0, 0, 0" />
			</AxisX>
			
		</ChartArea>

	</ChartAreas>
	
	<Titles>
		<Title _Template_="All" Font="{0}, 14pt, style=Bold" ForeColor="0, 0, 0"></Title>
	</Titles>
		
	<Series>
		<Series 
			Name="Volume" 
			BorderWidth="2" 
			Color="153, 204, 255" 
			BorderColor="164, 164, 164" 
			BorderDashStyle="Solid" 
			ShadowColor="128, 128, 128, 128" 
			ShadowOffset="1" 
			IsValueShownAsLabel="true" 
			Font="{0}, 8pt" 
			BackGradientStyle="TopBottom" 
			BackSecondaryColor="0, 102, 153" 
			LabelForeColor="0, 0, 0"
			
			>
			<SmartLabelStyle Enabled="True" />
		</Series>
	</Series>
	
	<Legends>
		<Legend Alignment="Center" Docking="Left" Name="Technology" Font="{0}, 10pt, style=Italic, GdiCharSet=0">
	</Legend>
	</Legends>

	<BorderSkin PageColor="Control" BackColor="CornflowerBlue" BackSecondaryColor="CornflowerBlue" />
</Chart>

Solución 1

Si desea utilizar porcentajes como números, simplemente asigne los valores a la serie. Después de todo, son sólo números. Si lo que pregunta es cómo muestra el porcentaje de edad como etiqueta, simplemente use este marcado en su ChartArea.

HTML
<AxisY >
  <LabelStyle Format="{0:p}" />
</AxisY>

コメント

タイトルとURLをコピーしました