Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
8.5 KiB

import { c3_chart_internal_fn } from './core';
import { isDefined } from './util';
10 years ago
c3_chart_internal_fn.getDefaultConfig = function () {
var config = {
bindto: '#chart',
svg_classname: undefined,
size_width: undefined,
size_height: undefined,
padding_left: undefined,
padding_right: undefined,
padding_top: undefined,
padding_bottom: undefined,
resize_auto: true,
zoom_enabled: false,
zoom_initialRange: undefined,
zoom_privileged: false,
zoom_rescale: false,
zoom_onzoom: function () {},
zoom_onzoomstart: function () {},
zoom_onzoomend: function () {},
zoom_x_min: undefined,
zoom_x_max: undefined,
interaction_brighten: true,
interaction_enabled: true,
onmouseover: function () {},
onmouseout: function () {},
onresize: function () {},
onresized: function () {},
oninit: function () {},
onrendered: function () {},
transition_duration: 350,
data_x: undefined,
data_xs: {},
data_xFormat: '%Y-%m-%d',
data_xLocaltime: true,
data_xSort: true,
data_idConverter: function (id) { return id; },
data_names: {},
data_classes: {},
data_groups: [],
data_axes: {},
data_type: undefined,
data_types: {},
data_labels: {},
data_order: 'desc',
data_regions: {},
data_color: undefined,
data_colors: {},
data_hide: false,
data_filter: undefined,
data_selection_enabled: false,
data_selection_grouped: false,
data_selection_isselectable: function () { return true; },
data_selection_multiple: true,
data_selection_draggable: false,
data_onclick: function () {},
data_onmouseover: function () {},
data_onmouseout: function () {},
data_onselected: function () {},
data_onunselected: function () {},
data_url: undefined,
data_headers: undefined,
data_json: undefined,
data_rows: undefined,
data_columns: undefined,
data_mimeType: undefined,
data_keys: undefined,
// configuration for no plot-able data supplied.
data_empty_label_text: "",
// subchart
subchart_show: false,
subchart_size_height: 60,
subchart_axis_x_show: true,
subchart_onbrush: function () {},
// color
color_pattern: [],
color_threshold: {},
// legend
legend_show: true,
legend_hide: false,
legend_position: 'bottom',
legend_inset_anchor: 'top-left',
legend_inset_x: 10,
legend_inset_y: 0,
legend_inset_step: undefined,
legend_item_onclick: undefined,
legend_item_onmouseover: undefined,
legend_item_onmouseout: undefined,
legend_equally: false,
legend_padding: 0,
legend_item_tile_width: 10,
legend_item_tile_height: 10,
// axis
axis_rotated: false,
axis_x_show: true,
axis_x_type: 'indexed',
axis_x_localtime: true,
axis_x_categories: [],
axis_x_tick_centered: false,
axis_x_tick_format: undefined,
axis_x_tick_culling: {},
axis_x_tick_culling_max: 10,
axis_x_tick_count: undefined,
axis_x_tick_fit: true,
axis_x_tick_values: null,
axis_x_tick_rotate: 0,
axis_x_tick_outer: true,
axis_x_tick_multiline: true,
axis_x_tick_width: null,
axis_x_max: undefined,
axis_x_min: undefined,
axis_x_padding: {},
axis_x_height: undefined,
axis_x_selection: undefined,
axis_x_label: {},
axis_x_inner: undefined,
axis_y_show: true,
axis_y_type: undefined,
axis_y_max: undefined,
axis_y_min: undefined,
axis_y_inverted: false,
axis_y_center: undefined,
10 years ago
axis_y_inner: undefined,
axis_y_label: {},
axis_y_tick_format: undefined,
axis_y_tick_outer: true,
axis_y_tick_values: null,
axis_y_tick_rotate: 0,
axis_y_tick_count: undefined,
7 years ago
axis_y_tick_time_type: undefined,
axis_y_tick_time_interval: undefined,
axis_y_padding: {},
axis_y_default: undefined,
axis_y2_show: false,
axis_y2_max: undefined,
axis_y2_min: undefined,
axis_y2_inverted: false,
axis_y2_center: undefined,
10 years ago
axis_y2_inner: undefined,
axis_y2_label: {},
axis_y2_tick_format: undefined,
axis_y2_tick_outer: true,
axis_y2_tick_values: null,
axis_y2_tick_count: undefined,
axis_y2_padding: {},
axis_y2_default: undefined,
// grid
grid_x_show: false,
grid_x_type: 'tick',
grid_x_lines: [],
grid_y_show: false,
// not used
// grid_y_type: 'tick',
grid_y_lines: [],
grid_y_ticks: 10,
grid_focus_show: true,
grid_lines_front: true,
// point - point of each data
point_show: true,
point_r: 2.5,
point_sensitivity: 10,
point_focus_expand_enabled: true,
point_focus_expand_r: undefined,
point_select_r: undefined,
// line
line_connectNull: false,
line_step_type: 'step',
// bar
bar_width: undefined,
bar_width_ratio: 0.6,
bar_width_max: undefined,
bar_zerobased: true,
bar_space: 0,
// area
area_zerobased: true,
area_above: false,
// pie
pie_label_show: true,
pie_label_format: undefined,
pie_label_threshold: 0.05,
pie_label_ratio: undefined,
pie_expand: {},
pie_expand_duration: 50,
// gauge
gauge_fullCircle: false,
gauge_label_show: true,
Squashed commit of the following: commit 547311d30ca334c4bcd1c51cf13fa20ae28eb740 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 14:35:09 2017 +0200 for multi-arc-gauge the radius has changed to let the label fit in the chart commit 43ba49dd154995bdfac4ac5d756076616824ae8f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 13:00:29 2017 +0200 fixed warnings of travis check commit 7f5a025de45b06683f08866da2e9680dd149422f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 15:14:34 2016 +0100 rebased, conflict resolved, bugfixed, refactored and tests added commit 013f0666a7e0583a698667a0b8a6702490804ea0 Merge: ff175d1 c343243 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 12:40:39 2017 +0200 Merge remote-tracking branch 'upstream/master' into feature/multi-arc-gauge # Conflicts: # src/arc.js # src/data.js commit ff175d15ea04786b72303d76d2b74ed28d5731f6 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 15:14:34 2016 +0100 optimized position of arc label line commit 0bf2cefff3644852119f5f739208b46779d0db42 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 14:44:50 2016 +0100 wrong tooltip position for gauges fixed commit 155c08c045421775a9b2c378c3e1e3d83c651091 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 14:49:25 2016 +0100 also hide arc label line when gauge_label_show is false commit e145b5c2a5878abe60d2b5a68aeca060778917bd Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 draw line from arc end to its label to highlight the relation commit 28616bf8104ec261ae8c7ee76a9240ef84bc9688 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 add background for every single arc commit cb2aaf16721d2e32ce7aec0a3213d382d7842f72 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 label placement for more than one arc commit 6ecc60987826c2d095406a5d26dfdb914b90d5df Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 gauge_arcs_minWidth property to determine the minimal width of gaugearcs until the innerRadius disappears commit 5689dee384e02faf35f5de085a404d0970fdb9dc Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Aug 27 10:24:18 2015 +0200 visibleTargetCount for cleaner arc calculation commit 9a2686c37f6dcae833fe32f793280bd77479e564 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Aug 27 10:21:13 2015 +0200 more than one arc are possible for gauges commit 0866234001c25ce81a4d7d25804b74e0a9e5d83f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Mon Aug 10 17:07:48 2015 +0200 show legend for gauges which have more than one arc
7 years ago
gauge_labelLine_show: true,
gauge_label_format: undefined,
gauge_min: 0,
gauge_max: 100,
gauge_startingAngle: -1 * Math.PI/2,
gauge_label_extents: undefined,
gauge_units: undefined,
gauge_width: undefined,
Squashed commit of the following: commit 547311d30ca334c4bcd1c51cf13fa20ae28eb740 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 14:35:09 2017 +0200 for multi-arc-gauge the radius has changed to let the label fit in the chart commit 43ba49dd154995bdfac4ac5d756076616824ae8f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 13:00:29 2017 +0200 fixed warnings of travis check commit 7f5a025de45b06683f08866da2e9680dd149422f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 15:14:34 2016 +0100 rebased, conflict resolved, bugfixed, refactored and tests added commit 013f0666a7e0583a698667a0b8a6702490804ea0 Merge: ff175d1 c343243 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Jun 23 12:40:39 2017 +0200 Merge remote-tracking branch 'upstream/master' into feature/multi-arc-gauge # Conflicts: # src/arc.js # src/data.js commit ff175d15ea04786b72303d76d2b74ed28d5731f6 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 15:14:34 2016 +0100 optimized position of arc label line commit 0bf2cefff3644852119f5f739208b46779d0db42 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 14:44:50 2016 +0100 wrong tooltip position for gauges fixed commit 155c08c045421775a9b2c378c3e1e3d83c651091 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Feb 4 14:49:25 2016 +0100 also hide arc label line when gauge_label_show is false commit e145b5c2a5878abe60d2b5a68aeca060778917bd Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 draw line from arc end to its label to highlight the relation commit 28616bf8104ec261ae8c7ee76a9240ef84bc9688 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 add background for every single arc commit cb2aaf16721d2e32ce7aec0a3213d382d7842f72 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 label placement for more than one arc commit 6ecc60987826c2d095406a5d26dfdb914b90d5df Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Fri Aug 28 09:36:31 2015 +0200 gauge_arcs_minWidth property to determine the minimal width of gaugearcs until the innerRadius disappears commit 5689dee384e02faf35f5de085a404d0970fdb9dc Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Aug 27 10:24:18 2015 +0200 visibleTargetCount for cleaner arc calculation commit 9a2686c37f6dcae833fe32f793280bd77479e564 Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Thu Aug 27 10:21:13 2015 +0200 more than one arc are possible for gauges commit 0866234001c25ce81a4d7d25804b74e0a9e5d83f Author: Gökhan Özen <Goekhan.Oezen@hksinformatik.de> Date: Mon Aug 10 17:07:48 2015 +0200 show legend for gauges which have more than one arc
7 years ago
gauge_arcs_minWidth: 5,
gauge_expand: {},
gauge_expand_duration: 50,
// donut
donut_label_show: true,
donut_label_format: undefined,
donut_label_threshold: 0.05,
donut_label_ratio: undefined,
donut_width: undefined,
donut_title: "",
donut_expand: {},
donut_expand_duration: 50,
// spline
spline_interpolation_type: 'cardinal',
// region - region to change style
regions: [],
// tooltip - show when mouseover on each data
tooltip_show: true,
tooltip_grouped: true,
tooltip_order: undefined,
tooltip_format_title: undefined,
tooltip_format_name: undefined,
tooltip_format_value: undefined,
tooltip_position: undefined,
tooltip_contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : '';
},
tooltip_init_show: false,
tooltip_init_x: 0,
tooltip_init_position: {top: '0px', left: '50px'},
tooltip_onshow: function () {},
tooltip_onhide: function () {},
// title
title_text: undefined,
title_padding: {
top: 0,
right: 0,
bottom: 0,
left: 0
},
title_position: 'top-center',
};
10 years ago
Object.keys(this.additionalConfig).forEach(function (key) {
config[key] = this.additionalConfig[key];
}, this);
10 years ago
return config;
};
c3_chart_internal_fn.additionalConfig = {};
c3_chart_internal_fn.loadConfig = function (config) {
var this_config = this.config, target, keys, read;
function find() {
var key = keys.shift();
10 years ago
// console.log("key =>", key, ", target =>", target);
if (key && target && typeof target === 'object' && key in target) {
target = target[key];
return find();
}
else if (!key) {
return target;
}
else {
return undefined;
}
}
Object.keys(this_config).forEach(function (key) {
target = config;
keys = key.split('_');
read = find();
10 years ago
// console.log("CONFIG : ", key, read);
if (isDefined(read)) {
this_config[key] = read;
}
});
};