| @@ -205,19 +205,21 @@ | ||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $chart_type . '.csv' ); |
| 208 | 208 | $source->fetch(); |
| 209 | + $series = $source->getSeries(); | |
| 209 | 210 | $response = array( |
| 210 | 211 | 'success' => 2, |
| 211 | 212 | 'message' => __( 'Something went wrong while importing the chart', 'visualizer' ), |
| 212 | 213 | ); |
| 213 | 214 | |
| 215 | + $data = $source->getData(); | |
| 214 | 216 | $args = array( |
| 215 | 217 | 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, |
| 216 | 218 | 'post_title' => 'Visualization', |
| 217 | 219 | 'post_author' => get_current_user_id(), |
| 218 | 220 | 'post_status' => 'publish', |
| 219 | - 'post_content' => $source->getData(), | |
| 221 | + 'post_content' => $data, | |
| 220 | 222 | ); |
| 221 | 223 | $chart_id = wp_insert_post( $args ); |
| 222 | 224 | |
| 223 | 225 | if ( $chart_id && ! is_wp_error( $chart_id ) ) { |
| @@ -227,15 +229,156 @@ | ||
| 227 | 229 | |
| 228 | 230 | update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $chart_type ); |
| 229 | 231 | update_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 ); |
| 230 | 232 | update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() ); |
| 231 | - update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); | |
| 233 | + update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $series ); | |
| 232 | 234 | update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' ); |
| 235 | + | |
| 236 | + $data = maybe_unserialize( $data ); | |
| 237 | + $setting_series = array(); | |
| 238 | + $setting_slices = array(); | |
| 239 | + foreach ( $data as $s ) { | |
| 240 | + $setting_series[] = array( | |
| 241 | + 'visibleInLegend' => '', | |
| 242 | + 'lineWidth' => '', | |
| 243 | + 'pointSize' => '', | |
| 244 | + 'format' => '', | |
| 245 | + 'curveType' => '', | |
| 246 | + 'color' => '', | |
| 247 | + 'role' => '', | |
| 248 | + ); | |
| 249 | + $setting_slices[] = array( | |
| 250 | + 'offset' => 0, | |
| 251 | + 'color' => '', | |
| 252 | + ); | |
| 253 | + } | |
| 233 | 254 | update_post_meta( |
| 234 | 255 | $chart_id, |
| 235 | 256 | Visualizer_Plugin::CF_SETTINGS, |
| 236 | 257 | array( |
| 237 | - 'focusTarget' => 'datum', | |
| 258 | + 'title' => '', | |
| 259 | + 'titlePosition' => '', | |
| 260 | + 'titleTextStyle' => array( | |
| 261 | + 'color' => '#000', | |
| 262 | + ), | |
| 263 | + 'legend' => array( | |
| 264 | + 'position' => 'right', | |
| 265 | + 'alignment' => 15, | |
| 266 | + 'textStyle' => array( | |
| 267 | + 'color' => '#000', | |
| 268 | + 'text' => 'both', | |
| 269 | + ), | |
| 270 | + ), | |
| 271 | + 'tooltip' => array( | |
| 272 | + 'trigger' => 'focus', | |
| 273 | + 'showColorCode' => 0, | |
| 274 | + 'showColorCode' => 0, | |
| 275 | + ), | |
| 276 | + 'animation' => array( | |
| 277 | + 'startup' => 0, | |
| 278 | + 'duration' => '', | |
| 279 | + 'easing' => 'linear', | |
| 280 | + ), | |
| 281 | + 'width' => '', | |
| 282 | + 'height' => '', | |
| 283 | + 'keepAspectRatio' => false, | |
| 284 | + 'isStacked' => false, | |
| 285 | + 'lazy_load_chart' => true, | |
| 286 | + 'backgroundColor' => array( | |
| 287 | + 'strokeWidth' => '', | |
| 288 | + 'stroke' => '', | |
| 289 | + 'fill' => '', | |
| 290 | + ), | |
| 291 | + 'chartArea' => array( | |
| 292 | + 'left' => '', | |
| 293 | + 'top' => '', | |
| 294 | + 'width' => '', | |
| 295 | + 'height' => '', | |
| 296 | + ), | |
| 297 | + 'focusTarget' => 'datum', | |
| 298 | + 'series' => $setting_series, | |
| 299 | + 'slices' => $setting_slices, | |
| 300 | + 'vAxis' => array( | |
| 301 | + 'title' => '', | |
| 302 | + 'textPosition' => '', | |
| 303 | + 'direction' => 1, | |
| 304 | + 'baselineColor' => '#000', | |
| 305 | + 'textStyle' => array( | |
| 306 | + 'color' => '#000', | |
| 307 | + ), | |
| 308 | + 'format' => '', | |
| 309 | + 'gridlines' => array( | |
| 310 | + 'count' => '', | |
| 311 | + 'color' => '#ccc', | |
| 312 | + ), | |
| 313 | + 'minorGridlines' => array( | |
| 314 | + 'count' => '', | |
| 315 | + 'color' => '', | |
| 316 | + ), | |
| 317 | + 'viewWindow' => array( | |
| 318 | + 'max' => '', | |
| 319 | + 'min' => '', | |
| 320 | + ), | |
| 321 | + ), | |
| 322 | + 'hAxis' => array( | |
| 323 | + 'title' => '', | |
| 324 | + 'textPosition' => '', | |
| 325 | + 'direction' => 1, | |
| 326 | + 'baselineColor' => '#000', | |
| 327 | + 'textStyle' => array( | |
| 328 | + 'color' => '#000', | |
| 329 | + ), | |
| 330 | + 'format' => '', | |
| 331 | + 'gridlines' => array( | |
| 332 | + 'count' => '', | |
| 333 | + 'color' => '#ccc', | |
| 334 | + ), | |
| 335 | + 'minorGridlines' => array( | |
| 336 | + 'count' => '', | |
| 337 | + 'color' => '', | |
| 338 | + ), | |
| 339 | + 'viewWindow' => array( | |
| 340 | + 'max' => '', | |
| 341 | + 'min' => '', | |
| 342 | + ), | |
| 343 | + ), | |
| 344 | + 'customcss' => array( | |
| 345 | + 'headerRow' => array( | |
| 346 | + 'background-color' => '', | |
| 347 | + 'color' => '', | |
| 348 | + 'transform' => '', | |
| 349 | + ), | |
| 350 | + 'tableRow' => array( | |
| 351 | + 'background-color' => '', | |
| 352 | + 'color' => '', | |
| 353 | + 'transform' => '', | |
| 354 | + ), | |
| 355 | + 'oddTableRow' => array( | |
| 356 | + 'background-color' => '', | |
| 357 | + 'color' => '', | |
| 358 | + 'transform' => '', | |
| 359 | + ), | |
| 360 | + 'selectedTableRow' => array( | |
| 361 | + 'background-color' => '', | |
| 362 | + 'color' => '', | |
| 363 | + 'transform' => '', | |
| 364 | + ), | |
| 365 | + 'hoverTableRow' => array( | |
| 366 | + 'background-color' => '', | |
| 367 | + 'color' => '', | |
| 368 | + 'transform' => '', | |
| 369 | + ), | |
| 370 | + 'headerCell' => array( | |
| 371 | + 'background-color' => '', | |
| 372 | + 'color' => '', | |
| 373 | + 'transform' => '', | |
| 374 | + ), | |
| 375 | + 'tableCell' => array( | |
| 376 | + 'background-color' => '', | |
| 377 | + 'color' => '', | |
| 378 | + 'transform' => '', | |
| 379 | + ), | |
| 380 | + ), | |
| 238 | 381 | ) |
| 239 | 382 | ); |
| 240 | 383 | $wizard_data = array( |
| 241 | 384 | 'chart_type' => $chart_type, |