sparkline.go 21.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of
// this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
// Package excelize providing a set of functions that allow you to write to
// and read from XLSX files. Support reads and writes XLSX file generated by
// Microsoft Excel™ 2007 and later. Support save file without losing original
// charts of XLSX. This library needs Go version 1.10 or later.

package excelize

import (
	"encoding/xml"
	"errors"
	"strings"
)

// addSparklineGroupByStyle provides a function to create x14:sparklineGroups
// element by given sparkline style ID.
func (f *File) addSparklineGroupByStyle(ID int) *xlsxX14SparklineGroup {
	groups := []*xlsxX14SparklineGroup{
		{
			ColorSeries:   &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 5},
			ColorMarkers:  &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 4},
			ColorLow:      &xlsxTabColor{Theme: 4},
		}, // 0
		{
			ColorSeries:   &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 5},
			ColorMarkers:  &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 4},
			ColorLow:      &xlsxTabColor{Theme: 4},
		}, // 1
		{
			ColorSeries:   &xlsxTabColor{Theme: 5, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 6},
			ColorMarkers:  &xlsxTabColor{Theme: 5, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 5},
			ColorLow:      &xlsxTabColor{Theme: 5},
		}, // 2
		{
			ColorSeries:   &xlsxTabColor{Theme: 6, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 7},
			ColorMarkers:  &xlsxTabColor{Theme: 6, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 6},
			ColorLow:      &xlsxTabColor{Theme: 6},
		}, // 3
		{
			ColorSeries:   &xlsxTabColor{Theme: 7, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 8},
			ColorMarkers:  &xlsxTabColor{Theme: 7, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 7},
			ColorLow:      &xlsxTabColor{Theme: 7},
		}, // 4
		{
			ColorSeries:   &xlsxTabColor{Theme: 8, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 9},
			ColorMarkers:  &xlsxTabColor{Theme: 8, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 8},
			ColorLow:      &xlsxTabColor{Theme: 8},
		}, // 5
		{
			ColorSeries:   &xlsxTabColor{Theme: 9, Tint: -0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 4},
			ColorMarkers:  &xlsxTabColor{Theme: 9, Tint: -0.499984740745262},
			ColorFirst:    &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921},
			ColorLast:     &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921},
			ColorHigh:     &xlsxTabColor{Theme: 9},
			ColorLow:      &xlsxTabColor{Theme: 9},
		}, // 6
		{
			ColorSeries:   &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 5},
			ColorMarkers:  &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 5},
			ColorLow:      &xlsxTabColor{Theme: 5},
		}, // 7
		{
			ColorSeries:   &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 6},
			ColorMarkers:  &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
		}, // 8
		{
			ColorSeries:   &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 7},
			ColorMarkers:  &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
		}, // 9
		{
			ColorSeries:   &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 8},
			ColorMarkers:  &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
		}, // 10
		{
			ColorSeries:   &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 9},
			ColorMarkers:  &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
		}, // 11
		{
			ColorSeries:   &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorNegative: &xlsxTabColor{Theme: 4},
			ColorMarkers:  &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
		}, // 12
		{
			ColorSeries:   &xlsxTabColor{Theme: 4},
			ColorNegative: &xlsxTabColor{Theme: 5},
			ColorMarkers:  &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
		}, // 13
		{
			ColorSeries:   &xlsxTabColor{Theme: 5},
			ColorNegative: &xlsxTabColor{Theme: 6},
			ColorMarkers:  &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
		}, // 14
		{
			ColorSeries:   &xlsxTabColor{Theme: 6},
			ColorNegative: &xlsxTabColor{Theme: 7},
			ColorMarkers:  &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
		}, // 15
		{
			ColorSeries:   &xlsxTabColor{Theme: 7},
			ColorNegative: &xlsxTabColor{Theme: 8},
			ColorMarkers:  &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
		}, // 16
		{
			ColorSeries:   &xlsxTabColor{Theme: 8},
			ColorNegative: &xlsxTabColor{Theme: 9},
			ColorMarkers:  &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
		}, // 17
		{
			ColorSeries:   &xlsxTabColor{Theme: 9},
			ColorNegative: &xlsxTabColor{Theme: 4},
			ColorMarkers:  &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
		}, // 18
		{
			ColorSeries:   &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 4, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 4, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 4, Tint: -0.499984740745262},
		}, // 19
		{
			ColorSeries:   &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 5, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 5, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 5, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 5, Tint: -0.499984740745262},
		}, // 20
		{
			ColorSeries:   &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 6, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 6, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 6, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 6, Tint: -0.499984740745262},
		}, // 21
		{
			ColorSeries:   &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 7, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 7, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 7, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 7, Tint: -0.499984740745262},
		}, // 22
		{
			ColorSeries:   &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 8, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 8, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 8, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 8, Tint: -0.499984740745262},
		}, // 23
		{
			ColorSeries:   &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262},
			ColorMarkers:  &xlsxTabColor{Theme: 9, Tint: 0.79998168889431442},
			ColorFirst:    &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 9, Tint: -0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 9, Tint: -0.499984740745262},
			ColorLow:      &xlsxTabColor{Theme: 9, Tint: -0.499984740745262},
		}, // 24
		{
			ColorSeries:   &xlsxTabColor{Theme: 1, Tint: 0.499984740745262},
			ColorNegative: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
			ColorMarkers:  &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 1, Tint: 0.249977111117893},
		}, // 25
		{
			ColorSeries:   &xlsxTabColor{Theme: 1, Tint: 0.34998626667073579},
			ColorNegative: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
			ColorMarkers:  &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
			ColorFirst:    &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
			ColorLast:     &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
			ColorHigh:     &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
			ColorLow:      &xlsxTabColor{Theme: 0, Tint: 0.249977111117893},
		}, // 26
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF323232"},
			ColorNegative: &xlsxTabColor{RGB: "FFD00000"},
			ColorMarkers:  &xlsxTabColor{RGB: "FFD00000"},
			ColorFirst:    &xlsxTabColor{RGB: "FFD00000"},
			ColorLast:     &xlsxTabColor{RGB: "FFD00000"},
			ColorHigh:     &xlsxTabColor{RGB: "FFD00000"},
			ColorLow:      &xlsxTabColor{RGB: "FFD00000"},
		}, // 27
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF000000"},
			ColorNegative: &xlsxTabColor{RGB: "FF0070C0"},
			ColorMarkers:  &xlsxTabColor{RGB: "FF0070C0"},
			ColorFirst:    &xlsxTabColor{RGB: "FF0070C0"},
			ColorLast:     &xlsxTabColor{RGB: "FF0070C0"},
			ColorHigh:     &xlsxTabColor{RGB: "FF0070C0"},
			ColorLow:      &xlsxTabColor{RGB: "FF0070C0"},
		}, // 28
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF376092"},
			ColorNegative: &xlsxTabColor{RGB: "FFD00000"},
			ColorMarkers:  &xlsxTabColor{RGB: "FFD00000"},
			ColorFirst:    &xlsxTabColor{RGB: "FFD00000"},
			ColorLast:     &xlsxTabColor{RGB: "FFD00000"},
			ColorHigh:     &xlsxTabColor{RGB: "FFD00000"},
			ColorLow:      &xlsxTabColor{RGB: "FFD00000"},
		}, // 29
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF0070C0"},
			ColorNegative: &xlsxTabColor{RGB: "FF000000"},
			ColorMarkers:  &xlsxTabColor{RGB: "FF000000"},
			ColorFirst:    &xlsxTabColor{RGB: "FF000000"},
			ColorLast:     &xlsxTabColor{RGB: "FF000000"},
			ColorHigh:     &xlsxTabColor{RGB: "FF000000"},
			ColorLow:      &xlsxTabColor{RGB: "FF000000"},
		}, // 30
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF5F5F5F"},
			ColorNegative: &xlsxTabColor{RGB: "FFFFB620"},
			ColorMarkers:  &xlsxTabColor{RGB: "FFD70077"},
			ColorFirst:    &xlsxTabColor{RGB: "FF5687C2"},
			ColorLast:     &xlsxTabColor{RGB: "FF359CEB"},
			ColorHigh:     &xlsxTabColor{RGB: "FF56BE79"},
			ColorLow:      &xlsxTabColor{RGB: "FFFF5055"},
		}, // 31
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF5687C2"},
			ColorNegative: &xlsxTabColor{RGB: "FFFFB620"},
			ColorMarkers:  &xlsxTabColor{RGB: "FFD70077"},
			ColorFirst:    &xlsxTabColor{RGB: "FF777777"},
			ColorLast:     &xlsxTabColor{RGB: "FF359CEB"},
			ColorHigh:     &xlsxTabColor{RGB: "FF56BE79"},
			ColorLow:      &xlsxTabColor{RGB: "FFFF5055"},
		}, // 32
		{
			ColorSeries:   &xlsxTabColor{RGB: "FFC6EFCE"},
			ColorNegative: &xlsxTabColor{RGB: "FFFFC7CE"},
			ColorMarkers:  &xlsxTabColor{RGB: "FF8CADD6"},
			ColorFirst:    &xlsxTabColor{RGB: "FFFFDC47"},
			ColorLast:     &xlsxTabColor{RGB: "FFFFEB9C"},
			ColorHigh:     &xlsxTabColor{RGB: "FF60D276"},
			ColorLow:      &xlsxTabColor{RGB: "FFFF5367"},
		}, // 33
		{
			ColorSeries:   &xlsxTabColor{RGB: "FF00B050"},
			ColorNegative: &xlsxTabColor{RGB: "FFFF0000"},
			ColorMarkers:  &xlsxTabColor{RGB: "FF0070C0"},
			ColorFirst:    &xlsxTabColor{RGB: "FFFFC000"},
			ColorLast:     &xlsxTabColor{RGB: "FFFFC000"},
			ColorHigh:     &xlsxTabColor{RGB: "FF00B050"},
			ColorLow:      &xlsxTabColor{RGB: "FFFF0000"},
		}, // 34
		{
			ColorSeries:   &xlsxTabColor{Theme: 3},
			ColorNegative: &xlsxTabColor{Theme: 9},
			ColorMarkers:  &xlsxTabColor{Theme: 8},
			ColorFirst:    &xlsxTabColor{Theme: 4},
			ColorLast:     &xlsxTabColor{Theme: 5},
			ColorHigh:     &xlsxTabColor{Theme: 6},
			ColorLow:      &xlsxTabColor{Theme: 7},
		}, // 35
		{
			ColorSeries:   &xlsxTabColor{Theme: 1},
			ColorNegative: &xlsxTabColor{Theme: 9},
			ColorMarkers:  &xlsxTabColor{Theme: 8},
			ColorFirst:    &xlsxTabColor{Theme: 4},
			ColorLast:     &xlsxTabColor{Theme: 5},
			ColorHigh:     &xlsxTabColor{Theme: 6},
			ColorLow:      &xlsxTabColor{Theme: 7},
		}, // 36
	}
	return groups[ID]
}

// AddSparkline provides a function to add sparklines to the worksheet by
// given formatting options. Sparklines are small charts that fit in a single
// cell and are used to show trends in data. Sparklines are a feature of Excel
// 2010 and later only. You can write them to an XLSX file that can be read by
// Excel 2007 but they won't be displayed. For example, add a grouped
// sparkline. Changes are applied to all three:
//
//    err := f.AddSparkline("Sheet1", &excelize.SparklineOption{
//        Location: []string{"A1", "A2", "A3"},
//        Range:    []string{"Sheet2!A1:J1", "Sheet2!A2:J2", "Sheet2!A3:J3"},
//        Markers:  true,
//    })
//
// The following shows the formatting options of sparkline supported by excelize:
//
//     Parameter | Description
//    -----------+--------------------------------------------
//     Location  | Required, must have the same number with 'Range' parameter
//     Range     | Required, must have the same number with 'Location' parameter
//     Type      | Enumeration value: line, column, win_loss
//     Style     | Value range: 0 - 35
//     Hight     | Toggle sparkline high points
//     Low       | Toggle sparkline low points
//     First     | Toggle sparkline first points
//     Last      | Toggle sparkline last points
//     Negative  | Toggle sparkline negative points
//     Markers   | Toggle sparkline markers
//     ColorAxis | An RGB Color is specified as RRGGBB
//     Axis      | Show sparkline axis
//
func (f *File) AddSparkline(sheet string, opt *SparklineOption) error {
	// parameter validation
	ws, err := f.parseFormatAddSparklineSet(sheet, opt)
	if err != nil {
		return err
	}
	// Handle the sparkline type
	sparkType := "line"
	sparkTypes := map[string]string{"line": "line", "column": "column", "win_loss": "stacked"}
	if opt.Type != "" {
		specifiedSparkTypes, ok := sparkTypes[opt.Type]
		if !ok {
			return errors.New("parameter 'Type' must be 'line', 'column' or 'win_loss'")
		}
		sparkType = specifiedSparkTypes
	}
	group := f.addSparklineGroupByStyle(opt.Style)
	group.Type = sparkType
	group.ColorAxis = &xlsxColor{RGB: "FF000000"}
	group.DisplayEmptyCellsAs = "gap"
	group.High = opt.High
	group.Low = opt.Low
	group.First = opt.First
	group.Last = opt.Last
	group.Negative = opt.Negative
	group.DisplayXAxis = opt.Axis
	group.Markers = opt.Markers
	if opt.SeriesColor != "" {
		group.ColorSeries = &xlsxTabColor{
			RGB: getPaletteColor(opt.SeriesColor),
		}
	}
	if opt.Reverse {
		group.RightToLeft = opt.Reverse
	}
	f.addSparkline(opt, group)
	if ws.ExtLst.Ext != "" { // append mode ext
		decodeExtLst := decodeWorksheetExt{}
		err = xml.Unmarshal([]byte("<extLst>"+ws.ExtLst.Ext+"</extLst>"), &decodeExtLst)
		if err != nil {
			return err
		}
		for idx, ext := range decodeExtLst.Ext {
			if ext.URI == ExtURISparklineGroups {
				decodeSparklineGroups := decodeX14SparklineGroups{}
				_ = xml.Unmarshal([]byte(ext.Content), &decodeSparklineGroups)
				sparklineGroupBytes, _ := xml.Marshal(group)
				groups := xlsxX14SparklineGroups{
					XMLNSXM: NameSpaceSpreadSheetExcel2006Main,
					Content: decodeSparklineGroups.Content + string(sparklineGroupBytes),
				}
				sparklineGroupsBytes, _ := xml.Marshal(groups)
				decodeExtLst.Ext[idx].Content = string(sparklineGroupsBytes)
			}
		}
		extLstBytes, _ := xml.Marshal(decodeExtLst)
		extLst := string(extLstBytes)
		ws.ExtLst = &xlsxExtLst{
			Ext: strings.TrimSuffix(strings.TrimPrefix(extLst, "<extLst>"), "</extLst>"),
		}
	} else {
		groups := xlsxX14SparklineGroups{
			XMLNSXM:         NameSpaceSpreadSheetExcel2006Main,
			SparklineGroups: []*xlsxX14SparklineGroup{group},
		}
		sparklineGroupsBytes, _ := xml.Marshal(groups)
		extLst := xlsxWorksheetExt{
			URI:     ExtURISparklineGroups,
			Content: string(sparklineGroupsBytes),
		}
		extBytes, _ := xml.Marshal(extLst)
		ws.ExtLst.Ext = string(extBytes)
	}
	return nil
}

// parseFormatAddSparklineSet provides a function to validate sparkline
// properties.
func (f *File) parseFormatAddSparklineSet(sheet string, opt *SparklineOption) (*xlsxWorksheet, error) {
	ws, err := f.workSheetReader(sheet)
	if err != nil {
		return ws, err
	}
	if opt == nil {
		return ws, errors.New("parameter is required")
	}
	if len(opt.Location) < 1 {
		return ws, errors.New("parameter 'Location' is required")
	}
	if len(opt.Range) < 1 {
		return ws, errors.New("parameter 'Range' is required")
	}
	// The ranges and locations must match.\
	if len(opt.Location) != len(opt.Range) {
		return ws, errors.New(`must have the same number of 'Location' and 'Range' parameters`)
	}
	if opt.Style < 0 || opt.Style > 35 {
		return ws, errors.New("parameter 'Style' must betweent 0-35")
	}
	if ws.ExtLst == nil {
		ws.ExtLst = &xlsxExtLst{}
	}
	return ws, err
}

// addSparkline provides a function to create a sparkline in a sparkline group
// by given properties.
func (f *File) addSparkline(opt *SparklineOption, group *xlsxX14SparklineGroup) {
	for idx, location := range opt.Location {
		group.Sparklines.Sparkline = append(group.Sparklines.Sparkline, &xlsxX14Sparkline{
			F:     opt.Range[idx],
			Sqref: location,
		})
	}
}