diff --git a/src/js/charts/cb-xy/parse-xy.js b/src/js/charts/cb-xy/parse-xy.js index dbf909ac..994b389c 100644 --- a/src/js/charts/cb-xy/parse-xy.js +++ b/src/js/charts/cb-xy/parse-xy.js @@ -23,9 +23,17 @@ function parseXY(config, _chartProps, callback, parseOpts) { // clone so that we aren't modifying original // this can probably be avoided by applying new settings differently var chartProps = JSON.parse(JSON.stringify(_chartProps)); + var bySeries = dataBySeries(chartProps.input.raw, { checkForDate: true, - type: chartProps.input.type + type: chartProps.input.type, + inputTZ: (function() { + if (chartProps.scale.dateSettings) { + return chartProps.scale.dateSettings.inputTZ; + } else { + return "Z"; + } + })() }); var labels = chartProps._annotations.labels; diff --git a/src/js/components/chart-grid/ChartGridXY.jsx b/src/js/components/chart-grid/ChartGridXY.jsx index 96f971f1..79cf9ebf 100644 --- a/src/js/components/chart-grid/ChartGridXY.jsx +++ b/src/js/components/chart-grid/ChartGridXY.jsx @@ -276,8 +276,8 @@ function drawXYChartGrid(el, state) { text: numericSettings ? numericSettings.suffix : "", dy: state.grid.rows == 1 ? "1.2em" : 0 }] - }) - + }) + }) .using("xAxis", function(axis) { if(chartProps.scale.isNumeric) { @@ -331,8 +331,8 @@ function drawXYChartGrid(el, state) { text: "", dy: 0 }] - }) - + }) + }) chart.outerWidth(state.dimensions.width); chart.extraPadding(extraPadding); diff --git a/src/js/components/chart-xy/XYRenderer.jsx b/src/js/components/chart-xy/XYRenderer.jsx index 1e737939..fe493844 100644 --- a/src/js/components/chart-xy/XYRenderer.jsx +++ b/src/js/components/chart-xy/XYRenderer.jsx @@ -759,11 +759,9 @@ function drawXY(el, state) { var inputOffset = state.chartProps.scale.dateSettings.inputTZ ? -help.TZOffsetToMinutes(state.chartProps.scale.dateSettings.inputTZ) : curOffset; var timeOffset = 0; axis.tickFormat(function(d,i) { - - if(displayTZ === "as-entered") { + if (displayTZ === "as-entered") { timeOffset = curOffset - inputOffset; } - return dateSettings.dateFormatter(d.clone(),i,timeOffset); }); } diff --git a/src/js/stores/SessionStore.js b/src/js/stores/SessionStore.js index 71139caf..cdac7efb 100644 --- a/src/js/stores/SessionStore.js +++ b/src/js/stores/SessionStore.js @@ -10,7 +10,10 @@ var _session = { separators: detectNumberSeparators(), emSize: 10, width: 640, - timerOn: (localStorage.hasOwnProperty("model") === true), + timerOn: (function() { + if (localStorage) return ( localStorage.hasOwnProperty("model") === true ); + return false; + })(), nowOffset: getTZOffset(now), now: now }; diff --git a/src/js/util/helper.js b/src/js/util/helper.js index 9ad6acb6..b7c65cc0 100644 --- a/src/js/util/helper.js +++ b/src/js/util/helper.js @@ -216,7 +216,7 @@ function merge_or_apply(defaults, source) { } /** - * Given a the domain of a scale suggest the most numerous number + * Given a the domain of a scale suggest the most numerous number * of round number ticks that it cold be divided into while still containing values evenly divisible by 1, 2, 2.5, 5, 10, or 25. * @param {array} domain - An array of two number like objects diff --git a/src/js/util/parse-data-by-series.js b/src/js/util/parse-data-by-series.js index 6b82a5be..651eba02 100644 --- a/src/js/util/parse-data-by-series.js +++ b/src/js/util/parse-data-by-series.js @@ -16,7 +16,8 @@ function dataBySeries(input, opts) { var parsedInput = parseDelimInput(input, { checkForDate: opts.checkForDate, - type: opts.type + type: opts.type, + inputTZ: opts.inputTZ }); var columnNames = parsedInput.columnNames; diff --git a/src/js/util/parse-delimited-input.js b/src/js/util/parse-delimited-input.js index d33c67ab..75712a65 100644 --- a/src/js/util/parse-delimited-input.js +++ b/src/js/util/parse-delimited-input.js @@ -9,12 +9,15 @@ var help = require("./helper.js"); var assign = require("lodash/assign"); var defaults = require("lodash/defaults"); var unique = require("lodash/uniq"); -var separators; +var SessionStore = require("../stores/SessionStore"); + +var curOffset = Date.create().getTimezoneOffset(); +var tz_pattern = /((\+|\-)\d\d\:?\d\d)/gi; // We need this to get the current locale's thousands separator // Check for localStorage in case we are testing from node if (typeof(localStorage) !== 'undefined') { - separators = require("../stores/SessionStore").get("separators"); + separators = SessionStore.get("separators"); } else { separators = { decimal: ".", @@ -40,7 +43,7 @@ function parseDelimInput(input, opts) { var _defaultOpts = defaults(opts, { delimiter: parseUtils.detectDelimiter(input), type: opts.type, - inputTZ: "Z" + inputTZ: SessionStore.get("nowOffset") }); if (opts.checkForDate === false) { @@ -97,12 +100,10 @@ function cast_data(input, columnNames, stripCharsRegex, opts) { var all_index_types = []; var all_entry_values = []; - var tz_pattern = /([+-]\d\d:*\d\d)/gi; - var found_timezones = input.match(tz_pattern); + var found_timezones = tz_pattern.test(input); + var offset = opts.inputTZ !== null ? -help.TZOffsetToMinutes(opts.inputTZ) : curOffset; var data = dsv.parse(input, function(d,ii) { - var curOffset = Date.create().getTimezoneOffset(); - var offset = opts.inputTZ !== null ? -help.TZOffsetToMinutes(opts.inputTZ) : curOffset; each(columnNames, function(column, i) { if (i === 0) { //first column diff --git a/test/timezone-adjustments.js b/test/timezone-adjustments.js index 2e2c94e4..b788fe0b 100644 --- a/test/timezone-adjustments.js +++ b/test/timezone-adjustments.js @@ -75,7 +75,6 @@ test("timezone: tz adjustments", function(t) { entries = cast(input, ["date-col", "val"], stripCharsRegex, opts).entries; t.deepEqual(entries, expected,"dates that don't have a timezone are adjusted to local when there is no inputTZ"); - opts = { type: "date", inputTZ: "-0500",