Skip to content

Commit

Permalink
Charts builder improvements (#2796)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Apr 5, 2018
1 parent 7e4fe7c commit 7bdff39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions web/client/components/charts/Pie.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');
const {pure} = require('recompose');
const {PieChart, Pie, Cell} = require('recharts');
const {convertToNameValue} = require('./polar');

module.exports = ({isAnimationActive, width = 600, height = 300, data, series =[], xAxis, colorGenerator, ...props, maxCols = 3} = {}) => {
module.exports = pure(({isAnimationActive, width = 600, height = 300, data, series =[], xAxis, colorGenerator, ...props, maxCols = 3} = {}) => {
const seriesArray = Array.isArray(series) ? series : [series];
const cols = Math.min(maxCols, seriesArray.length);
const COLORS = colorGenerator(data.length);
Expand All @@ -33,4 +34,4 @@ module.exports = ({isAnimationActive, width = 600, height = 300, data, series =[
}
{props.children}
</PieChart>);
};
});
2 changes: 1 addition & 1 deletion web/client/components/charts/SimpleChart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AUTOCOLOR_DEFAULTS = {
* @param {String} [type="line"] Type of the chart. One of "line", "pie", "bar", "gauge"
* @param {Object} [tooltip={}] false to disable tooltip. TooltipOptions otherwise
* @param {Object} [legend={}] false to disable legend. Legend options otherwise
* @param {Object} [autoColorOptions] [description] Optiopns to generate colors for the chart
* @param {Object} [autoColorOptions] [description] Options to generate colors for the chart
* @param {[type]} props [description]
*/
const SimpleChart = ({type="line", tooltip = {}, legend = {}, autoColorOptions = AUTOCOLOR_DEFAULTS, colorGenerator, ...props} = {}) => {
Expand Down
12 changes: 8 additions & 4 deletions web/client/components/widgets/builder/wizard/chart/ChartType.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


const React = require('react');
const { shouldUpdate } = require('recompose');
const SideGrid = require('../../../../misc/cardgrids/SideGrid');
const Message = require('../../../../I18N/Message');
const sampleData = require('../../../enhancers/sampleChartData');
Expand All @@ -29,15 +30,18 @@ const ITEMS = [{
type: "pie"
}, {
type: "line"
}, {
}/*, {
type: "gauge"
}].map( ({type}) => ({
}
*/].map( ({type}) => ({
type,
title: <Message msgId={`widgets.chartType.${type}.title`} />,
description: <Message msgId={`widgets.chartType.${type}.description`} />,
caption: <Message msgId={`widgets.chartType.${type}.caption`} />
}));
module.exports = ({onSelect = () => {}, onNextPage = () => {}, types = [], type} = {}) => (<Row>
module.exports = shouldUpdate(
({ types, type }, { types: nextTypes, type: nextType}) => type !== nextType && types !== nextTypes
)(({ onSelect = () => { }, onNextPage = () => { }, types = ITEMS, type} = {}) => (<Row>
<StepHeader key="title" title={<Message msgId="widgets.selectChartType.title" />} />
<SideGrid
key="content"
Expand All @@ -58,4 +62,4 @@ module.exports = ({onSelect = () => {}, onNextPage = () => {}, types = [], type}
/>)
}))} />
</Row>
);
));

0 comments on commit 7bdff39

Please sign in to comment.