SunVoteChart.cs 98.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370
/// ----------------------------------------------------------------
/// 文 件 名:ChartControl.cs
/// 功能描述:图表管理
/// 
/// 创建标识:Jdragon  2011-11-22
/// ----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms.DataVisualization.Charting;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using SunVoteARSPPT;


namespace GeneralLib
{
    /// <summary>
    /// 枚举类型(自定义枚举类型)
    /// </summary>
    public enum ChartTypes
    {
        /// <summary>
        /// 柱形图
        /// </summary>            
        ctColumn,
        /// <summary>
        /// 条形图
        /// </summary>
        ctBar,
        /// <summary>
        /// 垂直方块图 杨斌 2014-04-22      
        /// </summary>    
        ctColumnBox,
        /// <summary>
        /// 水平方块图 杨斌 2014-04-22
        /// </summary>
        ctBarBox,
        /// <summary>
        /// 饼图
        /// </summary>
        ctPie,
        /// <summary>
        /// 文本
        /// </summary>
        ctText,
    }

    /// <summary>
    /// 标签类型
    /// </summary>
    public enum LabelTypes
    {
        // 无标签
        ltNone,
        // 数值
        ltNumberValue,
        // 百分比
        ltPercent,
        // 数值加百分比
        ltNumberValueAndPercent,
    }

    /// <summary>
    /// 图例样式
    /// </summary>
    public enum LegendStyles
    {
        /// <summary>
        /// 列方式
        /// </summary>
        lsColumn = 0,
        /// <summary>
        /// 行方式
        /// </summary>
        lsRow = 1,
        /// <summary>
        /// 表格方式
        /// 杨斌 2014-02-25
        /// </summary>
        lstTable = 2
    }

    /// <summary>
    /// 图例对齐方式
    /// </summary>
    public enum LegentAlignments
    {
        /// <summary>
        /// 靠近布局对齐。在左到右布局中,近端位置是左。在右到左布局中,近端位置是右。
        /// </summary>
        laNear = 0,
        /// <summary>
        /// 居中对齐
        /// </summary>
        laCenter = 1,
        /// <summary>
        /// 指定文本远离布局矩形的原点位置对齐。在左到右布局中,远端位置是右。在右到左布局中,远端位置是左。
        /// </summary>
        laFar = 2
    }

    /// <summary>
    /// 图例位置
    /// </summary>
    public enum LegentDockings
    {
        /// <summary>
        /// 上
        /// </summary>
        ldTop = 0,
        /// <summary>
        /// 右
        /// </summary>
        ldRight = 1,
        /// <summary>
        /// 下
        /// </summary>
        ldBottom = 2,
        /// <summary>
        /// 左
        /// </summary>
        ldLeft = 3
    }

    public class ManageChart
    {
        /// <summary>
        /// 微软控件属性
        /// </summary>
        public Chart MsChart { get; set; }

        /// <summary>
        /// 图表类型(默认值:柱形图)
        /// </summary>
        private ChartTypes chartType = ChartTypes.ctColumn;
        /// <summary>
        /// 图表类型
        /// </summary>
        public ChartTypes ChartType
        {
            get
            {
                return chartType;
            }
            set
            {
                chartType = value;
            }
        }

        /// <summary>
        /// 文本模式图表数据按行排列
        /// </summary>
        public bool TextChartTypeByLine = false;
        /// <summary>
        /// 只显示文本的图表形式,数字和选项之间的空格(水平)或空行(垂直)数。杨斌 2019-04-03
        /// </summary>
        public int ChartTypeTextSpaceOrLine = 0;

        /// <summary>
        /// 图表宽度,默认为320
        /// </summary>
        private int width = 320;
        public int Width
        {
            get
            {
                return width <= 0 ? 320 : width;
            }
            set
            {
                if (value <= 0)
                    throw (new ApplicationException("Abnormal width of the chart, the width must be greater than 0"));
                width = (value <= 0) ? 320 : value;
            }
        }

        /// <summary>
        /// 图表高度,默认为240
        /// </summary>
        private int height = 240;
        public int Height
        {
            get
            {
                return height <= 0 ? 240 : height;
            }
            set
            {
                if (value <= 0)
                    throw (new ApplicationException("Degree of abnormal length of the chart, the width must be greater than 0"));
                height = (value <= 0) ? 240 : value;
            }
        }

        /// <summary>
        /// X轴值(选择项)
        /// </summary>
        public string[] XValue { get; set; }

        /// <summary>
        /// Y轴值集合
        /// </summary>
        public List<double[]> YValues { get; set; }


        /// <summary>
        /// Y轴值集合。Angage定制不按标准如权重,按投票人数,与百分比分离。杨斌 2019-11-26
        /// </summary>
        public List<double[]> YValuesNew { get; set; }

        /// <summary>
        /// 数据标签(默认值:数值)
        /// </summary>
        private LabelTypes labelType = LabelTypes.ltNumberValue;
        public LabelTypes LabelType
        {
            get
            {
                return labelType;
            }
            set
            {
                labelType = value;
            }
        }
        /// <summary>
        /// 2014-03-17 增加标签小数位数
        /// </summary>
        public int NumberDec = 0;
        public int PercentDec = 1;
        private double labelDenominator = 0;
        /// <summary>
        /// 百分比标签的分母,为0时表示以总数量计算,默认为0
        /// </summary>
        public double LabelDenominator
        {
            get
            {
                return labelDenominator;
            }
            set
            {
                if (value < 0)
                    throw (new ApplicationException("Percentage of the label must be greater than or equal to 0 denominator"));
                labelDenominator = value;
            }
        }

        /// <summary>
        /// 分母计算选项限制,如三键表决按赞成反对。默认0为所有选项。
        /// 杨斌 2015-06-18
        /// </summary>
        public int LabelDenominatorOptionLimit = 0;


        /// <summary>
        /// 计算系列总数值
        /// </summary>
        /// <param name="series">系列</param>
        /// <returns>总数值</returns>
        private int SumPointsValue(Series series)
        {
            int value = 0;

            //杨斌 2015-06-18
            int count = series.Points.Count;
            if ((this.LabelDenominatorOptionLimit > 0)
                && (this.LabelDenominatorOptionLimit < series.Points.Count))
            {
                count = this.LabelDenominatorOptionLimit;
            }
            for (int i = 0; i < count; i++)//杨斌 2015-06-18
            {
                value = value + (int)series.Points[i].GetValueByName("Y");
            }
            return value;
        }

        /// <summary>
        /// 杨斌 2012-06-29
        /// </summary>
        public Color[] SeriesColorsInit =
        {
            Color.FromArgb(65, 140, 240),
            Color.FromArgb(224, 64, 10),
            Color.FromArgb(252, 180, 65),
            Color.FromArgb(5, 100, 146),
            Color.FromArgb(191, 191, 191),
            Color.FromArgb(26, 59, 105),
            Color.FromArgb(255, 227, 130),
            Color.FromArgb(18, 156, 221),
            Color.FromArgb(202, 107, 75),
            Color.FromArgb(0, 92, 219)
        };



        /// <summary>
        /// 系列(Series)颜色
        /// 修改:杨斌 2012-06-28
        /// </summary>
        public Color[] SeriesColors
        {
            get
            {
                //return seriesColors;
                Color[] aryColors = new Color[9999];
                int count = SeriesColorsInit.Length;
                for (int i = 0; i < aryColors.Length; i++)
                {
                    int n = i % count;
                    aryColors[i] = SeriesColorsInit[n];
                }
                return aryColors;
            }
            set
            {
                SeriesColorsInit = value;
                if (value == null || value.Length < 0)
                    throw (new ApplicationException("Series (Series) colors set at least one color"));
            }
        }
        /// <summary>
        /// Point颜色
        /// </summary>
        public Color[] PointColors { get; set; }

        //杨斌 2014-06-04。默认改为0
        private double pointWidth = 0;//必须设置,因为默认为0。图表控件应默认设置为1,否则默认为0时图表柱状图画不出来 2012-02-02
        /// <summary>
        /// 系列各项的宽度,必须0-1之间,0表示默认
        /// </summary>
        public double PointWidth
        {
            get
            {
                return pointWidth;
            }
            set
            {
                if (value < 0 || value > 1)
                    throw (new ApplicationException("The width of the series, must be between 0-1"));
                pointWidth = (value < 0 || value > 1) ? 1 : value;
            }
        }

        /// <summary>
        /// 是否显示图例
        /// </summary>
        private bool legendEnable = true;
        public bool LegendEnable
        {
            get
            {
                return legendEnable;
            }
            set
            {
                legendEnable = value;
            }
        }


        private LegendStyles legendStyle = LegendStyles.lsColumn;
        /// <summary>
        /// 图例样式
        /// </summary>
        private LegendStyles LegendStyle
        {
            get
            {
                return legendStyle;
            }
            set
            {
                legendStyle = value;
            }
        }

        private Font legendFont = new Font("Arial", 8);
        /// <summary>
        /// 图例文本格式,如字体、字号、字形属性
        /// </summary>
        private Font LegendFont
        {
            get
            {
                return legendFont;
            }
            set
            {
                legendFont = value;
            }
        }


        private LegentAlignments legendAlignment = LegentAlignments.laCenter;
        /// <summary>
        /// 图例对齐方式,默认居中对齐
        /// </summary>
        public LegentAlignments LegendAlignment
        {
            get
            {
                return legendAlignment;
            }
            set
            {
                legendAlignment = value;
            }
        }


        private LegentDockings legentDocking = LegentDockings.ldBottom;
        /// <summary>
        /// 图例位置
        /// </summary>
        public LegentDockings LegentDocking
        {
            get
            {
                return legentDocking;
            }
            set
            {
                legentDocking = value;
            }
        }

        private Color legentForeColor = Color.Black;
        /// <summary>
        /// 图例文本颜色
        /// </summary>
        public Color LegentForeColor
        {
            get
            {
                return legentForeColor;
            }
            set
            {
                legentForeColor = value;
            }
        }

        /// <summary>
        /// 图例文本
        /// </summary>
        public string[] LegentText { get; set; }


        /// <summary>
        /// 是否3D图
        /// </summary>
        private bool is3D = false;
        public bool Is3D
        {
            get
            {
                return is3D;
            }
            set
            {
                is3D = value;
            }
        }

        private bool axisYEnable = false;
        /// <summary>
        /// 是否显示Y轴,默认显示
        /// </summary>
        private bool AxisYEnabled
        {
            get
            {
                return axisYEnable;
            }
            set
            {
                axisYEnable = value;
            }
        }

        private bool axisXEnable = true;
        private int iChangeColor = 0;  //0:初始值,1:Bar图,2:Other图   20120204
        private int iChiceCount = 0;   //记录Bar图选项选项个数(Bar图时记录) 20120204

        /// <summary>
        /// 是否显示X轴,默认显示
        /// </summary>
        public bool AxisXEnabled
        {
            get
            {
                return axisXEnable;
            }
            set
            {
                axisXEnable = value;
            }
        }

        /// <summary>
        /// 柱状图的最大值
        /// </summary>
        private int maxValue = 0;
        public int MaxValue
        {
            get
            {
                return maxValue;
            }
            set
            {
                maxValue = value;
            }
        }

        private Font dataLabelFont = new Font("Arial", 14);
        /// <summary>
        /// 数据标签字体
        /// 创建:杨斌 2012-06-26
        /// </summary>
        public Font DataLabelFont
        {
            get { return dataLabelFont; }
            set { dataLabelFont = value; }
        }

        /// <summary>
        /// 是否使用系统字体
        /// 杨斌 2015-05-29
        /// </summary>
        public bool UseSystemFont = true;

        private Color dataLabelColor = Color.Black;
        /// <summary>
        /// 数据标签颜色
        /// 创建:杨斌 2012-06-26
        /// </summary>
        public Color DataLabelColor
        {
            get { return dataLabelColor; }
            set { dataLabelColor = value; }
        }

        private Font itemLabelFont = new Font("Arial", 16);
        /// <summary>
        /// 选项标签字体
        /// 创建:杨斌 2012-06-26
        /// </summary>
        public Font ItemLabelFont
        {
            get { return itemLabelFont; }
            set { itemLabelFont = value; }
        }

        private Color itemLabelColor = Color.Black;
        /// <summary>
        /// 选项标签颜色
        /// 创建:杨斌 2012-06-26
        /// </summary>
        public Color ItemLabelColor
        {
            get { return itemLabelColor; }
            set { itemLabelColor = value; }
        }

        /// <summary>
        /// 图表最大数据值,用于柱状图或条形图最大长度设置
        /// 若为0则长度自动适应
        /// 创建:杨斌 2013-02-21
        /// </summary>
        public double MaxDataValue = 0;

        /// <summary>
        /// 是否强制显示选项文本
        /// 杨斌 2015-01-08
        /// </summary>
        //public bool ShowItemText = false;

        /// <summary>
        /// 使用堆积图
        /// 杨斌 2014-11-04
        /// </summary>
        public bool UseStacked = false;
        /// <summary>
        /// 在使用UseStacked堆积图基础上,使用100堆积图
        /// 杨斌 2017-06-13
        /// </summary>
        public bool UseStacked100 = false;

        /// <summary>
        /// 图表标题。杨斌 2017-03-21
        /// </summary>
        public string ChartTitle = "";

        public bool UpdateChart2(Dictionary<string, string> optionTextFull = null)
        {
            string titleSlide = "";
            if (MsChart.Titles.Count > 0)
            {
                titleSlide = MsChart.Titles[0].Text;
            }

            //清除图表(区域)
            MsChart.ChartAreas.Clear();
            MsChart.Series.Clear();
            MsChart.Titles.Clear();
            MsChart.Legends.Clear();

            //图表、字体清晰度(锯齿)
            MsChart.AntiAliasing = AntiAliasingStyles.Graphics;
            //图表背景色
            MsChart.BackColor = Color.Transparent;
            //图表位置
            MsChart.Location = new System.Drawing.Point(0, 0);
            //图表大小
            MsChart.Size = new System.Drawing.Size(this.width, this.height);

            if (titleSlide.Length < 1)
                titleSlide = "Group Comparison";
            Title ti = new Title(titleSlide, Docking.Top);
            ti.Name = "Title";
            ti.Alignment = ContentAlignment.MiddleCenter;
            ti.ForeColor = Color.Black;
            ti.Font = new Font(ItemLabelFont.Name, ItemLabelFont.Size, ItemLabelFont.Style);
            MsChart.Titles.Add(ti);

            string foot = "";
            if ((optionTextFull != null) && (optionTextFull.Count > 0))
            {
                int nItem = 0;
                foreach (var v in optionTextFull)
                {
                    nItem++;
                    foot += v.Key + "." + v.Value + "; ";
                }
            }
            ti = new Title(foot, Docking.Bottom);
            ti.Name = "Foot";
            ti.Alignment = ContentAlignment.MiddleLeft;
            ti.ForeColor = Color.Black;
            ti.Font = new Font(ItemLabelFont.Name, ItemLabelFont.Size, ItemLabelFont.Style);
            MsChart.Titles.Add(ti);

            int groupCount = this.YValues.Count;
            int yStart = 10;
            int hStep = 80;
            int xStart = 5;
            int wStep = (100 - xStart) / groupCount;

            ChartArea area = null;
            Series ser = null;

            for (int i = 1; i <= groupCount; i++)
            {
                area = new ChartArea("Area" + i);
                area.Position.Auto = false;
                area.Position = new ElementPosition(xStart, yStart, wStep, hStep);
                area.BackColor = Color.Transparent;
                MsChart.ChartAreas.Add(area);
                xStart += wStep;

                ser = new Series("Series" + i);
                ser.ChartArea = area.Name;
                ser.IsValueShownAsLabel = true;
                ser.ChartType = SeriesChartType.Bar;
                MsChart.Series.Add(ser);

                string sGroup = LegentText[i - 1];
                ti = new Title(sGroup, Docking.Top);
                ti.Name = "Title" + i;
                ti.Alignment = ContentAlignment.TopLeft;
                ti.DockedToChartArea = area.Name;
                //ti.DockingOffset = 7;
                //ti.IsDockedInsideChartArea = false;
                ti.ForeColor = Color.Black;
                ti.Font = new Font(LegendFont.Name, 12, LegendFont.Style);
                MsChart.Titles.Add(ti);
            }

            area = new ChartArea("AreaRank");
            area.Position.Auto = false;
            area.Position = new ElementPosition(0, yStart, 50, hStep);
            area.BackColor = Color.Transparent;
            MsChart.ChartAreas.Add(area);

            ser = new Series("SeriesRank");
            ser.ChartArea = "AreaRank";
            ser.IsValueShownAsLabel = false;
            ser.ChartType = SeriesChartType.Bar;
            MsChart.Series.Add(ser);

            string rankTi = GlobalInfo.SysLanguage.LPT.ReadString("Other", "OrderGroupChartRank", "Avg.\r\nRanking");
            ti = new Title(rankTi, Docking.Top);
            ti.Name = "Rank";
            ti.Alignment = ContentAlignment.TopLeft;
            ti.DockedToChartArea = "AreaRank";
            ti.DockingOffset = 4;
            ti.IsDockedInsideChartArea = false;
            ti.ForeColor = Color.Black;
            MsChart.Titles.Add(ti);

            //如果是条形图,反转数据,颜色翻转 杨斌 2014-03-21
            if ((this.chartType == ChartTypes.ctBar) ||
                (this.chartType == ChartTypes.ctBarBox) ||
                (this.chartType == ChartTypes.ctText))//杨斌 2015-04-20
            {
                //杨斌 2014-12-09
                string tempXVal;
                double tempYVal;
                int count = XValue.Length;
                for (int j = 0; j < count / 2; j++)
                {
                    tempXVal = XValue[j];
                    XValue[j] = XValue[count - 1 - j];
                    XValue[count - 1 - j] = tempXVal;
                }
                for (int i = 0; i < YValues.Count; i++)
                {
                    count = YValues[i].Length;
                    for (int j = 0; j < count / 2; j++)
                    {
                        //tempXVal = XValue[j];
                        //XValue[j] = XValue[count - 1 - j];
                        //XValue[count - 1 - j] = tempXVal;

                        tempYVal = YValues[i][j];
                        YValues[i][j] = YValues[i][count - 1 - j];
                        YValues[i][count - 1 - j] = tempYVal;
                    }
                }
            }

            groupCount++;
            for (int y = 0; y < groupCount; y++)
            {
                //创建图表区域
                ChartArea chartArea = MsChart.ChartAreas[y];

                chartArea.AxisX.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True;//是否显示x轴
                chartArea.AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;//是否显示y轴

                //X/Y轴网格线
                chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
                chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;

                chartArea.AxisX.MajorGrid.Enabled = false;
                chartArea.AxisX.MajorTickMark.Enabled = false;
                chartArea.AxisX.LineColor = Color.Transparent;

                chartArea.AxisX.LabelStyle.Interval = 1;//解决图表显示13 5 7 9 11问题

                //数据列是否聚合
                chartArea.Area3DStyle.IsClustered = false;// this.ChartParam.IsClustered;

                //图表区域背景色
                chartArea.BackColor = Color.Transparent;

                //X/Y轴标签文本颜色
                chartArea.AxisY.LabelStyle.ForeColor = Color.Black;
                chartArea.AxisX.LabelStyle.ForeColor = ItemLabelColor;//Color.Black;//杨斌 2012-06-26

                //系列各项深度,3D时有效,取值0-1000之间,默认60
                chartArea.Area3DStyle.PointDepth = 60;// this.ChartParam.PointDepth;

                //系列各项前后空白的深度,3D时有效,取值0-1000之间,默认100
                chartArea.Area3DStyle.PointGapDepth = 100;// this.ChartParam.PointGapDepth;

                //杨斌 2016-05-13
                //chartArea.BorderDashStyle = ChartDashStyle.Solid;
                //chartArea.BorderColor = Color.Red;
                chartArea.AlignmentOrientation = AreaAlignmentOrientations.Vertical;

                if (chartArea.Name == "AreaRank")
                {
                    chartArea.BorderColor = Color.Transparent;
                    chartArea.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
                    //cha.Series[i].Points.DataBindXY(aryItemR, aryValueR);
                }
                else
                {
                    chartArea.BorderColor = Color.Black;
                    chartArea.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
                }

                if (iChangeColor == 1 && iChiceCount > 1)  // 颜色翻转-颜色还原 --解决由5个选项变成7个选项颜色会变的bug jdragon -2012-02-06
                {
                    Color[] tempColors = this.SeriesColors;
                    Color tempColor;
                    for (int j = 0; j < iChiceCount / 2; j++)
                    {
                        tempColor = tempColors[iChiceCount - 1 - j];
                        tempColors[iChiceCount - 1 - j] = tempColors[j];
                        tempColors[j] = tempColor;
                    }
                    this.SeriesColors = tempColors;
                    iChangeColor = 2;
                }

                //组内排序。杨斌 2016-05-17


                ////如果是条形图,反转数据,颜色翻转 杨斌 2014-03-21
                //if ((this.chartType == ChartTypes.ctBar) ||
                //    (this.chartType == ChartTypes.ctBarBox) ||
                //    (this.chartType == ChartTypes.ctText))//杨斌 2015-04-20
                //{
                //    //杨斌 2014-12-09
                //    string tempXVal;
                //    double tempYVal;
                //    int count = XValue.Length;
                //    for (int j = 0; j < count / 2; j++)
                //    {
                //        tempXVal = XValue[j];
                //        XValue[j] = XValue[count - 1 - j];
                //        XValue[count - 1 - j] = tempXVal;
                //    }
                //    for (int i = 0; i < YValues.Count; i++)
                //    {
                //        count = YValues[i].Length;
                //        for (int j = 0; j < count / 2; j++)
                //        {
                //            //tempXVal = XValue[j];
                //            //XValue[j] = XValue[count - 1 - j];
                //            //XValue[count - 1 - j] = tempXVal;

                //            tempYVal = YValues[i][j];
                //            YValues[i][j] = YValues[i][count - 1 - j];
                //            YValues[i][count - 1 - j] = tempYVal;
                //        }
                //    }
                //}

                //找到最大数据值,方便设置柱状图最大高度。杨斌 2012-04-11
                double yValueMax = maxValue;
                //for (int i = 0; i < this.YValues.Count; i++)
                //{
                //    double[] YVals = this.YValues[i];
                //    for (int j = 0; j < YVals.Length; j++)
                //    {
                //        if (YVals[j] > yValueMax)
                //            yValueMax = YVals[j];
                //    }
                //}
                if (this.YValues.Count > 1)//杨斌 2014-11-04
                {
                    if (UseStacked)
                    {
                        for (int j = 0; j < this.YValues[0].Length; j++)
                        {
                            double count = 0;
                            for (int i = 0; i < this.YValues.Count; i++)
                            {
                                count += this.YValues[i][j];
                            }
                            if (count > yValueMax)
                                yValueMax = count;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < this.YValues.Count; i++)
                        {
                            double[] YVals = this.YValues[i];
                            for (int j = 0; j < YVals.Length; j++)
                            {
                                if (YVals[j] > yValueMax)
                                    yValueMax = YVals[j];
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < this.YValues.Count; i++)
                    {
                        double[] YVals = this.YValues[i];
                        for (int j = 0; j < YVals.Length; j++)
                        {
                            if (YVals[j] > yValueMax)
                                yValueMax = YVals[j];
                        }
                    }
                }

                //创建数据系列
                //for (int i = 0; i < this.YValues.Count; i++)
                //{
                Series series = MsChart.Series[y];

                //DrawingStyle取值范围:Cylinder 、Emboss、LightToDark、Wedge、Default。杨斌 2014-04-18
                //series.ChartArea = this.MsChart.ChartAreas[y].Name;

                this.LegendStyle = LegendStyles.lsColumn;
                ////图表类型
                //switch (this.chartType)
                //{
                //    case ChartTypes.ctColumn:
                //    case ChartTypes.ctColumnBox:
                //        //series.ChartType = SeriesChartType.Column;
                //        if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-11-04
                //        {
                //            series.ChartType = SeriesChartType.StackedColumn;
                //            //this.LegendStyle = LegendStyles.lstTable;
                //            this.LegendStyle = LegendStyles.lsColumn;
                //        }
                //        else
                //        {
                //            series.ChartType = SeriesChartType.Column;
                //            this.LegendStyle = LegendStyles.lsColumn;
                //        }
                //        //系列效果 杨斌 2014-11-04
                //        if (this.chartType == ChartTypes.ctColumn)
                //            series["DrawingStyle"] = "Cylinder";       // 圆柱
                //        else
                //            series["DrawingStyle"] = "Default";

                //        //if (iChangeColor == 1 && iChiceCount > 1)  // 颜色翻转(上次是Bar时颜色时翻转) -jdragon 20120204
                //        //{
                //        //    Color[] tempColors = this.SeriesColors;
                //        //    Color tempColor;
                //        //    for (int j = 0; j < iChiceCount / 2; j++)
                //        //    {
                //        //        tempColor = tempColors[iChiceCount - 1 - j];
                //        //        tempColors[iChiceCount - 1 - j] = tempColors[j];
                //        //        tempColors[j] = tempColor;
                //        //    }
                //        //    this.SeriesColors = tempColors;
                //        //}
                //        //iChangeColor = 2;
                //        break;
                //    case ChartTypes.ctBar:
                //    case ChartTypes.ctBarBox:
                //    case ChartTypes.ctText://杨斌 2015-04-20
                //        //series.ChartType = SeriesChartType.Bar;
                //        if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-11-04
                //        {
                //            series.ChartType = SeriesChartType.StackedBar;
                //            //this.LegendStyle = LegendStyles.lstTable;
                //            this.LegendStyle = LegendStyles.lsColumn;
                //        }
                //        else
                //        {
                //            series.ChartType = SeriesChartType.Bar;
                //            this.LegendStyle = LegendStyles.lsColumn;
                //        }
                //        //系列效果 杨斌 2014-11-04
                //        if (this.chartType == ChartTypes.ctBar)
                //            series["DrawingStyle"] = "Cylinder";       // 圆柱
                //        else
                //            series["DrawingStyle"] = "Default";

                //        ////颜色翻转--20120202
                //        //string[] XValsTemp = this.XValue;
                //        //if (iChangeColor != 1)  //颜色翻转
                //        //{
                //        //    Color[] tempColors = this.SeriesColors;
                //        //    int count = XValsTemp.Length;
                //        //    iChiceCount = XValsTemp.Length;
                //        //    Color tempColor;
                //        //    for (int j = 0; j < count / 2; j++)
                //        //    {
                //        //        tempColor = tempColors[count - 1 - j];
                //        //        tempColors[count - 1 - j] = tempColors[j];
                //        //        tempColors[j] = tempColor;
                //        //    }
                //        //    this.SeriesColors = tempColors;
                //        //    iChangeColor = 1;
                //        //}

                //        break;
                //    //case ChartTypes.ctColumnBox://杨斌 2014-04-22
                //    //    series.ChartType = SeriesChartType.Column;
                //    //    //系列效果
                //    //    series["DrawingStyle"] = "Default";
                //    //    break;
                //    //case ChartTypes.ctBarBox://杨斌 2014-04-22
                //    //    series.ChartType = SeriesChartType.Bar;
                //    //    //系列效果
                //    //    series["DrawingStyle"] = "Default";
                //    //    break;
                //    case ChartTypes.ctPie://PieDrawingStyle范围:Default、SoftEdge、Concave
                //        series.ChartType = SeriesChartType.Pie;
                //        //系列效果
                //        series["PieDrawingStyle"] = "Default";//默认
                //        //if (iChangeColor == 1 && iChiceCount > 1)   // 颜色翻转(上次是Bar时颜色时翻转) -jdragon 20120204
                //        //{
                //        //    Color[] tempColors = this.SeriesColors;
                //        //    Color tempColor;
                //        //    for (int j = 0; j < iChiceCount / 2; j++)
                //        //    {
                //        //        tempColor = tempColors[iChiceCount - 1 - j];
                //        //        tempColors[iChiceCount - 1 - j] = tempColors[j];
                //        //        tempColors[j] = tempColor;
                //        //    }
                //        //    this.SeriesColors = tempColors;
                //        //}
                //        //iChangeColor = 2;
                //        break;
                //}

                //不显示柱状图。杨斌 2015-04-20
                ////series.Points.DataBindXY(this.XValue, this.YValues[i]);
                double[] zeroVal = new double[this.YValues[0].Length];//杨斌 2016-05-17

                if (chartArea.Name == "AreaRank")//杨斌 2016-05-17
                {
                    int itemCount = zeroVal.Length;
                    string[] aryItemR = new string[itemCount];
                    double[] aryValueR = new double[itemCount];
                    for (int n = 0; n < itemCount; n++)
                    {
                        aryItemR[n] = (aryItemR.Length - n).ToString();
                    }
                    series.Points.DataBindXY(aryItemR, aryValueR);
                }
                else
                {
                    //排序处理。杨斌 2016-05-17
                    List<object[]> lsOrder = new List<object[]>();
                    for (int j = 0; j < this.YValues[y].Length; j++)
                    {
                        lsOrder.Add(new object[] { j, this.YValues[y][j] });
                    }
                    lsOrder = lsOrder.OrderBy(o => o[1]).ToList();
                    List<int> lsOn = new List<int>();
                    string[] newXValue = null;
                    double[] newYValue = null;
                    if (lsOrder.Count > 0)
                    {
                        foreach (var v in lsOrder)
                        {
                            lsOn.Add((int)v[0]);
                        }
                        newXValue = new string[lsOrder.Count];
                        newYValue = new double[lsOrder.Count];
                        for (int j = 0; j < this.YValues[y].Length; j++)
                        {
                            newXValue[j] = this.XValue[lsOn[j]];
                            newYValue[j] = this.YValues[y][lsOn[j]];
                        }
                        for (int j = 0; j < this.YValues[y].Length; j++)
                        {
                            this.YValues[y][j] = newYValue[j];
                        }
                    }

                    bool showBar = !(this.chartType == ChartTypes.ctText);
                    if (showBar)
                    {
                        series.Points.DataBindXY(newXValue, newYValue);
                    }
                    else
                    {
                        chartArea.AxisX.LineColor = Color.Transparent;
                        chartArea.AxisX.MajorTickMark.Enabled = false;
                        chartArea.AxisX.MajorGrid.Enabled = false;

                        series.Points.DataBindXY(this.XValue, zeroVal);
                    }

                    //设置标签
                    series.IsValueShownAsLabel = true;

                    switch (this.labelType)
                    {
                        case LabelTypes.ltNone://不显示标签
                            series.IsValueShownAsLabel = false;
                            break;
                        case LabelTypes.ltNumberValue://显示数值
                            for (int j = 0; j < series.Points.Count; j++)
                            {
                                //if (NumberDec < 0)//杨斌 2014-08-07
                                //    series.Points[j].Label = series.Points[j].GetValueByName("Y").ToString();
                                //else
                                //    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y"));

                                if (NumberDec < 0)//杨斌 2014-08-07
                                    series.Points[j].Label = this.YValues[y][j].ToString();
                                else
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[y][j]);
                            }
                            break;
                        case LabelTypes.ltPercent://显示百分比
                            for (int j = 0; j < series.Points.Count; j++)
                            {
                                if (this.LabelDenominator > 0)//设置了分母
                                {
                                    //series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                    series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[y][j] / this.LabelDenominator * 100) + "%";
                                }
                                else if (this.LabelDenominator == 0)//没有设置分母
                                {
                                    double count = this.SumPointsValue(series);
                                    if (this.UseStacked)//杨斌 2014-11-10
                                    {
                                        count = 0;
                                        for (int n = 0; n < YValues.Count; n++)
                                            count += YValues[n][j];
                                    }
                                    //杨斌 2015-06-18
                                    if ((this.LabelDenominatorOptionLimit == 0) || (j < this.LabelDenominatorOptionLimit))
                                        //series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? series.Points[j].GetValueByName("Y") / count : 0) * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? this.YValues[y][j] / count : 0) * 100) + "%";
                                    else
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[y][j]);

                                }
                            }
                            break;
                        case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                            for (int j = 0; j < series.Points.Count; j++)
                            {
                                if (this.LabelDenominator > 0)//设置了分母
                                {
                                    if (series.ChartType == SeriesChartType.Bar)
                                    {
                                        //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + ";  " +
                                        //  String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[y][j]) + ";  " +
                                          String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[y][j] / this.LabelDenominator * 100) + "%";
                                    }
                                    else
                                    {
                                        //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + "\n" +
                                        //    String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[y][j]) + "\n" +
                                            String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[y][j] / this.LabelDenominator * 100) + "%";
                                    }
                                }
                                else if (this.LabelDenominator == 0)//没有设置分母
                                {
                                    double count = this.SumPointsValue(series);
                                    if (this.UseStacked)//杨斌 2014-11-10
                                    {
                                        count = 0;
                                        for (int n = 0; n < YValues.Count; n++)
                                            count += YValues[n][j];
                                    }
                                    //杨斌 2015-06-18
                                    string spl = "; ";
                                    if (series.ChartType == SeriesChartType.Bar)
                                    {
                                        spl = "; ";
                                    }
                                    else
                                    {
                                        spl = "\n";
                                    }
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[y][j]);
                                    if ((this.LabelDenominatorOptionLimit == 0) || (j < this.LabelDenominatorOptionLimit))
                                        series.Points[j].Label += spl + String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? this.YValues[y][j] / count : 0) * 100) + "%";

                                }

                            }

                            break;
                    }
                }

                ////杨斌 2014-09-01 3D条形图数据标签右移
                //if (this.labelType != LabelTypes.ltNone)
                //{
                //    if (chartArea.Area3DStyle.Enable3D)
                //    {
                //        switch (series.ChartType)
                //        {
                //            case SeriesChartType.Bar:
                //                for (int j = 0; j < series.Points.Count; j++)
                //                {
                //                    series.Points[j].Label = "  " + series.Points[j].Label;
                //                }
                //                break;
                //        }
                //    }
                //}

                //if (this.labelType != LabelTypes.ltNone)
                //{
                //    //堆积图表数据为0不显示。杨斌 2014-02-20
                //    for (int j = 0; j < series.Points.Count; j++)
                //    {
                //        switch (series.ChartType)
                //        {
                //            case SeriesChartType.StackedColumn:
                //            case SeriesChartType.StackedBar:
                //                if (series.Points[j].GetValueByName("Y") == 0)
                //                    series.Points[j].Label = " ";
                //                //series.Label = "AA";
                //                break;
                //        }
                //    }
                //}

                if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-01-27
                {
                }
                else
                {
                    //控制百分比显示在柱状图的外面,杨斌 2012-04-11
                    //chartArea.AxisY.Maximum = yValueMax * 1.16;// Double.NaN;//默认自动
                    //if (hchuw < 0.9) hchuw = 0.9;
                    //switch (this.labelType)
                    //{
                    //    case LabelTypes.ltNone://不显示标签       
                    //        break;
                    //    case LabelTypes.ltNumberValue://显示数值
                    //        break;
                    //    case LabelTypes.ltPercent://显示百分比
                    //        if (this.ChartType == ChartTypes.ctBar)
                    //            chartArea.AxisY.Maximum = yValueMax * 1.4;
                    //        break;
                    //    case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                    //        if (this.ChartType == ChartTypes.ctBar)
                    //            chartArea.AxisY.Maximum = yValueMax * 1.7;
                    //        break;
                    //}
                    //杨斌 2012-06-06
                    chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;

                    double wchuh = (double)MsChart.Width / MsChart.Height;
                    if (wchuh > 2)
                        chartArea.AxisY.Maximum = yValueMax + 25;
                    else
                        chartArea.AxisY.Maximum = yValueMax * 2 + 30;

                    //杨斌 2013-02-22
                    if (MaxDataValue > yValueMax)
                        yValueMax = MaxDataValue;
                    double cC = 0;//字宽/高
                    double cL = 0;//柱宽/高
                    switch (this.chartType)
                    {
                        case ChartTypes.ctBar:
                        case ChartTypes.ctBarBox://杨斌 2014-04-22
                            cC = 15 * dataLabelFont.Size / 14;//字宽。字号14,16=15,根据字体算
                            cL = (double)MsChart.Width * 0.9;//柱宽  
                            switch (this.labelType)
                            {
                                case LabelTypes.ltNone://不显示标签       
                                    break;
                                case LabelTypes.ltNumberValue://显示数值
                                    cC *= (((int)yValueMax).ToString().Length + 1);
                                    break;
                                case LabelTypes.ltPercent://显示百分比
                                    cC *= ("100.0%".Length);
                                    //cC *= 0.95;//杨斌 2013-03-14
                                    break;
                                case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                                    cC *= (((int)yValueMax).ToString().Length + "; 100.0%".Length);
                                    //cC *= 0.95;//杨斌 2013-03-14
                                    break;
                            }
                            if (cL > cC)
                            {
                                double cL2 = cL - cC;//去掉字宽的条形图柱宽
                                yValueMax = yValueMax * cL / cL2;
                            }
                            else
                            {
                                yValueMax = yValueMax * 100;
                            }
                            break;
                        case ChartTypes.ctColumn:
                        case ChartTypes.ctColumnBox://杨斌 2014-04-22
                            cC = 30 * dataLabelFont.Size / 14;//字高。字号14,16=30,根据字体算
                            cL = (double)MsChart.Height * 0.8;//柱高  

                            //杨斌 2015-03-31
                            if ((chartArea.AxisX.Enabled == AxisEnabled.True) && (XValue.Length > 0))
                            {
                                foreach (string s in XValue)
                                {
                                    if (Encoding.Default.GetByteCount(s) > 10)
                                    {
                                        cL = cL * 0.5;
                                        break;
                                    }
                                }
                            }

                            switch (this.labelType)
                            {
                                case LabelTypes.ltNone://不显示标签       
                                    break;
                                case LabelTypes.ltNumberValue://显示数值                                
                                    break;
                                case LabelTypes.ltPercent://显示百分比                                
                                    break;
                                case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                                    cC *= 2;//两行显示
                                    break;
                            }
                            if (cL > cC)
                            {
                                double cL2 = cL - cC;//去掉字宽的条形图柱宽
                                yValueMax = yValueMax * cL / cL2;
                            }
                            else
                            {
                                yValueMax = yValueMax * 100;
                            }
                            break;
                    }
                }
                chartArea.AxisY.Maximum = yValueMax;

                //系列颜色
                series.Color = this.SeriesColors[y % this.SeriesColors.Length];
                MsChart.ChartAreas[series.ChartArea].BorderColor = series.Color;

                //杨斌 2012-06-26
                ////系列标签文本格式
                ////series.Font = new Font("Arial", 16);                 
                //if (series.Points.Count > 16)
                //{
                //    series.Font = new Font("Arial", 4);
                //    chartArea.AxisX.LabelStyle.Font = new Font("Arial", 4);
                //    chartArea.AxisY.LabelStyle.Font = new Font("Arial", 4);
                //}
                //else
                //{
                //    float size = 16;//原来是20 杨斌 2012-06-06
                //    series.Font = new Font("Arial", size - series.Points.Count);
                //    //X/Y轴标签文本格式,如字体、字号、字形属性(必须放在Add之后,否则字号无效)
                //    chartArea.AxisX.LabelStyle.Font = new Font("Arial", size - series.Points.Count);
                //    chartArea.AxisY.LabelStyle.Font = new Font("Arial", size - series.Points.Count);
                //}

                //杨斌 2015-05-29
                if (this.UseSystemFont)
                {
                    chartArea.AxisX.LabelStyle.Font = new Font(GlobalInfo.SysFontName, ItemLabelFont.Size);// new Font("Arial", 16);//杨斌 2012-06-26
                    chartArea.AxisY.LabelStyle.Font = new Font(GlobalInfo.SysFontName, 16);
                    series.Font = new Font(GlobalInfo.SysFontName, DataLabelFont.Size);// new Font("Arial", 16);//杨斌 2012-06-26
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Font = ItemLabelFont;// new Font("Arial", 16);//杨斌 2012-06-26
                    chartArea.AxisY.LabelStyle.Font = new Font("Arial", 16);
                    series.Font = DataLabelFont;// new Font("Arial", 16);//杨斌 2012-06-26
                }

                //系列标签文本颜色
                series.LabelForeColor = DataLabelColor;// Color.Black;//杨斌 2012-06-26

                //添加数据系列
                //this.MsChart.Series.Add(series);

                ////如果是饼图设置Point边框
                //if (this.is3D == false && this.chartType == ChartTypes.ctPie)
                //{
                //    for (int j = 0; j < series.Points.Count; j++)
                //    {
                //        series.Points[j].BorderColor = Color.Silver;
                //        series.Points[j].BorderDashStyle = ChartDashStyle.Solid;
                //        series.Points[j].BorderWidth = 1;
                //    }
                //}
                //}

                //设置图表区域大小,尽量大。杨斌 2012-04-11
                //for (int i = 0; i < MsChart.ChartAreas.Count; i++)
                //{
                //    MsChart.ChartAreas[i].Position.Width = 100;
                //    MsChart.ChartAreas[i].Position.Height = 100;
                //}

                //设置Point颜色,只支持一个系列时设置
                if (MsChart.Series.Count == 2)//杨斌 2016-05-17
                {
                    if ((this.chartType == ChartTypes.ctBar) || (this.chartType == ChartTypes.ctBarBox))//颜色翻转 杨斌 2014-04-22
                    {
                        if (this.PointColors != null && this.PointColors.Length > 0)
                        {
                            for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                                MsChart.Series[0].Points[j].Color = this.PointColors[(this.PointColors.Length - 1 - j) % this.PointColors.Length];
                        }
                        else
                        {
                            for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                                MsChart.Series[0].Points[j].Color = this.SeriesColors[(MsChart.Series[0].Points.Count - 1 - j) % MsChart.Series[0].Points.Count];
                        }
                    }
                    else
                    {
                        if (this.PointColors != null && this.PointColors.Length > 0)
                        {
                            for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                                MsChart.Series[0].Points[j].Color = this.PointColors[j % this.PointColors.Length];
                        }
                        else
                        {
                            for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                            {
                                MsChart.Series[0].Points[j].Color = this.SeriesColors[j % MsChart.Series[0].Points.Count];
                            }
                        }
                    }
                    //if (this.PointColors != null && this.PointColors.Length > 0)
                    //{
                    //    for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                    //        MsChart.Series[0].Points[j].Color = this.PointColors[j % this.PointColors.Length];
                    //}
                    //else
                    //{
                    //    for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                    //        MsChart.Series[0].Points[j].Color = this.SeriesColors[j % MsChart.Series[0].Points.Count];
                    //}
                }


                //系列各项的宽度,必须0-1之间,0表示默认
                for (int i = 0; i < MsChart.Series.Count; i++)
                {
                    string pointWidth = "";
                    if (this.PointWidth == 0)//杨斌 2014-05-14
                        pointWidth = (Double.Parse(MsChart.Series.Count.ToString()) / (MsChart.Series.Count + 1)).ToString();
                    else
                        pointWidth = this.PointWidth.ToString();
                    pointWidth = pointWidth.Replace(',', '.');
                    MsChart.Series[i]["PointWidth"] = pointWidth;
                    //MsChart.Series[i]["PointWidth"] = "0.1";
                    MsChart.Series[i]["PieStartAngle"] = "270";//饼图起始角度 杨斌 2012-06-08

                    //饼图变形。杨斌 2015-07-07
                    //MsChart.Series[i].Points[0].BorderWidth = 3;
                    //MsChart.Series[i].Points[1].BorderWidth = 100;
                }
            }

            return true;
        }

        /// <summary>
        /// 图表更新。杨斌 2016-06-16
        /// </summary>
        /// <param name="multiChartAreas"></param>
        /// <returns></returns>
        public bool UpdateChart(bool multiChartAreas = false, string numUnit = "")
        {
            return UpdateChart(MsChart, multiChartAreas, numUnit);
        }

        /// <summary>
        /// 图表更新
        /// </summary>
        /// <returns>初始化成功:True,初始化失败:False</returns>
        public bool UpdateChart(Chart MsChart, bool multiChartAreas = false, string numUnit = "")
        {
            //图表、字体清晰度(锯齿)
            MsChart.AntiAliasing = AntiAliasingStyles.Graphics;

            //图表背景色
            MsChart.BackColor = Color.Transparent;

            //图表位置
            //MsChart.Location = new System.Drawing.Point(5, 10);
            MsChart.Location = new System.Drawing.Point(0, 0);
            //图表大小
            MsChart.Size = new System.Drawing.Size(this.width, this.height);

            //清除图表(区域)
            MsChart.ChartAreas.Clear();

            //创建图表区域
            ChartArea chartArea = new ChartArea();

            //ChartAreas:增加多个绘图区域,每个绘图区域包含独立的图表组、数据源,用于多个图表类型在一个绘图区不兼容时。

            //添加图表区域到图表
            MsChart.ChartAreas.Add(chartArea);
            MsChart.ChartAreas[0].AxisX.LabelStyle.Interval = 1;//解决图表显示13 5 7 9 11问题

            //是否3D
            chartArea.Area3DStyle.Enable3D = this.is3D;//.ChartParam.Is3D;
            //设置图片旋转角度、倾斜角度
            if (this.chartType == ChartTypes.ctPie)
            {
                //旋转角度
                chartArea.Area3DStyle.Rotation = 0;
                //倾斜角度
                chartArea.Area3DStyle.Inclination = 25;  //20111226修改
            }
            else
            {
                //旋转角度
                chartArea.Area3DStyle.Rotation = 10;
                //倾斜角度
                chartArea.Area3DStyle.Inclination = 20;
            }

            //数据列是否聚合
            chartArea.Area3DStyle.IsClustered = false;// this.ChartParam.IsClustered;

            //图表区域背景色
            chartArea.BackColor = Color.Transparent;

            //是否显示Y轴
            chartArea.AxisY.Enabled = this.AxisYEnabled ? AxisEnabled.True : AxisEnabled.False;

            //是否显示x轴
            chartArea.AxisX.Enabled = axisXEnable ? AxisEnabled.True : AxisEnabled.False;

            //X/Y轴网格线
            chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
            chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;

            //X/Y轴标签文本格式,如字体、字号、字形属性(必须放在Add之后,否则字号无效)
            // chartArea.AxisX.LabelStyle.Font = new Font("Arial", 16); ;
            // chartArea.AxisY.LabelStyle.Font = new Font("Arial", 16); ;

            //X/Y轴标签文本颜色
            chartArea.AxisY.LabelStyle.ForeColor = Color.Black;
            chartArea.AxisX.LabelStyle.ForeColor = ItemLabelColor;//Color.Black;//杨斌 2012-06-26

            //系列各项深度,3D时有效,取值0-1000之间,默认60
            chartArea.Area3DStyle.PointDepth = 60;// this.ChartParam.PointDepth;

            //系列各项前后空白的深度,3D时有效,取值0-1000之间,默认100
            chartArea.Area3DStyle.PointGapDepth = 100;// this.ChartParam.PointGapDepth;

            //图表标题。杨斌 2017-03-21
            MsChart.Titles.Clear();
            if (!string.IsNullOrEmpty(ChartTitle))
            {
                Title ti = new Title(ChartTitle, Docking.Top);
                ti.Name = "Title";
                ti.Alignment = ContentAlignment.MiddleCenter;
                ti.ForeColor = Color.Black;
                ti.Font = new Font(ItemLabelFont.Name, ItemLabelFont.Size, ItemLabelFont.Style);
                MsChart.Titles.Add(ti);
            }

            MsChart.Series.Clear();
            if (iChangeColor == 1 && iChiceCount > 1)  // 颜色翻转-颜色还原 --解决由5个选项变成7个选项颜色会变的bug jdragon -2012-02-06
            {
                Color[] tempColors = this.SeriesColors;
                Color tempColor;
                for (int j = 0; j < iChiceCount / 2; j++)
                {
                    tempColor = tempColors[iChiceCount - 1 - j];
                    tempColors[iChiceCount - 1 - j] = tempColors[j];
                    tempColors[j] = tempColor;
                }
                this.SeriesColors = tempColors;
                iChangeColor = 2;
            }

            //如果是条形图,反转数据,颜色翻转 杨斌 2014-03-21
            if ((this.chartType == ChartTypes.ctBar) ||
                (this.chartType == ChartTypes.ctBarBox) ||
                ((this.chartType == ChartTypes.ctText) && (!TextChartTypeByLine)))//杨斌 2015-04-20
            {
                //杨斌 2014-12-09
                string tempXVal;
                double tempYVal;
                int count = XValue.Length;
                for (int j = 0; j < count / 2; j++)
                {
                    tempXVal = XValue[j];
                    XValue[j] = XValue[count - 1 - j];
                    XValue[count - 1 - j] = tempXVal;
                }
                for (int i = 0; i < YValues.Count; i++)
                {
                    count = YValues[i].Length;
                    for (int j = 0; j < count / 2; j++)
                    {
                        //tempXVal = XValue[j];
                        //XValue[j] = XValue[count - 1 - j];
                        //XValue[count - 1 - j] = tempXVal;

                        tempYVal = YValues[i][j];
                        YValues[i][j] = YValues[i][count - 1 - j];
                        YValues[i][count - 1 - j] = tempYVal;
                    }
                }
            }

            //找到最大数据值,方便设置柱状图最大高度。杨斌 2012-04-11
            double yValueMax = maxValue;
            //for (int i = 0; i < this.YValues.Count; i++)
            //{
            //    double[] YVals = this.YValues[i];
            //    for (int j = 0; j < YVals.Length; j++)
            //    {
            //        if (YVals[j] > yValueMax)
            //            yValueMax = YVals[j];
            //    }
            //}
            if (this.YValues.Count > 1)//杨斌 2014-11-04
            {
                if (UseStacked)
                {
                    for (int j = 0; j < this.YValues[0].Length; j++)
                    {
                        double count = 0;
                        for (int i = 0; i < this.YValues.Count; i++)
                        {
                            count += this.YValues[i][j];
                        }
                        if (count > yValueMax)
                            yValueMax = count;
                    }
                }
                else
                {
                    for (int i = 0; i < this.YValues.Count; i++)
                    {
                        double[] YVals = this.YValues[i];
                        for (int j = 0; j < YVals.Length; j++)
                        {
                            if (YVals[j] > yValueMax)
                                yValueMax = YVals[j];
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < this.YValues.Count; i++)
                {
                    double[] YVals = this.YValues[i];
                    for (int j = 0; j < YVals.Length; j++)
                    {
                        if (YVals[j] > yValueMax)
                            yValueMax = YVals[j];
                    }
                }
            }

            //创建数据系列
            for (int i = 0; i < this.YValues.Count; i++)
            {
                Series series = new Series();

                //DrawingStyle取值范围:Cylinder 、Emboss、LightToDark、Wedge、Default。杨斌 2014-04-18

                //图表类型
                switch (this.chartType)
                {

                    case ChartTypes.ctColumn:
                    case ChartTypes.ctColumnBox:
                        //series.ChartType = SeriesChartType.Column;
                        if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-11-04
                        {
                            series.ChartType = UseStacked100 ? SeriesChartType.StackedColumn100 : SeriesChartType.StackedColumn;//杨斌 2017-06-13
                            //this.LegendStyle = LegendStyles.lstTable;
                            this.LegendStyle = LegendStyles.lsColumn;
                        }
                        else
                        {
                            series.ChartType = SeriesChartType.Column;
                            this.LegendStyle = LegendStyles.lsColumn;
                        }
                        //系列效果 杨斌 2014-11-04
                        if (this.chartType == ChartTypes.ctColumn)
                            series["DrawingStyle"] = "Cylinder";       // 圆柱
                        else
                            series["DrawingStyle"] = "Default";

                        //if (iChangeColor == 1 && iChiceCount > 1)  // 颜色翻转(上次是Bar时颜色时翻转) -jdragon 20120204
                        //{
                        //    Color[] tempColors = this.SeriesColors;
                        //    Color tempColor;
                        //    for (int j = 0; j < iChiceCount / 2; j++)
                        //    {
                        //        tempColor = tempColors[iChiceCount - 1 - j];
                        //        tempColors[iChiceCount - 1 - j] = tempColors[j];
                        //        tempColors[j] = tempColor;
                        //    }
                        //    this.SeriesColors = tempColors;
                        //}
                        //iChangeColor = 2;
                        break;
                    case ChartTypes.ctBar:
                    case ChartTypes.ctBarBox:
                    case ChartTypes.ctText://杨斌 2015-04-20
                        //series.ChartType = SeriesChartType.Bar;
                        if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-11-04
                        {
                            series.ChartType = UseStacked100 ? SeriesChartType.StackedBar100 : SeriesChartType.StackedBar;//杨斌 2017-06-13
                            //this.LegendStyle = LegendStyles.lstTable;
                            this.LegendStyle = LegendStyles.lsColumn;
                        }
                        else
                        {
                            //杨斌 2019-04-03
                            if (TextChartTypeByLine)
                                series.ChartType = SeriesChartType.Column;
                            else
                                series.ChartType = SeriesChartType.Bar;
                            this.LegendStyle = LegendStyles.lsColumn;
                        }
                        //系列效果 杨斌 2014-11-04
                        if (this.chartType == ChartTypes.ctBar)
                            series["DrawingStyle"] = "Cylinder";       // 圆柱
                        else
                            series["DrawingStyle"] = "Default";

                        ////颜色翻转--20120202
                        //string[] XValsTemp = this.XValue;
                        //if (iChangeColor != 1)  //颜色翻转
                        //{
                        //    Color[] tempColors = this.SeriesColors;
                        //    int count = XValsTemp.Length;
                        //    iChiceCount = XValsTemp.Length;
                        //    Color tempColor;
                        //    for (int j = 0; j < count / 2; j++)
                        //    {
                        //        tempColor = tempColors[count - 1 - j];
                        //        tempColors[count - 1 - j] = tempColors[j];
                        //        tempColors[j] = tempColor;
                        //    }
                        //    this.SeriesColors = tempColors;
                        //    iChangeColor = 1;
                        //}

                        break;
                    //case ChartTypes.ctColumnBox://杨斌 2014-04-22
                    //    series.ChartType = SeriesChartType.Column;
                    //    //系列效果
                    //    series["DrawingStyle"] = "Default";
                    //    break;
                    //case ChartTypes.ctBarBox://杨斌 2014-04-22
                    //    series.ChartType = SeriesChartType.Bar;
                    //    //系列效果
                    //    series["DrawingStyle"] = "Default";
                    //    break;
                    case ChartTypes.ctPie://PieDrawingStyle范围:Default、SoftEdge、Concave
                        series.ChartType = SeriesChartType.Pie;
                        //系列效果
                        series["PieDrawingStyle"] = "Default";//默认
                        //if (iChangeColor == 1 && iChiceCount > 1)   // 颜色翻转(上次是Bar时颜色时翻转) -jdragon 20120204
                        //{
                        //    Color[] tempColors = this.SeriesColors;
                        //    Color tempColor;
                        //    for (int j = 0; j < iChiceCount / 2; j++)
                        //    {
                        //        tempColor = tempColors[iChiceCount - 1 - j];
                        //        tempColors[iChiceCount - 1 - j] = tempColors[j];
                        //        tempColors[j] = tempColor;
                        //    }
                        //    this.SeriesColors = tempColors;
                        //}
                        //iChangeColor = 2;
                        break;
                }


                //屏蔽下面代码,反转数据放到前面。杨斌 2014-11-10
                ////绑定数据
                //string[] XVals = this.XValue;
                //double[] YVals = this.YValues[i];

                //if ((series.ChartType == SeriesChartType.Bar) ||
                //(series.ChartType == SeriesChartType.StackedBar) ||
                //(series.ChartType == SeriesChartType.StackedBar100))//如果是条形图,反转数据,颜色翻转 杨斌 2014-03-21
                //{
                //    string tempXVal;
                //    double tempYVal;
                //    int count = XVals.Length;
                //    for (int j = 0; j < count / 2; j++)
                //    {
                //        tempXVal = XVals[count - 1 - j];
                //        tempYVal = YVals[count - 1 - j];
                //        XVals[count - 1 - j] = XVals[j];
                //        YVals[count - 1 - j] = YVals[j];
                //        XVals[j] = tempXVal;
                //        YVals[j] = tempYVal;
                //    }
                //    //绑定数据
                //    series.Points.DataBindXY(XVals, YVals);
                //}
                //else
                //绑定数据                

                //不显示柱状图。杨斌 2015-04-20
                ////series.Points.DataBindXY(this.XValue, this.YValues[i]);
                double[] zeroVal = new double[this.YValues[i].Length];
                //杨斌 2019-04-03
                bool showBar = (this.chartType != ChartTypes.ctText);
                if (showBar)
                {
                    series.Points.DataBindXY(this.XValue, this.YValues[i]);
                }
                else
                {
                    chartArea.AxisX.LineColor = Color.Transparent;
                    chartArea.AxisX.MajorTickMark.Enabled = false;
                    chartArea.AxisX.MajorGrid.Enabled = false;

                    //杨斌 2019-04-03
                    chartArea.AxisY.LineColor = Color.Transparent;
                    chartArea.AxisY.MajorTickMark.Enabled = false;
                    chartArea.AxisY.MajorGrid.Enabled = false;

                    series.Points.DataBindXY(this.XValue, zeroVal);
                }

                //设置标签
                series.IsValueShownAsLabel = true;

                switch (this.labelType)
                {
                    case LabelTypes.ltNone://不显示标签
                        series.IsValueShownAsLabel = false;
                        break;
                    case LabelTypes.ltNumberValue://显示数值                        
                        for (int j = 0; j < series.Points.Count; j++)
                        {
                            //if (NumberDec < 0)//杨斌 2014-08-07
                            //    series.Points[j].Label = series.Points[j].GetValueByName("Y").ToString();
                            //else
                            //    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y"));

                            if ((YValuesNew != null) && (YValuesNew.Count > 0))//杨斌 2019-11-26
                            {
                                if (NumberDec < 0)//杨斌 2014-08-07
                                    series.Points[j].Label = this.YValuesNew[i][j].ToString();
                                else
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValuesNew[i][j]);
                            }
                            else
                            {
                                if (NumberDec < 0)//杨斌 2014-08-07
                                    series.Points[j].Label = this.YValues[i][j].ToString();
                                else
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[i][j]);
                            }
                            series.Points[j].Label += numUnit;//杨斌 2018-05-09
                        }
                        break;
                    case LabelTypes.ltPercent://显示百分比
                        for (int j = 0; j < series.Points.Count; j++)
                        {
                            if (this.LabelDenominator > 0)//设置了分母
                            {
                                //series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[i][j] / this.LabelDenominator * 100) + "%";
                            }
                            else if (this.LabelDenominator == 0)//没有设置分母
                            {
                                double count = this.SumPointsValue(series);
                                if (this.UseStacked)//杨斌 2014-11-10
                                {
                                    count = 0;
                                    for (int n = 0; n < YValues.Count; n++)
                                        count += YValues[n][j];
                                }
                                //杨斌 2015-06-18
                                if ((this.LabelDenominatorOptionLimit == 0) || (j < this.LabelDenominatorOptionLimit))
                                    //series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? series.Points[j].GetValueByName("Y") / count : 0) * 100) + "%";
                                    series.Points[j].Label = String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? this.YValues[i][j] / count : 0) * 100) + "%";
                                else
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[i][j]);

                            }
                        }
                        break;
                    case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                        for (int j = 0; j < series.Points.Count; j++)
                        {
                            if (this.LabelDenominator > 0)//设置了分母
                            {
                                if (series.ChartType == SeriesChartType.Bar)
                                {
                                    if ((YValuesNew != null) && (YValuesNew.Count > 0))//杨斌 2019-11-26
                                    {
                                        //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + ";  " +
                                        //  String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValuesNew[i][j]) + numUnit/*杨斌 2018-05-09*/ + ";  " +
                                          String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[i][j] / this.LabelDenominator * 100) + "%";
                                    }
                                    else
                                    {
                                        //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + ";  " +
                                        //  String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[i][j]) + numUnit/*杨斌 2018-05-09*/ + ";  " +
                                          String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[i][j] / this.LabelDenominator * 100) + "%";
                                    }
                                }
                                else
                                {
                                    if ((YValuesNew != null) && (YValuesNew.Count > 0))//杨斌 2019-11-26
                                    {
                                       //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + "\n" +
                                        //    String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValuesNew[i][j]) + numUnit/*杨斌 2018-05-09*/ + "\n" +
                                        String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[i][j] / this.LabelDenominator * 100) + "%";
                                    }
                                    else
                                    {
                                        //series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", series.Points[j].GetValueByName("Y")) + "\n" +
                                        //    String.Format("{0:F" + PercentDec.ToString() + "}", series.Points[j].GetValueByName("Y") / this.LabelDenominator * 100) + "%";
                                        series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[i][j]) + numUnit/*杨斌 2018-05-09*/ + "\n" +
                                        String.Format("{0:F" + PercentDec.ToString() + "}", this.YValues[i][j] / this.LabelDenominator * 100) + "%";
                                    }
                                }
                            }
                            else if (this.LabelDenominator == 0)//没有设置分母
                            {
                                double count = this.SumPointsValue(series);
                                if (this.UseStacked)//杨斌 2014-11-10
                                {
                                    count = 0;
                                    for (int n = 0; n < YValues.Count; n++)
                                        count += YValues[n][j];
                                }
                                //杨斌 2015-06-18
                                string spl = "; ";
                                if (series.ChartType == SeriesChartType.Bar)
                                {
                                    spl = "; ";
                                }
                                else
                                {
                                    spl = "\n";
                                }
                                if ((YValuesNew != null) && (YValuesNew.Count > 0))//杨斌 2019-11-26
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValuesNew[i][j]);
                                else
                                    series.Points[j].Label = String.Format("{0:F" + NumberDec.ToString() + "}", this.YValues[i][j]);
                                if ((this.LabelDenominatorOptionLimit == 0) || (j < this.LabelDenominatorOptionLimit))
                                    series.Points[j].Label += spl + String.Format("{0:F" + PercentDec.ToString() + "}", (count > 0 ? this.YValues[i][j] / count : 0) * 100) + "%";

                            }

                        }

                        break;
                }

                if (this.labelType != LabelTypes.ltNone)
                {
                    switch (series.ChartType)//杨斌 2019-04-03
                    {
                        case SeriesChartType.Bar:
                            string addSpace = "";
                            addSpace = new string(' ', ChartTypeTextSpaceOrLine);
                            for (int j = 0; j < series.Points.Count; j++)
                            {
                                series.Points[j].Label = addSpace + series.Points[j].Label;
                            }
                            break;
                        case SeriesChartType.Column:
                            string addLine = "";
                            for (int n = 1; n <= ChartTypeTextSpaceOrLine; n++)
                            {
                                addLine += "\r\n";
                            }
                            for (int j = 0; j < series.Points.Count; j++)
                            {
                                series.Points[j].Label = series.Points[j].Label + addLine;
                            }
                            break;
                    }

                    if (chartArea.Area3DStyle.Enable3D)//杨斌 2014-09-01 3D条形图数据标签右移  
                    {
                        switch (series.ChartType)
                        {
                            case SeriesChartType.Bar:
                                for (int j = 0; j < series.Points.Count; j++)
                                {
                                    series.Points[j].Label = "  " + series.Points[j].Label;
                                }
                                break;
                        }
                    }
                }

                if (this.labelType != LabelTypes.ltNone)
                {
                    //堆积图表数据为0不显示。杨斌 2014-02-20
                    for (int j = 0; j < series.Points.Count; j++)
                    {
                        switch (series.ChartType)
                        {
                            case SeriesChartType.StackedColumn:
                            case SeriesChartType.StackedBar:
                                //case SeriesChartType.StackedColumn100:
                                //case SeriesChartType.StackedBar100:
                                if (series.Points[j].GetValueByName("Y") == 0)
                                    series.Points[j].Label = " ";
                                //series.Label = "AA";
                                break;
                        }
                    }
                }

                if ((this.YValues.Count > 1) && UseStacked)//杨斌 2014-01-27
                {
                }
                else
                {
                    //控制百分比显示在柱状图的外面,杨斌 2012-04-11
                    //chartArea.AxisY.Maximum = yValueMax * 1.16;// Double.NaN;//默认自动
                    //if (hchuw < 0.9) hchuw = 0.9;
                    //switch (this.labelType)
                    //{
                    //    case LabelTypes.ltNone://不显示标签       
                    //        break;
                    //    case LabelTypes.ltNumberValue://显示数值
                    //        break;
                    //    case LabelTypes.ltPercent://显示百分比
                    //        if (this.ChartType == ChartTypes.ctBar)
                    //            chartArea.AxisY.Maximum = yValueMax * 1.4;
                    //        break;
                    //    case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                    //        if (this.ChartType == ChartTypes.ctBar)
                    //            chartArea.AxisY.Maximum = yValueMax * 1.7;
                    //        break;
                    //}
                    //杨斌 2012-06-06
                    chartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;

                    double wchuh = (double)MsChart.Width / MsChart.Height;
                    if (wchuh > 2)
                        chartArea.AxisY.Maximum = yValueMax + 25;
                    else
                        chartArea.AxisY.Maximum = yValueMax * 2 + 30;

                    //杨斌 2013-02-22
                    if (MaxDataValue > yValueMax)
                        yValueMax = MaxDataValue;
                    double cC = 0;//字宽/高
                    double cL = 0;//柱宽/高
                    switch (this.chartType)
                    {
                        case ChartTypes.ctBar:
                        case ChartTypes.ctBarBox://杨斌 2014-04-22
                            cC = 15 * dataLabelFont.Size / 14;//字宽。字号14,16=15,根据字体算
                            cL = (double)MsChart.Width * 0.9;//柱宽  
                            switch (this.labelType)
                            {
                                case LabelTypes.ltNone://不显示标签       
                                    break;
                                case LabelTypes.ltNumberValue://显示数值
                                    cC *= (((int)yValueMax).ToString().Length + 1 + numUnit.Length);//杨斌 2018-05-09
                                    break;
                                case LabelTypes.ltPercent://显示百分比
                                    cC *= (" 100.0%".Length);
                                    //cC *= 0.95;//杨斌 2013-03-14
                                    break;
                                case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                                    cC *= (((int)yValueMax).ToString().Length + " ; 100.0%".Length + numUnit.Length);//杨斌 2018-05-09
                                    //cC *= 0.95;//杨斌 2013-03-14
                                    break;
                            }
                            if (cL > cC)
                            {
                                double cL2 = cL - cC;//去掉字宽的条形图柱宽
                                yValueMax = yValueMax * cL / cL2;
                            }
                            else
                            {
                                yValueMax = yValueMax * 100;
                            }
                            break;
                        case ChartTypes.ctColumn:
                        case ChartTypes.ctColumnBox://杨斌 2014-04-22
                            cC = 30 * dataLabelFont.Size / 14;//字高。字号14,16=30,根据字体算
                            cL = (double)MsChart.Height * 0.8;//柱高  

                            //杨斌 2015-03-31
                            if ((chartArea.AxisX.Enabled == AxisEnabled.True) && (XValue.Length > 0))
                            {
                                foreach (string s in XValue)
                                {
                                    if (Encoding.Default.GetByteCount(s) > 10)
                                    {
                                        cL = cL * 0.5;
                                        break;
                                    }
                                }
                            }

                            switch (this.labelType)
                            {
                                case LabelTypes.ltNone://不显示标签       
                                    break;
                                case LabelTypes.ltNumberValue://显示数值                                
                                    break;
                                case LabelTypes.ltPercent://显示百分比                                
                                    break;
                                case LabelTypes.ltNumberValueAndPercent://显示数值加百分比
                                    cC *= 2;//两行显示
                                    break;
                            }
                            if (cL > cC)
                            {
                                double cL2 = cL - cC;//去掉字宽的条形图柱宽
                                yValueMax = yValueMax * cL / cL2;
                            }
                            else
                            {
                                yValueMax = yValueMax * 100;
                            }
                            break;
                    }
                }

                //杨斌 2017-06-13
                switch (series.ChartType)
                {
                    //case SeriesChartType.StackedColumn:
                    case SeriesChartType.StackedColumn100:
                    //case SeriesChartType.StackedBar:
                    case SeriesChartType.StackedBar100:
                        break;
                    default:
                        chartArea.AxisY.Maximum = yValueMax;
                        break;
                }

                //系列颜色
                series.Color = this.SeriesColors[i % this.SeriesColors.Length];

                //杨斌 2012-06-26
                ////系列标签文本格式
                ////series.Font = new Font("Arial", 16);                 
                //if (series.Points.Count > 16)
                //{
                //    series.Font = new Font("Arial", 4);
                //    chartArea.AxisX.LabelStyle.Font = new Font("Arial", 4);
                //    chartArea.AxisY.LabelStyle.Font = new Font("Arial", 4);
                //}
                //else
                //{
                //    float size = 16;//原来是20 杨斌 2012-06-06
                //    series.Font = new Font("Arial", size - series.Points.Count);
                //    //X/Y轴标签文本格式,如字体、字号、字形属性(必须放在Add之后,否则字号无效)
                //    chartArea.AxisX.LabelStyle.Font = new Font("Arial", size - series.Points.Count);
                //    chartArea.AxisY.LabelStyle.Font = new Font("Arial", size - series.Points.Count);
                //}

                //杨斌 2015-05-29
                if (this.UseSystemFont)
                {
                    chartArea.AxisX.LabelStyle.Font = new Font(GlobalInfo.SysFontName, ItemLabelFont.Size);// new Font("Arial", 16);//杨斌 2012-06-26
                    chartArea.AxisY.LabelStyle.Font = new Font(GlobalInfo.SysFontName, 16);
                    series.Font = new Font(GlobalInfo.SysFontName, DataLabelFont.Size);// new Font("Arial", 16);//杨斌 2012-06-26
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Font = ItemLabelFont;// new Font("Arial", 16);//杨斌 2012-06-26
                    chartArea.AxisY.LabelStyle.Font = new Font("Arial", 16);
                    series.Font = DataLabelFont;// new Font("Arial", 16);//杨斌 2012-06-26
                }

                //系列标签文本颜色
                series.LabelForeColor = DataLabelColor;// Color.Black;//杨斌 2012-06-26

                //添加数据系列
                MsChart.Series.Add(series);

                //如果是饼图设置Point边框
                if (this.is3D == false && this.chartType == ChartTypes.ctPie)
                {
                    for (int j = 0; j < series.Points.Count; j++)
                    {
                        series.Points[j].BorderColor = Color.Silver;
                        series.Points[j].BorderDashStyle = ChartDashStyle.Solid;
                        series.Points[j].BorderWidth = 1;
                    }
                }

            }

            //设置图表区域大小,尽量大。杨斌 2012-04-11
            //for (int i = 0; i < MsChart.ChartAreas.Count; i++)
            //{
            //    MsChart.ChartAreas[i].Position.Width = 100;
            //    MsChart.ChartAreas[i].Position.Height = 100;
            //}

            //设置Point颜色,只支持一个系列时设置
            if (MsChart.Series.Count == 1)
            {
                if ((this.chartType == ChartTypes.ctBar) || (this.chartType == ChartTypes.ctBarBox))//颜色翻转 杨斌 2014-04-22
                {
                    if (this.PointColors != null && this.PointColors.Length > 0)
                    {
                        for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                            MsChart.Series[0].Points[j].Color = this.PointColors[(this.PointColors.Length - 1 - j) % this.PointColors.Length];
                    }
                    else
                    {
                        for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                            MsChart.Series[0].Points[j].Color = this.SeriesColors[(MsChart.Series[0].Points.Count - 1 - j) % MsChart.Series[0].Points.Count];
                    }
                }
                else
                {
                    if (this.PointColors != null && this.PointColors.Length > 0)
                    {
                        for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                            MsChart.Series[0].Points[j].Color = this.PointColors[j % this.PointColors.Length];
                    }
                    else
                    {
                        for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                        {
                            MsChart.Series[0].Points[j].Color = this.SeriesColors[j % MsChart.Series[0].Points.Count];
                        }
                    }
                }
                //if (this.PointColors != null && this.PointColors.Length > 0)
                //{
                //    for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                //        MsChart.Series[0].Points[j].Color = this.PointColors[j % this.PointColors.Length];
                //}
                //else
                //{
                //    for (int j = 0; j < MsChart.Series[0].Points.Count; j++)
                //        MsChart.Series[0].Points[j].Color = this.SeriesColors[j % MsChart.Series[0].Points.Count];
                //}
            }


            //系列各项的宽度,必须0-1之间,0表示默认
            for (int i = 0; i < MsChart.Series.Count; i++)
            {
                string pointWidth = "";
                if (this.PointWidth == 0)//杨斌 2014-05-14
                    pointWidth = (Double.Parse(MsChart.Series.Count.ToString()) / (MsChart.Series.Count + 1)).ToString();
                else
                    pointWidth = this.PointWidth.ToString();
                pointWidth = pointWidth.Replace(',', '.');
                MsChart.Series[i]["PointWidth"] = pointWidth;
                //MsChart.Series[i]["PointWidth"] = "0.1";
                MsChart.Series[i]["PieStartAngle"] = "270";//饼图起始角度 杨斌 2012-06-08

                //饼图变形。杨斌 2015-07-07
                //MsChart.Series[i].Points[0].BorderWidth = 3;
                //MsChart.Series[i].Points[1].BorderWidth = 100;
            }

            //杨斌 2015-02-10
            chartArea.AxisX.IsLabelAutoFit = true;
            chartArea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
            //chartArea.AxisX.LabelStyle.Angle = 45;//-90到90之间

            MsChart.Legends.Clear();
            //图例设置  && (this.chartType ==ChartTypes.ctPie)
            if (this.legendEnable)
            {
                MsChart.Legends.Add("");
                //背景透明
                MsChart.Legends[0].BackColor = Color.Transparent;
                //图例位置
                MsChart.Legends[0].Docking = (Docking)((int)this.legentDocking);
                //图例样式
                MsChart.Legends[0].LegendStyle = (LegendStyle)((int)this.LegendStyle);
                //图例对齐方式
                MsChart.Legends[0].Alignment = (StringAlignment)((int)this.LegendAlignment);

                //图例标签文本格式。系统字体。杨斌 2015-05-29
                if (this.UseSystemFont)
                    MsChart.Legends[0].Font = new Font(GlobalInfo.SysFontName, chartArea.AxisX.LabelStyle.Font.Size);// this.legendFont;//杨斌 2012-06-26
                else
                    MsChart.Legends[0].Font = chartArea.AxisX.LabelStyle.Font;// this.legendFont;//杨斌 2012-06-26

                //图例文本颜色
                MsChart.Legends[0].ForeColor = chartArea.AxisX.LabelStyle.ForeColor;// this.LegentForeColor;//杨斌 2012-06-26

                //图例文本
                if (this.LegentText != null)
                {
                    if (this.ChartType == ChartTypes.ctPie)//如果是饼图
                    {
                        for (int i = 0; i < MsChart.Series.Count; i++)
                        {
                            if (this.LegentText.Length >= MsChart.Series[i].Points.Count)
                            {
                                for (int j = 0; j < MsChart.Series[i].Points.Count; j++)
                                {
                                    MsChart.Series[i].Points[j].LegendText = this.LegentText[j];
                                }
                            }
                            else
                            {
                                throw (new ApplicationException("Legend text's number is not less than the number"));
                            }
                        }
                    }
                    else//如果是条形图或柱状图
                    {
                        if (this.LegentText.Length >= MsChart.Series.Count)
                        {
                            for (int i = 0; i < MsChart.Series.Count; i++)
                                MsChart.Series[i].Name = this.LegentText[i];
                        }
                        else
                        {
                            throw (new ApplicationException("Legend text's number is not less than the number"));
                        }
                    }
                }
            }

            ////杨斌 2016-05-10
            //MsChart.Titles.Add(new Title("1    2    3", Docking.Left));
            //MsChart.Titles[MsChart.Titles.Count -1].TextOrientation = TextOrientation.Stacked;
            //MsChart.Titles[MsChart.Titles.Count - 1].Font = DataLabelFont;

            return true;
        }


        /// <summary>
        /// 保存图片
        /// </summary>
        /// <param name="strPath">保存图片路径</param>
        /// <returns></returns>
        public bool SaveAsPicture(string strPath, string strPicName)
        {
            if (!System.IO.Directory.Exists(strPath))
            {
                // 目录不存在,建立目录 
                System.IO.Directory.CreateDirectory(strPath);
            }
            try
            {
                this.MsChart.SaveImage(strPath + strPicName, System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Png);
                return true;
            }
            catch (Exception ex)
            {
                string sErr = ex + "";
                return false;
            }
        }

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="strPath"></param>
        /// <returns></returns>
        public bool DeletePicture(string strPath)
        {
            File.Delete(strPath);
            return true;
        }

        /// <summary>
        /// 获取图表的图像
        /// 创建:杨斌 2012-02-07
        /// </summary>
        /// <returns></returns>
        public Bitmap GetBitmap()
        {
            int w = MsChart.Size.Width;
            int h = MsChart.Size.Height;
            Bitmap bm = new Bitmap(w, h);
            MsChart.DrawToBitmap(bm, new Rectangle(0, 0, w, h));
            return bm;
        }
    }
}