Skip to content

Commit

Permalink
Merge pull request #1061 from ruanhan/davinci-pro
Browse files Browse the repository at this point in the history
Davinci pro
  • Loading branch information
ruanhan authored Jun 26, 2019
2 parents d0c47ac + f7b6fac commit 098aea5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,16 @@ export class SpecSection extends React.PureComponent<ISpecSectionProps, {}> {
</Checkbox>
</Col>
</Row>
<Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
<Col span={10}>
<Checkbox
checked={stack}
onChange={this.checkboxChange('stack')}
>
堆叠
</Checkbox>
</Col>
</Row>
</div>
</div>
)
Expand Down
14 changes: 8 additions & 6 deletions webapp/app/containers/Widget/render/chart/doubleYAxis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ export default function (chartProps: IChartProps, drillOptions) {

const { selectedItems } = drillOptions
const { secondaryMetrics } = chartProps

const seriesData = secondaryMetrics
? getAixsMetrics('metrics', metrics, data, stack, labelOption, selectedItems, yAxisLeft)
.concat(getAixsMetrics('secondaryMetrics', secondaryMetrics, data, stack, labelOption, selectedItems, yAxisRight))
: getAixsMetrics('metrics', metrics, data, stack, labelOption, selectedItems, yAxisLeft)
? getAixsMetrics('metrics', metrics, data, stack, labelOption, selectedItems, {key: 'yAxisLeft', type: yAxisLeft})
.concat(getAixsMetrics('secondaryMetrics', secondaryMetrics, data, stack, labelOption, selectedItems, {key: 'yAxisRight', type: yAxisRight}))
: getAixsMetrics('metrics', metrics, data, stack, labelOption, selectedItems, {key: 'yAxisLeft', type: yAxisLeft})

const seriesObj = {
series: seriesData.map((series) => {
Expand Down Expand Up @@ -196,14 +197,14 @@ export default function (chartProps: IChartProps, drillOptions) {
return option
}

export function getAixsMetrics (type, axisMetrics, data, stack, labelOption, selectedItems, axisPosition?: string) {
export function getAixsMetrics (type, axisMetrics, data, stack, labelOption, selectedItems, axisPosition?: {key: string, type: string}) {
const seriesNames = []
const seriesAxis = []
axisMetrics.forEach((m) => {
const decodedMetricName = decodeMetricName(m.name)
const localeMetricName = `[${getAggregatorLocale(m.agg)}] ${decodedMetricName}`
seriesNames.push(decodedMetricName)

const stackOption = stack && axisPosition.type === 'bar' && axisMetrics.length > 1 ? { stack: axisPosition.key } : null
const itemData = data.map((g, index) => {
const itemStyle = selectedItems && selectedItems.length && selectedItems.some((item) => item === index) ? {itemStyle: {normal: {opacity: 1, borderWidth: 6}}} : null
return {
Expand All @@ -214,7 +215,8 @@ export function getAixsMetrics (type, axisMetrics, data, stack, labelOption, sel

seriesAxis.push({
name: decodedMetricName,
type: axisPosition ? axisPosition : type === 'metrics' ? 'line' : 'bar',
type: axisPosition && axisPosition.type ? axisPosition.type : type === 'metrics' ? 'line' : 'bar',
...stackOption,
yAxisIndex: type === 'metrics' ? 1 : 0,
data: itemData,
...labelOption,
Expand Down

0 comments on commit 098aea5

Please sign in to comment.