Пример #1
0
        protected void XisDateYisDecimal(IXTick <DateTime> xAxis, IYTick <decimal> yAxis, List <XyPair <T, Q> > xyPair, decimal increaseTickRate)
        {
            DateTime minX = DateTime.MaxValue;
            DateTime maxX = DateTime.MinValue;
            decimal  minY = int.MaxValue;
            decimal  maxY = 0;

            foreach (var item in xyPair)
            {
                #region minmax

                foreach (var xItem in item.X)
                {
                    DateTime date = Convert.ToDateTime(xItem);
                    if (date < minX)
                    {
                        minX = date;
                    }
                    if (date > maxX)
                    {
                        maxX = date;
                    }
                }

                foreach (var yItem in item.Y)
                {
                    if (Convert.ToDecimal(yItem) < minY)
                    {
                        minY = Convert.ToDecimal(yItem);
                    }
                    if (Convert.ToDecimal(yItem) > maxY)
                    {
                        maxY = Convert.ToDecimal(yItem);
                    }
                }
                #endregion
            }

            #region X
            string leftContent  = "";
            string rightContent = "";

            leftContent += "plt.xticks([";
            DateTime aux = minX;
            while (aux <= maxX)
            {
                leftContent  += "datetime.date(" + aux.ToString("yyyy,MM,d") + "),";
                rightContent += "\"" + aux.ToString("M/d") + "\\n" + aux.ToString("ddd") + "\",";
                aux           = aux.Add(new TimeSpan(1, 0, 0, 0));//TODO:aaaa
            }
            leftContent = leftContent.TrimEnd(',') + "],[" + rightContent.TrimEnd(',') + "])";
            PythonProcess.AddInstruction(leftContent);
            #endregion

            if (minY > 0)
            {
                minY = 0m;
            }

            leftContent  = "";
            rightContent = "";

            leftContent += "plt.yticks([";

            for (minY = 0m; minY < (maxY + increaseTickRate); minY += increaseTickRate)
            {
                leftContent  += minY + ",";
                rightContent += "\"{:,}\".format(" + minY + "),";//add sufix
                //Process.AddInstruction("\tplt.text(xP, yP, \"{:,}\".format(item) + \"" + scatterSuffix + "\", fontsize=11)");
            }

            //while (minY <= maxY)
            //{
            //    leftContent += minY + ",";
            //    rightContent += "\"" + minY + "\",";
            //    minY += increaseTickRate;
            //}


            leftContent = leftContent.TrimEnd(',') + "],[" + rightContent.TrimEnd(',') + "])";
            PythonProcess.AddInstruction(leftContent);
        }