[英]How to unit 2 or more Data Series in group by One Chart C#
用C#開發圖表,它會自動用sp填充。 正如我在圖中所示,該sp傳播的城市具有該月的總數被過濾。
在我的圖表中,我添加了兩組數據,盡管將來可能會更多。 問題不在於添加數據系列,而是如何尊重數據的順序,如果我將數據系列添加為輔助數據,效果會很好,但是我不對它們進行分組但轉置它們,並且不尊重數據的順序。順序相同。
我想知道是否有人知道該怎么做,我已經在互聯網上進行了驗證,但是找不到信息。 我添加了向我提供信息的sp,同時在對圖表中的數據進行分組時也對它們進行了拋出,因為無論下個月是否會有更多城市,我都希望對其進行分組。
此代碼將數據系列添加到圖表
conexion_server.PreparaComandoSP("sp_telemetria_camiones_Km_Mes_Actual");
conexion_server.AgregarParametro("Mes", SqlDbType.VarChar, strmes);
mes_actual = conexion_server.EjecutaComandoDataSet();
graf_km_camiones_comparativo.Titles.Add("Comparativa KMS entre Camiones \\n" + strmes + " VS " + strmes_comparativo).Font = new Font("Arial", 12, FontStyle.Bold);
graf_km_camiones_comparativo.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
graf_km_camiones_comparativo.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
graf_km_camiones_comparativo.Series["Series1"].ToolTip = "(#VALX, #VALY)";
graf_km_camiones_comparativo.Series["Series2"].ToolTip = "(#VALX, #VALY)";
graf_km_camiones_comparativo.Series["Series1"].LegendText = strmes;
graf_km_camiones_comparativo.Series["Series2"].LegendText = strmes_comparativo;
graf_km_camiones_comparativo.Legends["Legend1"].Title = "Segmentación";
foreach (DataRow row in mes_actual.Tables[0].Rows)
{
graf_km_camiones_comparativo.Series["Series1"].Points.AddXY(row["CeEmplazamiento"], row["Totales"]);
graf_km_camiones_comparativo.Series["Series1"].Label = "#VALY";
}
Thank you.
感謝大家的意見,這是我的解決方案。 1.-在查詢之間創建唯一性,因為在沒有查詢的情況下無法組織系列。 2.-圖表充滿了foreach。
Ë
,final_comparativo as (
select s.CeEmplazamiento, avg(s.Totales) TotalGeneral , s2.TotGral, @Mes as Mes
from tmpSemanas s
cross join ( select avg(Totales) TotGral from tmpSemanas s2 where Totales >0) s2
group by s.CeEmplazamiento , s2.TotGral
union all
select ss.CeEmplazamiento, avg(ss.Totales) TotalGeneral , ss2.TotGral, @Mes_comparar as Mes
from tmpSemanas_comparar ss
cross join ( select avg(Totales) TotGral from tmpSemanas_comparar ss2 where Totales >0) ss2
group by ss.CeEmplazamiento , ss2.TotGral
)
**CeEmplazamiento Diciembre Enero**
Celaya 76.500000 75.600000
Coecillo 79.000000 79.800000
Irapuato 77.500000 75.400000
León Sur 85.750000 87.600000
Los Reyes 0.000000 0.000000
Oriente León 86.250000 85.200000
Texcoco 0.000000 0.000000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.