/// <summary>
        /// Adds the label templates to the chart definition
        /// </summary>
        /// <param name="xAxisLabelTemplate">The x-axis label template</param>
        /// <param name="yAxisInterval">The y-axis interval</param>
        /// <returns>The updated chart definition</returns>
        public ChartDefinition WithLabelTemplates
        (
            ChartAxisLabel xAxisLabelTemplate,
            double?yAxisInterval = null
        )
        {
            Validate.IsNotNull(xAxisLabelTemplate);

            if (yAxisInterval < 1)
            {
                throw new ArgumentException
                      (
                          "The y-axis interval must be greater than zero."
                      );
            }

            this.XAxisLabelTemplate = xAxisLabelTemplate;
            this.YAxisInterval      = yAxisInterval;

            return(this);
        }
        /// <summary>
        /// Generates a chart axis label using a value and template
        /// </summary>
        /// <param name="value">The axis value</param>
        /// <param name="rowNumber">The query row number</param>
        /// <param name="template">The label template (optional)</param>
        /// <returns>The label generated</returns>
        private ChartAxisLabel GenerateLabel
        (
            object value,
            int rowNumber,
            ChartAxisLabel template = null
        )
        {
            if (template == null)
            {
                if (value == null)
                {
                    return(new ChartAxisLabel(rowNumber));
                }
                else
                {
                    var valueType = value.GetType();

                    if (valueType.IsNumeric())
                    {
                        return(new ChartAxisLabel
                               (
                                   Convert.ToDouble(value)
                               ));
                    }
                    else if (valueType == typeof(DateTime) || valueType == typeof(DateTime?))
                    {
                        return(new ChartAxisLabel
                               (
                                   (DateTime)value
                               ));
                    }
                    else
                    {
                        return(new ChartAxisLabel
                               (
                                   value.ToString()
                               ));
                    }
                }
            }
            else
            {
                if (value == null)
                {
                    return(template);
                }
                else
                {
                    var valueType = value.GetType();
                    var label     = template.Clone();

                    switch (template.ValueType)
                    {
                    case ChartValueType.Double:

                        if (false == valueType.IsNumeric())
                        {
                            throw new InvalidCastException
                                  (
                                      $"The value '{value}' is not numeric."
                                  );
                        }

                        label.DoubleValue = Convert.ToDouble
                                            (
                            value
                                            );

                        break;

                    case ChartValueType.DateTime:

                        if (valueType != typeof(DateTime) && valueType != typeof(DateTime?))
                        {
                            throw new InvalidCastException
                                  (
                                      $"The value '{value}' is not a valid date."
                                  );
                        }

                        label.DateValue = (DateTime)value;
                        break;

                    default:
                        label.CustomText = value.ToString();
                        break;
                    }

                    return(label);
                }
            }
        }