| @@ -205,21 +205,19 @@ | ||
| 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(); | |
| 210 | 209 | $response = array( |
| 211 | 210 | 'success' => 2, |
| 212 | 211 | 'message' => __( 'Something went wrong while importing the chart', 'visualizer' ), |
| 213 | 212 | ); |
| 214 | 213 | |
| 215 | - $data = $source->getData(); | |
| 216 | 214 | $args = array( |
| 217 | 215 | 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, |
| 218 | 216 | 'post_title' => 'Visualization', |
| 219 | 217 | 'post_author' => get_current_user_id(), |
| 220 | 218 | 'post_status' => 'publish', |
| 221 | - 'post_content' => $data, | |
| 219 | + 'post_content' => $source->getData(), | |
| 222 | 220 | ); |
| 223 | 221 | $chart_id = wp_insert_post( $args ); |
| 224 | 222 | |
| 225 | 223 | if ( $chart_id && ! is_wp_error( $chart_id ) ) { |
| @@ -229,156 +227,15 @@ | ||
| 229 | 227 | |
| 230 | 228 | update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $chart_type ); |
| 231 | 229 | update_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 ); |
| 232 | 230 | update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() ); |
| 233 | - update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $series ); | |
| 231 | + update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); | |
| 234 | 232 | 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 | - } | |
| 254 | 233 | update_post_meta( |
| 255 | 234 | $chart_id, |
| 256 | 235 | Visualizer_Plugin::CF_SETTINGS, |
| 257 | 236 | array( |
| 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 | - ), | |
| 237 | + 'focusTarget' => 'datum', | |
| 381 | 238 | ) |
| 382 | 239 | ); |
| 383 | 240 | $wizard_data = array( |
| 384 | 241 | 'chart_type' => $chart_type, |