<commit_before>module SmartChart
  module Axes

    def self.included(base)
      base.class_eval do
      
        # grid axis style
        attr_accessor :axis
        
        # grid axis labels
        attr_accessor :labels
      end
    end


    private # ---------------------------------------------------------------
  
    ##
    # Labels parameter.
    #
    def chdl
      unless bare_data_set?
        labels = data.map{ |d| d.is_a?(Hash) ? d[:label] : nil }
        labels.compact.size > 0 ? labels.join("|") : nil
      end
    end
  
    ##
    # Axis type parameter.
    #
    def chxt
      return nil unless show_axes?
      values = {
        :left   => "y",
        :right  => "r",
        :top    => "t",
        :bottom => "x"
      }
      axis.keys.map{ |i| values[i] }.join(',')
    end

    ##
    # Axis style parameter.
    #
    def chxs
      return nil unless show_axes?
      data = []
      axis.values.each_with_index do |side,i|
        data << [
          i + 1,                        # index
          side[:color],                 # color
          side[:font_size],             # font size
          alignment(side[:text_align]), # alignment
          (side[:color] ? "l" : "") +
            (side[:ticks] ? "t" : ""),  # drawing control
          side[:ticks]                  # tick mark color
        ].map{ |i| i.to_s }
      end
      out = data.map{ |i| i.join(',') }.join("|")
      out == "" ? nil : out
    end
    
    ##
    # Translate an alignment name into a URL parameter value.
    #
    def alignment(name)
      {
        "left"   => -1,<commit_msg>Get basic label text and positioning working, without alignment to data points.<commit_after>module SmartChart
  module Axes

    def self.included(base)
      base.class_eval do
      
        # grid axis style
        attr_accessor :axis
        
        # grid axis labels
        attr_accessor :labels
      end
    end


    private # ---------------------------------------------------------------
  
    ##
    # Labels parameter.
    #
    def chdl
      unless bare_data_set?
        labels = data.map{ |d| d.is_a?(Hash) ? d[:label] : nil }
        labels.compact.size > 0 ? labels.join("|") : nil
      end
    end
  
    ##
    # Axis type parameter.
    #
    def chxt
      return nil unless show_axes?
      values = {
        :left   => "y",
        :right  => "r",
        :top    => "t",
        :bottom => "x"
      }
      axis.keys.map{ |i| values[i] }.join(',')
    end

    ##
    # Axis style parameter.
    #
    def chxs
      return nil unless show_axes?
      data = []
      axis.values.each_with_index do |side,i|
        data << [
          i + 1,                        # index
          side[:color],                 # color
          side[:font_size],             # font size
          alignment(side[:text_align]), # alignment
          (side[:color] ? "l" : "") +
            (side[:ticks] ? "t" : ""),  # drawing control
          side[:ticks]                  # tick mark color
        ].map{ |i| i.to_s }
      end
      out = data.map{ |i| i.join(',') }.join("|")
      out == "" ? nil : out
    end
    
    ##
    # Axis labels parameter.
    #
    def chxl
      return nil unless show_axes?
      labels = []
      axis.values.each_with_index do |axis,i|
        axis[:labels].each do |pos,text|
          labels[i] ||= "#{i}:"
          labels[i] << "|" + text
        end
      end
      labels.join('|')
    end
    
    ##
    # Axis labels parameter.
    #
    def chxp
      return nil unless show_axes?
      labels = []
      axis.values.each_with_index do |axis,i|
        axis[:labels].each do |pos,text|
          labels[i] ||= "#{i}"
          labels[i] << "," + pos.to_s
        end
      end
      labels.join('|')
    end
    
    ##
    # Translate an alignment name into a URL parameter value.
    #
    def alignment(name)
      {
        "left"   => -1,
{'fraction_non_alphanumeric': 0.15855212847310732, 'fraction_numerical': 0.0015294417537598777, 'mean_word_length': 1.2761020881670533, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4870117', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1207, 'n_words': 302}