@@ -1677,6 +1677,82 @@ def validate_coerce(self, v):
1677
1677
return v
1678
1678
1679
1679
1680
+ class DashValidator (EnumeratedValidator ):
1681
+ """
1682
+ Special case validator for handling dash properties that may be specified
1683
+ as lists of dash lengths. These are not currently specified in the
1684
+ schema.
1685
+
1686
+ "dash": {
1687
+ "valType": "string",
1688
+ "values": [
1689
+ "solid",
1690
+ "dot",
1691
+ "dash",
1692
+ "longdash",
1693
+ "dashdot",
1694
+ "longdashdot"
1695
+ ],
1696
+ "dflt": "solid",
1697
+ "role": "style",
1698
+ "editType": "style",
1699
+ "description": "Sets the dash style of lines. Set to a dash type
1700
+ string (*solid*, *dot*, *dash*, *longdash*, *dashdot*, or
1701
+ *longdashdot*) or a dash length list in px (eg *5px,10px,2px,2px*)."
1702
+ },
1703
+ """
1704
+ def __init__ (self ,
1705
+ plotly_name ,
1706
+ parent_name ,
1707
+ values ,
1708
+ ** kwargs ):
1709
+
1710
+ # Add regex to handle dash length lists
1711
+ dash_list_regex = \
1712
+ r"/^\d+(\.\d+)?(px|%)?((,|\s)\s*\d+(\.\d+)?(px|%)?)*$/"
1713
+
1714
+ values = values + [dash_list_regex ]
1715
+
1716
+ # Call EnumeratedValidator superclass
1717
+ super (DashValidator , self ).__init__ (
1718
+ plotly_name = plotly_name ,
1719
+ parent_name = parent_name ,
1720
+ values = values , ** kwargs )
1721
+
1722
+ def description (self ):
1723
+
1724
+ # Separate regular values from regular expressions
1725
+ enum_vals = []
1726
+ enum_regexs = []
1727
+ for v , regex in zip (self .values , self .val_regexs ):
1728
+ if regex is not None :
1729
+ enum_regexs .append (regex .pattern )
1730
+ else :
1731
+ enum_vals .append (v )
1732
+ desc = ("""\
1733
+ The '{name}' property is an enumeration that may be specified as:"""
1734
+ .format (name = self .plotly_name ))
1735
+
1736
+ if enum_vals :
1737
+ enum_vals_str = '\n ' .join (
1738
+ textwrap .wrap (
1739
+ repr (enum_vals ),
1740
+ initial_indent = ' ' * 12 ,
1741
+ subsequent_indent = ' ' * 12 ,
1742
+ break_on_hyphens = False ,
1743
+ width = 80 ))
1744
+
1745
+ desc = desc + """
1746
+ - One of the following dash styles:
1747
+ {enum_vals_str}""" .format (enum_vals_str = enum_vals_str )
1748
+
1749
+ desc = desc + """
1750
+ - A string containing a dash length list in pixels or percentages
1751
+ (e.g. '5px 10px 2px 2px', '5, 10, 2, 2', '10% 20% 40%', etc.)
1752
+ """
1753
+ return desc
1754
+
1755
+
1680
1756
class ImageUriValidator (BaseValidator ):
1681
1757
_PIL = None
1682
1758
0 commit comments