Browse Source

Fix timeseries for d3.v4

pull/2246/head
Masayuki Tanaka 7 years ago
parent
commit
1a10d6b451
  1. 2
      htdocs/samples/timeseries.html
  2. 2
      htdocs/samples/timeseries_date.html
  3. 3
      htdocs/samples/timeseries_descendent.html
  4. 2
      htdocs/samples/timeseries_raw.html
  5. 4
      src/core.js
  6. 2
      src/scale.js

2
htdocs/samples/timeseries.html

@ -5,7 +5,7 @@
<body> <body>
<div id="chart"></div> <div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="/js/c3.js"></script>
<script> <script>
var chart = c3.generate({ var chart = c3.generate({

2
htdocs/samples/timeseries_date.html

@ -5,7 +5,7 @@
<body> <body>
<div id="chart"></div> <div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="/js/c3.js"></script>
<script> <script>
var chart = c3.generate({ var chart = c3.generate({

3
htdocs/samples/timeseries_descendent.html

@ -5,9 +5,8 @@
<body> <body>
<div id="chart"></div> <div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="/js/c3.js"></script>
<!-- <script src="/js/c3.min.0.1.35.js"></script>-->
<script> <script>
var dates = ['date', var dates = ['date',

2
htdocs/samples/timeseries_raw.html

@ -5,7 +5,7 @@
<body> <body>
<div id="chart"></div> <div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> <script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script> <script src="/js/c3.js"></script>
<script> <script>

4
src/core.js

@ -107,7 +107,7 @@ c3_chart_internal_fn.initParams = function () {
$$.color = $$.generateColor(); $$.color = $$.generateColor();
$$.levelColor = $$.generateLevelColor(); $$.levelColor = $$.generateLevelColor();
$$.dataTimeFormat = config.data_xLocaltime ? d3.timeFormat : d3.utcFormat; $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)($$.config.data_xFormat);
$$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat;
$$.defaultAxisTimeFormat = function (date) { $$.defaultAxisTimeFormat = function (date) {
if (date.getMilliseconds()) { return d3.timeFormat(".%L")(date); } if (date.getMilliseconds()) { return d3.timeFormat(".%L")(date); }
@ -1030,7 +1030,7 @@ c3_chart_internal_fn.parseDate = function (date) {
if (date instanceof Date) { if (date instanceof Date) {
parsedDate = date; parsedDate = date;
} else if (typeof date === 'string') { } else if (typeof date === 'string') {
parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date); parsedDate = $$.dataTimeParse(date);
} else if (typeof date === 'object') { } else if (typeof date === 'object') {
parsedDate = new Date(+date); parsedDate = new Date(+date);
} else if (typeof date === 'number' && !isNaN(date)) { } else if (typeof date === 'number' && !isNaN(date)) {

2
src/scale.js

@ -1,7 +1,7 @@
import { c3_chart_internal_fn } from './core'; import { c3_chart_internal_fn } from './core';
c3_chart_internal_fn.getScale = function (min, max, forTimeseries) { c3_chart_internal_fn.getScale = function (min, max, forTimeseries) {
return (forTimeseries ? this.d3.time.scale() : this.d3.scaleLinear()).range([min, max]); return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([min, max]);
}; };
c3_chart_internal_fn.getX = function (min, max, domain, offset) { c3_chart_internal_fn.getX = function (min, max, domain, offset) {
var $$ = this, var $$ = this,

Loading…
Cancel
Save