| 1 | package opts |
| 2 | |
| 3 | import "github.com/go-echarts/go-echarts/v2/types" |
| 4 | |
| 5 | // XAxis is the option set for X axis. |
| 6 | // https://echarts.apache.org/en/option.html#xAxis |
| 7 | type XAxis struct { |
| 8 | // Set this to false to prevent the axis from showing. |
| 9 | Show types.Bool `json:"show,omitempty"` |
| 10 | |
| 11 | // AlignTicks turned on to automatically align ticks when multiple numeric y axes. |
| 12 | // Only available for axes of type 'value' and 'log'. |
| 13 | AlignTicks types.Bool `json:"alignTicks,omitempty"` |
| 14 | |
| 15 | // Position The position of x-axis. |
| 16 | // options: |
| 17 | // 'top' |
| 18 | // 'bottom' |
| 19 | Position string `json:"position,omitempty"` |
| 20 | |
| 21 | // Type of axis. |
| 22 | // Option: |
| 23 | // * 'value': Numerical axis, suitable for continuous data. |
| 24 | // * 'category': Category axis, suitable for discrete category data. |
| 25 | // Category data can be auto retrieved from series.data or dataset.source, |
| 26 | // or can be specified via xAxis.data. |
| 27 | // * 'time' Time axis, suitable for continuous time series data. As compared to value axis, |
| 28 | // it has a better formatting for time and a different tick calculation method. For example, |
| 29 | // it decides to use month, week, day or hour for tick based on the range of span. |
| 30 | // * 'log' Log axis, suitable for log data. |
| 31 | Type string `json:"type,omitempty"` |
| 32 | |
| 33 | // BoundaryGap is only available for category axis. true by default. |
| 34 | // When true, category labels sit at the left of each band and data points sit in the center. |
| 35 | // When false, the first and last categories reach the axis edges and data points align with their labels. |
| 36 | BoundaryGap types.Bool `json:"boundaryGap,omitempty"` |
| 37 | |
| 38 | // Name of axis. |
| 39 | Name string `json:"name,omitempty"` |
| 40 | |
| 41 | // Location of axis name. |
| 42 | // |
| 43 | // Options: |
| 44 | // 'start' |
| 45 | // 'middle' or 'center' |
| 46 | // 'end' |
| 47 | NameLocation string `json:"nameLocation,omitempty"` |
| 48 | |
| 49 | // Gap between axis name and axis line. |
| 50 | NameGap int `json:"nameGap,omitempty"` |
| 51 | |
| 52 | // Inverse Set this to true to invert the axis. |
| 53 | // Default false |
| 54 | Inverse types.Bool `json:"inverse,omitempty"` |
| 55 | |
| 56 | // Category data, available in type: 'category' axis. |
| 57 | Data interface{} `json:"data,omitempty"` |
| 58 | |
| 59 | // Number of segments that the axis is split into. Note that this number serves only as a |
| 60 | // recommendation, and the true segments may be adjusted based on readability. |
| 61 | // This is unavailable for category axis. |
| 62 | SplitNumber int `json:"splitNumber,omitempty"` |
| 63 | |
| 64 | // It is available only in numerical axis, i.e., type: 'value'. |
| 65 | // It specifies whether not to contain zero position of axis compulsively. |
| 66 | // When it is set to be true, the axis may not contain zero position, |
| 67 | // which is useful in the scatter chart for both value axes. |
| 68 | // This configuration item is unavailable when the min and max are set. |
| 69 | Scale types.Bool `json:"scale,omitempty"` |
| 70 | |
| 71 | // The minimum value of axis. |
| 72 | // It can be set to a special value 'dataMin' so that the minimum value on this axis is set to be the minimum label. |
| 73 | // It will be automatically computed to make sure axis tick is equally distributed when not set. |
| 74 | Min interface{} `json:"min,omitempty"` |
| 75 | |
| 76 | // The maximum value of axis. |
| 77 | // It can be set to a special value 'dataMax' so that the minimum value on this axis is set to be the maximum label. |
| 78 | // It will be automatically computed to make sure axis tick is equally distributed when not set. |
| 79 | Max interface{} `json:"max,omitempty"` |
| 80 | |
| 81 | // Minimum gap between split lines. For 'time' axis, MinInterval is in unit of milliseconds. |
| 82 | MinInterval float64 `json:"minInterval,omitempty"` |
| 83 | |
| 84 | // Maximum gap between split lines. For 'time' axis, MaxInterval is in unit of milliseconds. |
| 85 | MaxInterval float64 `json:"maxInterval,omitempty"` |
| 86 | |
| 87 | // TriggerEvent Set this to true to enable triggering events, default false |
| 88 | // Parameters of the event include: |
| 89 | //{ |
| 90 | // // Component type: xAxis, yAxis, radiusAxis, angleAxis |
| 91 | // // Each of which has an attribute for index, e.g., xAxisIndex for xAxis |
| 92 | // componentType: string, |
| 93 | // // Value on axis before being formatted. |
| 94 | // // Click on value label to trigger event. |
| 95 | // value: '', |
| 96 | // // Name of axis. |
| 97 | // // Click on laben name to trigger event. |
| 98 | // name: '' |
| 99 | //} |
| 100 | TriggerEvent types.Bool `json:"triggerEvent,omitempty"` |
| 101 | |
| 102 | // The index of grid which the x axis belongs to. Defaults to be in the first grid. |
| 103 | // default 0 |
| 104 | GridIndex int `json:"gridIndex,omitempty"` |
| 105 | |
| 106 | // Split area of X axis in grid area. |
| 107 | SplitArea *SplitArea `json:"splitArea,omitempty"` |
| 108 | |
| 109 | // Split line of X axis in grid area. |
| 110 | SplitLine *SplitLine `json:"splitLine,omitempty"` |
| 111 | |
| 112 | // Settings related to axis line. |
| 113 | AxisLine *AxisLine `json:"axisLine,omitempty"` |
| 114 | |
| 115 | // Settings related to axis label. |
| 116 | AxisLabel *AxisLabel `json:"axisLabel,omitempty"` |
| 117 | |
| 118 | // Settings related to axis tick. |
| 119 | AxisTick *AxisTick `json:"axisTick,omitempty"` |
| 120 | |
| 121 | // Settings related to axis pointer. |
| 122 | AxisPointer *AxisPointer `json:"axisPointer,omitempty"` |
| 123 | } |
| 124 | |
| 125 | // AxisLabel settings related to axis label . |
| 126 | // https://echarts.apache.org/en/option.html#xAxis.axisLabel |
| 127 | // https://echarts.apache.org/en/option.html#yAxis.axisLabel |
| 128 | type AxisLabel struct { |
| 129 | // Set this to false to prevent the axis label from appearing. |
| 130 | Show types.Bool `json:"show,omitempty"` |
| 131 | |
| 132 | // Interval of Axis label, which is available in category axis. |
| 133 | // It uses a strategy that labels do not overlap by default. |
| 134 | // You may set it to be 0 to display all labels compulsively. |
| 135 | // If it is set to be 1, it means that labels are shown once after one label. |
| 136 | // And if it is set to be 2, it means labels are shown once after two labels, and so on. |
| 137 | Interval string `json:"interval,omitempty"` |
| 138 | |
| 139 | // Set this to true so the axis labels face the inside direction. |
| 140 | Inside types.Bool `json:"inside,omitempty"` |
| 141 | |
| 142 | // Rotation degree of axis label, which is especially useful when there is no enough space for category axis. |
| 143 | // Rotation degree is from -90 to 90. |
| 144 | Rotate float64 `json:"rotate,omitempty"` |
| 145 | |
| 146 | // The margin between the axis label and the axis line. |
| 147 | Margin float64 `json:"margin,omitempty"` |
| 148 | |
| 149 | // Formatter of axis label, which supports string template and callback function. |
| 150 | // |
| 151 | // Example: |
| 152 | // |
| 153 | // Use string template; template variable is the default label of axis {value} |
| 154 | // formatter: '{value} kg' |
| 155 | // |
| 156 | // Use callback function; function parameters are axis index |
| 157 | // |
| 158 | // |
| 159 | // formatter: function (value, index) { |
| 160 | // // Formatted to be month/day; display year only in the first label |
| 161 | // var date = new Date(value); |
| 162 | // var texts = [(date.getMonth() + 1), date.getDate()]; |
| 163 | // if (idx === 0) { |
| 164 | // texts.unshift(date.getYear()); |
| 165 | // } |
| 166 | // return texts.join('/'); |
| 167 | // } |
| 168 | Formatter types.FuncStr `json:"formatter,omitempty"` |
| 169 | |
| 170 | ShowMinLabel types.Bool `json:"showMinLabel"` |
| 171 | ShowMaxLabel types.Bool `json:"showMaxLabel"` |
| 172 | |
| 173 | // Alignment of the label of the min tick. If set to be null, it's the same with other labels . |
| 174 | // |
| 175 | // Options are: |
| 176 | // |
| 177 | // 'left' |
| 178 | // 'center' |
| 179 | // 'right' |
| 180 | // null (default) |
| 181 | AlignMinLabel string `json:"alignMinLabel,omitempty"` |
| 182 | |
| 183 | // Alignment of the label of the max tick. If set to be null, it's the same with other labels . |
| 184 | // |
| 185 | // Options are: |
| 186 | // |
| 187 | // 'left' |
| 188 | // 'center' |
| 189 | // 'right' |
| 190 | // null (default) |
| 191 | AlignMaxLabel string `json:"alignMaxLabel,omitempty"` |
| 192 | |
| 193 | // Whether to hide overlapped labels. |
| 194 | HideOverlap types.Bool `json:"hideOverlap,omitempty"` |
| 195 | |
| 196 | // Color of axis label is set to be axisLine.lineStyle.color by default. Callback function is supported, |
| 197 | // in the following format: |
| 198 | // |
| 199 | // (val: string) => Color |
| 200 | // Parameter is the text of label, and return value is the color. See the following example: |
| 201 | // |
| 202 | // textStyle: { |
| 203 | // color: function (value, index) { |
| 204 | // return value >= 0 ? 'green' : 'red'; |
| 205 | // } |
| 206 | // } |
| 207 | Color string `json:"color,omitempty"` |
| 208 | |
| 209 | // axis label font style |
| 210 | FontStyle string `json:"fontStyle,omitempty"` |
| 211 | // axis label font weight |
| 212 | FontWeight string `json:"fontWeight,omitempty"` |
| 213 | // axis label font family |
| 214 | FontFamily string `json:"fontFamily,omitempty"` |
| 215 | // axis label font size |
| 216 | FontSize int `json:"fontSize,omitempty"` |
| 217 | // Horizontal alignment of axis label |
| 218 | Align string `json:"align,omitempty"` |
| 219 | // Vertical alignment of axis label |
| 220 | VerticalAlign string `json:"verticalAlign,omitempty"` |
| 221 | // Line height of the axis label |
| 222 | LineHeight string `json:"lineHeight,omitempty"` |
| 223 | |
| 224 | BackgroundColor string `json:"backgroundColor,omitempty"` |
| 225 | |
| 226 | // Width of text block. |
| 227 | Width int `json:"width,omitempty"` |
| 228 | |
| 229 | // Height of text block. |
| 230 | Height int `json:"height,omitempty"` |
| 231 | |
| 232 | // Determine how to display the text when it's overflow. Available when width is set. |
| 233 | // |
| 234 | // 'truncate' Truncate the text and trailing with ellipsis. |
| 235 | // 'break' Break by word |
| 236 | // 'breakAll' Break by character. |
| 237 | Overflow string `json:"overflow,omitempty"` |
| 238 | |
| 239 | // Ellipsis to be displayed when overflow is set to truncate. |
| 240 | // |
| 241 | // 'truncate' Truncate the overflow lines. |
| 242 | Ellipsis string `json:"ellipsis,omitempty"` |
| 243 | } |
| 244 | |
| 245 | type AxisTick struct { |
| 246 | // Set this to false to prevent the axis tick from showing. |
| 247 | Show types.Bool `json:"show,omitempty"` |
| 248 | |
| 249 | // interval of axisTick, which is available in category axis. is set to be the same as axisLabel.interval by default. |
| 250 | // It uses a strategy that labels do not overlap by default. |
| 251 | // You may set it to be 0 to display all labels compulsively. |
| 252 | // If it is set to be 1, it means that labels are shown once after one label. And if it is set to be 2, it means labels are shown once after two labels, and so on. |
| 253 | // On the other hand, you can control by callback function, whose format is shown below: |
| 254 | // (index:number, value: string) => types.Boolean |
| 255 | // The first parameter is index of category, and the second parameter is the name of category. The return values decides whether to display label. |
| 256 | Interval string `json:"interval,omitempty"` |
| 257 | |
| 258 | // Align axis tick with label, which is available only when boundaryGap is set to be true in category axis. |
| 259 | AlignWithLabel types.Bool `json:"alignWithLabel,omitempty"` |
| 260 | |
| 261 | LineStyle *LineStyle `json:"lineStyle,omitempty"` |
| 262 | } |
| 263 | |
| 264 | // AxisLine controls settings related to axis line. |
| 265 | // https://echarts.apache.org/en/option.html#xAxis.axisLine |
| 266 | // https://echarts.apache.org/en/option.html#yAxis.axisLine |
| 267 | type AxisLine struct { |
| 268 | // Set this to false to prevent the axis line from showing. |
| 269 | Show types.Bool `json:"show,omitempty"` |
| 270 | |
| 271 | // Specifies whether X or Y axis lies on the other's origin position, where value is 0 on axis. |
| 272 | // Valid only if the other axis is of value type, and contains 0 value. |
| 273 | OnZero types.Bool `json:"onZero,omitempty"` |
| 274 | |
| 275 | // When multiple axes exists, this option can be used to specify which axis can be "onZero" to. |
| 276 | OnZeroAxisIndex int `json:"onZeroAxisIndex,omitempty"` |
| 277 | |
| 278 | // Symbol of the two ends of the axis. It could be a string, representing the same symbol for two ends; or an array |
| 279 | // with two string elements, representing the two ends separately. It's set to be 'none' by default, meaning no |
| 280 | // arrow for either end. If it is set to be 'arrow', there shall be two arrows. If there should only one arrow |
| 281 | // at the end, it should set to be ['none', 'arrow']. |
| 282 | Symbol string `json:"symbol,omitempty"` |
| 283 | |
| 284 | // Size of the arrows at two ends. The first is the width perpendicular to the axis, the next is the width parallel to the axis. |
| 285 | SymbolSize []float64 `json:"symbolSize,omitempty"` |
| 286 | |
| 287 | // Arrow offset of axis. If is array, the first number is the offset of the arrow at the beginning, and the second |
| 288 | // number is the offset of the arrow at the end. If is number, it means the arrows have the same offset. |
| 289 | SymbolOffset []float64 `json:"symbolOffset,omitempty"` |
| 290 | |
| 291 | LineStyle *LineStyle `json:"lineStyle,omitempty"` |
| 292 | } |