<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Signum.Entities.DynamicQuery;
using Signum.Entities.Chart;
using Signum.Entities.Reports;
using Signum.Entities;
using Signum.Entities.UserQueries;

namespace Signum.Windows.Chart
{
    /// <summary>
    /// Interaction logic for ChartRequest.xaml
    /// </summary>
    public partial class UserChart : UserControl
    {
        public UserChart()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty QueryDescriptionProperty =
            DependencyProperty.Register("QueryDescription", typeof(QueryDescription), typeof(UserChart), new UIPropertyMetadata(null));
        public QueryDescription QueryDescription
        {
            get { return (QueryDescription)GetValue(QueryDescriptionProperty); }
            set { SetValue(QueryDescriptionProperty, value); }
        }

        private QueryToken[] QueryTokenBuilderFilter_SubTokensEvent(QueryToken token)
        {
            return QueryUtils.SubTokens(token, QueryDescription.Columns);
        }

        internal static UserChartDN FromRequest(ChartRequest request)
        {
            var result = new UserChartDN
            {
                Query = QueryClient.GetQuery(request.QueryName),

                Chart=
                {
                    GroupResults = request.Chart.GroupResults,
                    ChartType = request.Chart.ChartType,
                },

                Filters = request.Filters.Select(f => new QueryFilterDN
                {
                    Token = f.Token,
                    Operation = f.Operation,
                    ValueString = FilterValueConverter.ToString(f.Value, f.Token.Type),
                }).ToMList(),
            };

            Assign(result.Chart.Dimension1, request.Chart.Dimension1);
            Assign(result.Chart.Dimension2, request.Chart.Dimension2);
            Assign(result.Chart.Value1, request.Chart.Value1);
            Assign(result.Chart.Value2, request.Chart.Value2);<commit_msg>Windows.Chart - UserCharts fix<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Signum.Entities.DynamicQuery;
using Signum.Entities.Chart;
using Signum.Entities.Reports;
using Signum.Entities;
using Signum.Entities.UserQueries;

namespace Signum.Windows.Chart
{
    /// <summary>
    /// Interaction logic for ChartRequest.xaml
    /// </summary>
    public partial class UserChart : UserControl
    {
        public static readonly DependencyProperty QueryDescriptionProperty =
           DependencyProperty.Register("QueryDescription", typeof(QueryDescription), typeof(UserChart), new UIPropertyMetadata(null));
        public QueryDescription QueryDescription
        {
            get { return (QueryDescription)GetValue(QueryDescriptionProperty); }
            set { SetValue(QueryDescriptionProperty, value); }
        }

        public UserChart()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(UserChart_Loaded);
        }

        void UserChart_Loaded(object sender, RoutedEventArgs e)
        {
            chartBuilder.Description = QueryDescription;
        }

        private QueryToken[] QueryTokenBuilderFilter_SubTokensEvent(QueryToken token)
        {
            return QueryUtils.SubTokens(token, QueryDescription.Columns);
        }

        internal static UserChartDN FromRequest(ChartRequest request)
        {
            var result = new UserChartDN
            {
                Query = QueryClient.GetQuery(request.QueryName),

                Chart=
                {
                    GroupResults = request.Chart.GroupResults,
                    ChartType = request.Chart.ChartType,
                },

                Filters = request.Filters.Select(f => new QueryFilterDN
                {
                    Token = f.Token,
                    Operation = f.Operation,
                    ValueString = FilterValueConverter.ToString(f.Value, f.Token.Type),
                }).ToMList(),
            };

            Assign(result.Chart.Dimension1, request.Chart.Dimension1);
            Assign(result.Chart.Dimension2, request.Chart.Dimension2);
            Assign(result.Chart.Value1, request.Chart.Value1);
            Assign(result.Chart.Value2, request.Chart.Value2);
{'fraction_non_alphanumeric': 0.08753799392097264, 'fraction_numerical': 0.0032421479229989866, 'mean_word_length': 2.348710990502035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6607029', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1200, 'n_words': 239}