Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/24108 integration high charts #31

Merged
merged 8 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Tarka Chat UI is a plug and play javascript library to integrate a chat assistan
```
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.0.2.umd.js"></script>
```
Include highcharts library to generate charts by highcharts
```
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
```


2. Initialise the global `TarkaChat` component with options in any script tag
Expand Down Expand Up @@ -80,7 +85,13 @@ where,
"name": "IMAGE_NAME",
}
```

- _HighCharts config type:_
```
{
"type": "highchart-config",
"high_chart_config": { highcharts_config_obj }
}
```
3. _Array containing one/multiple of above mentioned types:_
E.g.

Expand All @@ -98,7 +109,6 @@ where,
]
```


## Demo

Demo is deployed from the application code in `demo/` folder.
Expand Down
2 changes: 2 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
}
</style>

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<!-- Include this javscript -->
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.0.2.umd.js"></script>
</head>
Expand Down
2 changes: 2 additions & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<title>TarkaChat DevMode</title>
</head>
<body>
Expand Down
32 changes: 29 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ import downloadImg from "./images/download.png";

const INITIAL_STATE = false;


Highcharts.setOptions({
credits: {
enabled: false
},
title:{
style: {
fontSize: '12px',
fontWeight: 'normal',
}
},
plotOptions: {
series: {
dataLabels: {
style: {
fontSize: '10px',
fontWeight: 'normal'
}
}
}
},
});

function loadLottie(element) {
const animation = lottie.loadAnimation({
container: element,
Expand Down Expand Up @@ -155,7 +178,6 @@ export default {
</a>
</div>`;
return this.createNode("attachment", nodeContent);

case "image":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@su-docker @shivamarora1 Should we keep the image type supported in tarka-chat?

this.validateFieldPresent('link', data);
const imageContent = `
Expand All @@ -164,8 +186,12 @@ export default {
<img src="${downloadImg}" alt="Download Button" width="24" height="24">
</a>
`;
return this.createNode("image-container", imageContent);

return this.createNode("image-container", imageContent);
case "highchart-config":
this.validateFieldPresent('high_chart_config', data);
let ele = this.createNode("high-chart-container");
Highcharts.chart(ele,data.high_chart_config);
return ele;
default:
throw new Error(`Invalid type: ${type}`);
}
Expand Down
13 changes: 13 additions & 0 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@
}
}

.high-chart-container {
width: 110%;
height: 300px;
position: relative;
border: 1px solid var(--primary-primary-subtle, #f0dafb); /* Set border color as needed */
border-radius: 15px;
margin: 4px 0;

.highcharts-button-box {
fill: var(--primary-primary-subtle, #f0dafb) !important;
}
}

.image-container {
position: relative;
border: 1px solid var(--primary-primary-subtle, #f0dafb); /* Set border color as needed */
Expand Down
Loading