Ejemplo n.º 1
0
        void OnLoadData4(object sender, RoutedEventArgs e)
        {
            Table tbl = Table.Create(ResKit.GetResource("成绩(交叉表).json"));

            _chart.LoadTable(tbl, "姓名", new List <string> {
                "语文", "数学", "外语"
            });
        }
Ejemplo n.º 2
0
 void InitPrintInfo()
 {
     _printInfo.HeaderLeft   = "<Ts><T Text=\"《:sheetname:》\" Bold=\"true\" Underline=\"true\" /><T Text=\"  :date:\" Foreground=\"#FF4500\" /></Ts>";
     _printInfo.HeaderCenter = "<Ts><T Text=\"标识\" Bold=\"true\" /><Img Width=\"30\" /></Ts>";
     using (var stream = ResKit.GetResource("Logo.png"))
         using (var sr = new StreamReader(stream))
         {
             byte[] img = new byte[stream.Length];
             stream.Read(img, 0, (int)stream.Length);
             _printInfo.HeaderCenterImage = img;
         }
     _printInfo.HeaderRight = "<Ts><T Text=\":num:/:cnt:\" Italic=\"true\" /></Ts>";
     _printInfo.FooterRight = "<Ts><T Text=\":num:[:row:-:col:]\" /></Ts>";
     _fv.Data = _printInfo;
 }
Ejemplo n.º 3
0
        async void OnLoadFile(object sender, RoutedEventArgs e)
        {
            var file = ((Button)sender).Tag.ToString();

            using (var stream = ResKit.GetResource("Excel." + file))
            {
                if (file.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase))
                {
                    await _excel.OpenExcel(stream);
                }
                else
                {
                    await _excel.OpenXml(stream);
                }
            }
        }
Ejemplo n.º 4
0
        public StackedPie()
        {
            InitializeComponent();

            var data = new CSVData();

            data.Read(ResKit.GetResource("browsers.csv"), false);

            int len   = data.Length;
            var vdata = new VersionInfo[len];

            for (int i = 0; i < len; i++)
            {
                vdata[i] = new VersionInfo()
                {
                    Name    = data[i, 0],
                    Version = data[i, 1],
                    Value   = double.Parse(data[i, 2])
                };
            }

            _chart.BeginUpdate();
            _chart.Data.ItemsSource = vdata;
            Binding bindingName = new Binding();

            bindingName.Path            = new PropertyPath("Name");
            _chart.Data.ItemNameBinding = bindingName;

            _chart.Aggregate = Aggregate.Sum;

            // first series - total by browser
            Binding valueBinding = new Binding();

            valueBinding.Path = new PropertyPath("Value");
            var ds1 = new DataSeries()
            {
                ValueBinding       = valueBinding,
                PointLabelTemplate = (DataTemplate)Resources["lbl"],
            };

            ds1.PlotElementLoaded += (PlotElementLoaded);
            Canvas.SetZIndex(ds1, 1);
            _chart.Data.Children.Add(ds1);

            // second series - browser versions
            Binding valueBinding2 = new Binding();

            valueBinding2.Path = new PropertyPath("Value");
            var ds2 = new DataSeries()
            {
                ItemsSource        = vdata, // own data source(no aggregates)
                ValueBinding       = valueBinding2,
                PointLabelTemplate = (DataTemplate)Resources["lbl1"],
            };

            ds2.PlotElementLoaded += (PlotElementLoaded);
            _chart.Data.Children.Add(ds2);

            // _chart type and direction
            _chart.ChartType = ChartType.PieStacked;
            PieOptions.SetDirection(_chart, SweepDirection.Counterclockwise);

            // set palette
            _palette.Add("Internet Explorer", Color.FromArgb(255, 214, 239, 255));
            _palette.Add("Firefox", Color.FromArgb(255, 123, 211, 56));
            _palette.Add("Chrome", Color.FromArgb(255, 239, 21, 123));
            _palette.Add("Safari", Color.FromArgb(255, 255, 186, 0));
            _palette.Add("Opera", Color.FromArgb(255, 0, 174, 222));

            // find max version usage by browser
            foreach (var key in _palette.Keys)
            {
                _maxs[key] = (from item in vdata where item.Name == key select item.Value).Max();
            }

            _chart.EndUpdate();
        }
Ejemplo n.º 5
0
        void OnLoadData3(object sender, RoutedEventArgs e)
        {
            Table tbl = Table.Create(ResKit.GetResource("成绩(交叉表).json"));

            _chart.LoadTable(tbl, "姓名", "语文");
        }
Ejemplo n.º 6
0
        void OnLoadData2(object sender, RoutedEventArgs e)
        {
            Table tbl = Table.Create(ResKit.GetResource("成绩.json"));

            _chart.LoadMatrix(tbl, "subject", "xm", "score");
        }